aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEugene Sandulenko2017-07-31 19:21:16 +0200
committerEugene Sandulenko2017-08-01 10:42:22 +0200
commite832f1d650fbd66c5a180903d06b089b30bc2a07 (patch)
treee5fb15bec04ec4c39671496a0161dcbf1eb08091 /graphics
parent94a0eadd308dd6cc21dd6102886fcf767df37c66 (diff)
downloadscummvm-rg350-e832f1d650fbd66c5a180903d06b089b30bc2a07.tar.gz
scummvm-rg350-e832f1d650fbd66c5a180903d06b089b30bc2a07.tar.bz2
scummvm-rg350-e832f1d650fbd66c5a180903d06b089b30bc2a07.zip
GRAPHICS: MACGUI: Update cursor position as text being added to MacTextWindow
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/mactextwindow.cpp22
-rw-r--r--graphics/macgui/mactextwindow.h1
2 files changed, 18 insertions, 5 deletions
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 3bb626b3e4..19e1b7d45e 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -39,7 +39,7 @@ MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgco
_fontRef = wm->_fontMan->getFont(*font);
- _inputTextHeight = 0;
+ _inputTextHeight = 1;
_maxWidth = maxWidth;
_scrollPos = 0;
@@ -49,6 +49,8 @@ MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgco
_cursorState = false;
_cursorOff = false;
+ _cursorDirty = true;
+
_cursorRect = new Common::Rect(0, 0, 1, kCursorHeight);
_cursorSurface = new ManagedSurface(1, kCursorHeight);
@@ -63,14 +65,20 @@ void MacTextWindow::drawText(ManagedSurface *g, int x, int y, int w, int h, int
void MacTextWindow::appendText(Common::String str, int id, int size, int slant) {
_mactext->appendText(str, id, size, slant);
+
+ updateCursorPos();
}
void MacTextWindow::appendText(Common::String str, const MacFont *macFont) {
_mactext->appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant());
+
+ updateCursorPos();
}
void MacTextWindow::clearText() {
_mactext->clearText();
+
+ updateCursorPos();
}
void MacTextWindow::setSelection(int selStartX, int selStartY, int selEndX, int selEndY) {
@@ -165,10 +173,7 @@ void MacTextWindow::drawInput() {
_cursorX = _fontRef->getStringWidth(text[_inputTextHeight - 1]);
- if (_scrollPos)
- _cursorY = _mactext->getTextHeight() - kCursorHeight * 2;
- else
- _cursorY = _mactext->getTextHeight() - kCursorHeight;
+ updateCursorPos();
}
//////////////////
@@ -182,6 +187,13 @@ static void cursorTimerHandler(void *refCon) {
w->_cursorDirty = true;
}
+void MacTextWindow::updateCursorPos() {
+ if (_scrollPos)
+ _cursorY = _mactext->getTextHeight() - kCursorHeight * 2;
+ else
+ _cursorY = _mactext->getTextHeight() - kCursorHeight;
+}
+
void MacTextWindow::undrawCursor() {
_cursorState = false;
_cursorDirty = true;
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 58cd0db04c..ddd6c44d35 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -74,6 +74,7 @@ public:
private:
void drawInput();
+ void updateCursorPos();
public:
int _cursorX, _cursorY;