aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorEugene Sandulenko2017-07-31 09:20:31 +0200
committerEugene Sandulenko2017-08-01 10:42:22 +0200
commitc2944fb5b8912b2d1c1e9207116f249efa46b5ac (patch)
tree01277d12d9015646ad0f12567724a30579b83618 /graphics/macgui
parenta2427fddd72f6c18c1609e50393950c8f2cb20ba (diff)
downloadscummvm-rg350-c2944fb5b8912b2d1c1e9207116f249efa46b5ac.tar.gz
scummvm-rg350-c2944fb5b8912b2d1c1e9207116f249efa46b5ac.tar.bz2
scummvm-rg350-c2944fb5b8912b2d1c1e9207116f249efa46b5ac.zip
GRAPHICS: MACGUI: Simplified cursor code is MacTextWindow
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/mactextwindow.cpp38
-rw-r--r--graphics/macgui/mactextwindow.h4
2 files changed, 15 insertions, 27 deletions
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index c4395cdf19..cf2702ae0a 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -49,6 +49,11 @@ MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgco
_cursorState = false;
_cursorOff = false;
+ _cursorRect = new Common::Rect(0, 0, 1, kCursorHeight);
+
+ _cursorSurface = new ManagedSurface(1, kCursorHeight);
+ _cursorSurface->fillRect(*_cursorRect, kColorBlack);
+
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "textWindowCursor");
}
@@ -76,6 +81,8 @@ void MacTextWindow::setSelection(int selStartX, int selStartY, int selEndX, int
}
MacTextWindow::~MacTextWindow() {
+ delete _cursorSurface;
+
g_system->getTimerManager()->removeTimerProc(&cursorTimerHandler);
}
@@ -100,6 +107,10 @@ bool MacTextWindow::draw(ManagedSurface *g, bool forceRedraw) {
// Compose
_composeSurface.blitFrom(_surface, Common::Rect(0, 0, _surface.w - 2, _surface.h - 2), Common::Point(2, 2));
+
+ if (_cursorState)
+ _composeSurface.blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX, _cursorY));
+
_composeSurface.transBlitFrom(_borderSurface, kColorGreen);
g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
@@ -158,7 +169,6 @@ void MacTextWindow::drawInput() {
_cursorY = _mactext->getTextHeight() - kCursorHeight * 2;
else
_cursorY = _mactext->getTextHeight() - kCursorHeight;
-
}
//////////////////
@@ -166,39 +176,15 @@ void MacTextWindow::drawInput() {
static void cursorTimerHandler(void *refCon) {
MacTextWindow *w = (MacTextWindow *)refCon;
- int x = w->_cursorX;
- int y = w->_cursorY;
-
- if (x == 0 && y == 0)
- return;
-
- x += w->getInnerDimensions().left;
- y += w->getInnerDimensions().top;
- int h = kCursorHeight;
-
- if (y + h > w->getInnerDimensions().bottom) {
- h = w->getInnerDimensions().bottom - y;
- }
-
- if (h > 0)
- w->getSurface()->vLine(x, y, y + h, w->_cursorState ? kColorBlack : kColorWhite);
-
if (!w->_cursorOff)
w->_cursorState = !w->_cursorState;
- w->_cursorRect.left = x;
- w->_cursorRect.right = MIN<uint16>(x + 1, w->getInnerDimensions().right);
- w->_cursorRect.top = MIN<uint16>(y - 1, w->getInnerDimensions().top);
- w->_cursorRect.bottom = MIN<uint16>(y + h, w->getInnerDimensions().bottom);
-
w->_cursorDirty = true;
}
void MacTextWindow::undrawCursor() {
- _cursorOff = true;
_cursorState = false;
- cursorTimerHandler(this);
- _cursorOff = false;
+ _cursorDirty = true;
}
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 0e48122e36..58cd0db04c 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -80,7 +80,7 @@ public:
bool _cursorState;
bool _cursorDirty;
- Common::Rect _cursorRect;
+ Common::Rect *_cursorRect;
bool _cursorOff;
int _scrollPos;
@@ -90,6 +90,8 @@ private:
const MacFont *_font;
const Font *_fontRef;
+ ManagedSurface *_cursorSurface;
+
SelectedText _selectedText;
int _maxWidth;