diff options
author | Eugene Sandulenko | 2016-04-21 10:44:55 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-21 11:03:58 +0200 |
commit | e74a8ba619df3befc3c59ae32de5d5f06377fd20 (patch) | |
tree | 10c34307b28b795b024c185f649909bcebac3898 | |
parent | 4007a6973a63ad5a8510b1f5c3f28a5dc868ca81 (diff) | |
download | scummvm-rg350-e74a8ba619df3befc3c59ae32de5d5f06377fd20.tar.gz scummvm-rg350-e74a8ba619df3befc3c59ae32de5d5f06377fd20.tar.bz2 scummvm-rg350-e74a8ba619df3befc3c59ae32de5d5f06377fd20.zip |
WAGE: Moved console text selection to callbacks
-rw-r--r-- | engines/wage/gui.cpp | 117 | ||||
-rw-r--r-- | engines/wage/gui.h | 3 | ||||
-rw-r--r-- | engines/wage/macwindow.cpp | 32 | ||||
-rw-r--r-- | engines/wage/macwindow.h | 6 |
4 files changed, 78 insertions, 80 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index d6703786ee..7e703b18f5 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -143,8 +143,8 @@ static void cursorTimerHandler(void *refCon) { gui->_cursorDirty = true; } -static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui); -static void consoleWindowCallback(WindowClick click, Common::Event &event, void *gui); +static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *gui); +static bool consoleWindowCallback(WindowClick click, Common::Event &event, void *gui); Gui::Gui(WageEngine *engine) { _engine = engine; @@ -315,18 +315,29 @@ void Gui::drawScene() { _consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth); } -static void sceneWindowCallback(WindowClick click, Common::Event &event, void *g) { +static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *g) { Gui *gui = (Gui *)g; + return gui->processSceneEvents(click, event); +} + +bool Gui::processSceneEvents(WindowClick click, Common::Event &event) { + if (_cursorIsArrow == false) { + CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3); + _cursorIsArrow = true; + } + if (click == kBorderInner && event.type == Common::EVENT_LBUTTONUP) { - Designed *obj = gui->_scene->lookUpEntity(event.mouse.x - gui->_sceneWindow->getDimensions().left, - event.mouse.y - gui->_sceneWindow->getDimensions().top); + Designed *obj = _scene->lookUpEntity(event.mouse.x - _sceneWindow->getDimensions().left, + event.mouse.y - _sceneWindow->getDimensions().top); if (obj != nullptr) - gui->_engine->processTurn(NULL, obj); + _engine->processTurn(NULL, obj); - return; + return true; } + + return false; } // Render console @@ -339,13 +350,18 @@ void Gui::drawConsole() { _consoleWindow->setDirty(true); } -static void consoleWindowCallback(WindowClick click, Common::Event &event, void *g) { +static bool consoleWindowCallback(WindowClick click, Common::Event &event, void *g) { Gui *gui = (Gui *)g; - gui->processConsoleEvents(click, event); + return gui->processConsoleEvents(click, event); } -void Gui::processConsoleEvents(WindowClick click, Common::Event &event) { +bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) { + if (click != kBorderInner && _cursorIsArrow == false) { + CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3); + _cursorIsArrow = true; + } + if (click == kBorderScrollUp || click == kBorderScrollDown) { if (event.type == Common::EVENT_LBUTTONDOWN) { int textFullSize = _lines.size() * _consoleLineHeight + _consoleTextArea.height(); @@ -376,8 +392,49 @@ void Gui::processConsoleEvents(WindowClick click, Common::Event &event) { } } - return; + return true; } + + if (click == kBorderInner) { + if (event.type == Common::EVENT_LBUTTONDOWN) { + startMarking(event.mouse.x, event.mouse.y); + } else if (event.type == Common::EVENT_LBUTTONUP) { + if (_inTextSelection) { + _inTextSelection = false; + + if (_selectionEndY == -1 || + (_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) { + _selectionStartY = _selectionEndY = -1; + _consoleFullRedraw = true; + _menu->enableCommand(kMenuEdit, kMenuActionCopy, false); + } else { + _menu->enableCommand(kMenuEdit, kMenuActionCopy, true); + + bool cutAllowed = false; + + if (_selectionStartY == _selectionEndY && _selectionStartY == (int)_lines.size() - 1) + cutAllowed = true; + + _menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed); + _menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed); + } + } + } else if (event.type == Common::EVENT_MOUSEMOVE) { + if (_inTextSelection) { + updateTextSelection(event.mouse.x, event.mouse.y); + return true; + } + + if (_cursorIsArrow) { + CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3); + _cursorIsArrow = false; + } + } + + return true; + } + + return false; } void Gui::loadFonts() { @@ -443,21 +500,6 @@ void Gui::mouseMove(int x, int y) { return; } - - if (_inTextSelection) { - updateTextSelection(x, y); - return; - } - - if (_consoleTextArea.contains(x, y)) { - if (_cursorIsArrow) { - CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3); - _cursorIsArrow = false; - } - } else if (_cursorIsArrow == false) { - CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3); - _cursorIsArrow = true; - } } void Gui::pushArrowCursor() { @@ -502,35 +544,12 @@ void Gui::mouseUp(int x, int y) { return; } - if (_inTextSelection) { - _inTextSelection = false; - - if (_selectionEndY == -1 || - (_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) { - _selectionStartY = _selectionEndY = -1; - _consoleFullRedraw = true; - _menu->enableCommand(kMenuEdit, kMenuActionCopy, false); - } else { - _menu->enableCommand(kMenuEdit, kMenuActionCopy, true); - - bool cutAllowed = false; - - if (_selectionStartY == _selectionEndY && _selectionStartY == (int)_lines.size() - 1) - cutAllowed = true; - - _menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed); - _menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed); - } - } - return; } void Gui::mouseDown(int x, int y) { if (_menu->mouseClick(x, y)) { _menuDirty = true; - } else if (_consoleTextArea.contains(x, y)) { - startMarking(x, y); } } diff --git a/engines/wage/gui.h b/engines/wage/gui.h index 14208513a5..6783b2efdd 100644 --- a/engines/wage/gui.h +++ b/engines/wage/gui.h @@ -114,7 +114,8 @@ public: bool builtInFonts() { return _builtInFonts; } - void processConsoleEvents(WindowClick click, Common::Event &event); + bool processSceneEvents(WindowClick click, Common::Event &event); + bool processConsoleEvents(WindowClick click, Common::Event &event); private: void drawScene(); diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index f629e3ef8e..01767d7732 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -291,42 +291,22 @@ static WindowClick isInBorder(Common::Rect &rect, int x, int y) { } bool MacWindow::processEvent(Common::Event &event) { + WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y); + switch (event.type) { case Common::EVENT_MOUSEMOVE: - //mouseMove(event.mouse.x, event.mouse.y); break; case Common::EVENT_LBUTTONDOWN: - mouseDown(event); + setHighlight(click); break; - case Common::EVENT_LBUTTONUP: { - setHighlight(kBorderNone); - - WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y); - (*_callback)(click, event, _dataPtr); - } + case Common::EVENT_LBUTTONUP: + setHighlight(kBorderNone); break; - default: return false; } - return true; -} - -void MacWindow::mouseDown(Common::Event &event) { - WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y); - - if (click == kBorderNone) - return; - - setHighlight(click); - - if (click == kBorderScrollUp || click == kBorderScrollDown || click == kBorderInner) { - if (!_callback) - return; - - (*_callback)(click, event, _dataPtr); - } + return (*_callback)(click, event, _dataPtr); } } // End of namespace Wage diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index d82807d670..27ec196f95 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -86,7 +86,7 @@ public: void setDirty(bool dirty) { _contentIsDirty = dirty; } int getId() { return _id; } bool processEvent(Common::Event &event); - void setCallback(void (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; } + void setCallback(bool (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; } private: void drawBorder(); @@ -95,8 +95,6 @@ private: const Graphics::Font *getTitleFont(); bool builtInFonts(); - void mouseDown(Common::Event &event); - private: Graphics::ManagedSurface _surface; Graphics::ManagedSurface _borderSurface; @@ -115,7 +113,7 @@ private: Common::String _title; - void (*_callback)(WindowClick, Common::Event &, void *); + bool (*_callback)(WindowClick, Common::Event &, void *); void *_dataPtr; }; |