aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorVelocityRa2017-04-09 00:05:56 +0300
committerEugene Sandulenko2017-07-17 23:45:22 +0200
commit3a2ce122888cad6656f6b67aa4dc637a8e262d5e (patch)
treed1bd0895fae996c9659cf7a5b6dca48352f27d97 /graphics
parenta169c7efb3c80dafc9cfc2dccf2c31fcffe5be11 (diff)
downloadscummvm-rg350-3a2ce122888cad6656f6b67aa4dc637a8e262d5e.tar.gz
scummvm-rg350-3a2ce122888cad6656f6b67aa4dc637a8e262d5e.tar.bz2
scummvm-rg350-3a2ce122888cad6656f6b67aa4dc637a8e262d5e.zip
WAGE: Fix resizing and text selection bug
Revise/Simplify old optional text rendering Set things up a bit for selected text rendering Add MacTextWindow::clearText and MacTextWindow::setSelection Add MacTextWindow::appendText variant that accepts a MacFont
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/macfontmanager.h6
-rw-r--r--graphics/macgui/mactext.cpp11
-rw-r--r--graphics/macgui/mactext.h4
-rw-r--r--graphics/macgui/mactextwindow.cpp19
-rw-r--r--graphics/macgui/mactextwindow.h21
5 files changed, 51 insertions, 10 deletions
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index c154b8ba66..20c645a7bd 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -77,9 +77,9 @@ public:
_font = NULL;
}
- int getId() { return _id; };
- int getSize() { return _size; }
- int getSlant() { return _slant; }
+ const int getId() const { return _id; };
+ const int getSize() const { return _size; }
+ const int getSlant() const { return _slant; }
Common::String getName() { return _name; }
void setName(Common::String &name) { _name = name; }
void setName(const char *name) { _name = name; }
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 44dddad3ba..fa0510b544 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -327,6 +327,8 @@ void MacText::recalcDims() {
}
void MacText::draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff) {
+ if (_textLines.empty()) return;
+
render();
if (x + w < _surface->w || y + h < _surface->h) {
@@ -361,7 +363,7 @@ void MacText::resizeAndFormatLines(uint numNewLines, MacFontRun *fontRun) {
}
}
-void MacText::appendText(Common::String str, int fontId, int fontSize, int fontSlant) {
+void MacText::appendText(Common::String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular) {
uint oldLen = _textLines.size();
uint newLines = 1 + getNewlinesInString(str);
@@ -387,6 +389,13 @@ void MacText::appendTextDefault(Common::String str) {
render(oldLen, _textLines.size());
}
+void MacText::clearText() {
+ _textLines.clear();
+ _str.clear();
+
+ recalcDims();
+}
+
void MacText::replaceLastLine(Common::String str) {
int oldLen = MAX<int>(0, _textLines.size() - 1);
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index cd2adb3f0e..3870451014 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -92,12 +92,14 @@ public:
int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
// 0 pixels between the lines by default
~MacText();
+
void setInterLinear(int interLinear);
void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
void resizeAndFormatLines(uint numNewLines, MacFontRun * fontRun);
- void appendText(Common::String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular);
+ void appendText(Common::String str, int fontId, int fontSize, int fontSlant);
void appendTextDefault(Common::String str);
+ void clearText();
void replaceLastLine(Common::String str);
int getLineCount() { return _textLines.size(); }
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 22bd2407de..19ed9a8398 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -27,7 +27,7 @@
namespace Graphics {
-MacTextWindow::MacTextWindow(MacWindowManager *wm, const Font *font, int fgcolor,
+MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor,
int bgcolor, int maxWidth, TextAlign textAlignment) :
MacWindow(wm->getNextId(), true, true, true, wm) {
@@ -45,10 +45,25 @@ void MacTextWindow::appendText(Common::String str, int id, int size, int slant)
_mactext->appendText(str, id, size, slant);
}
+void MacTextWindow::appendText(Common::String str, const MacFont *macFont) {
+ _mactext->appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant());
+}
+
+void MacTextWindow::clearText() {
+ _mactext->clearText();
+}
+
+void MacTextWindow::setSelection(int selStartX, int selStartY, int selEndX, int selEndY) {
+ _selectedText.startX = selStartX;
+ _selectedText.startY = selStartY;
+ _selectedText.endX = selEndX;
+ _selectedText.endY = selEndY;
+}
+
MacTextWindow::~MacTextWindow() {
}
-const Font *MacTextWindow::getTextWindowFont() {
+const MacFont *MacTextWindow::getTextWindowFont() {
return _font;
}
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 3ef928eab9..f302f3724d 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -28,20 +28,35 @@
namespace Graphics {
+struct SelectedText {
+ int startX = 0, startY = 0;
+ int endX = 0, endY = 0;
+
+ bool needsRender() {
+ return startX != endX || startY != endY;
+ }
+};
+
class MacTextWindow : public MacWindow {
public:
- MacTextWindow(MacWindowManager *wm, const Font *font, int fgcolor,
+ MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor,
int bgcolor, int maxWidth, TextAlign textAlignment);
~MacTextWindow();
- const Font *getTextWindowFont();
+ const MacFont *getTextWindowFont();
void drawText(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
void appendText(Common::String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular);
+ void appendText(Common::String str, const MacFont *macFont);
+ void clearText();
+
+ void setSelection(int selStartX, int selStartY, int selEndX, int selEndY);
private:
MacText *_mactext;
- const Font *_font;
+ const MacFont *_font;
+
+ SelectedText _selectedText;
};
} // End of namespace Graphics