diff options
author | Eugene Sandulenko | 2016-04-24 10:29:08 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-24 10:29:08 +0200 |
commit | b4a2361bf726dfd7939b70e62fd902d80d73161f (patch) | |
tree | 4dda17e8061234e3ed6243ae53d766cc3ca5d4f4 | |
parent | ca4a948240b771e0bb3eeeb4d21fd357b89818b2 (diff) | |
download | scummvm-rg350-b4a2361bf726dfd7939b70e62fd902d80d73161f.tar.gz scummvm-rg350-b4a2361bf726dfd7939b70e62fd902d80d73161f.tar.bz2 scummvm-rg350-b4a2361bf726dfd7939b70e62fd902d80d73161f.zip |
WAGE: Started window resize implementation
-rw-r--r-- | engines/wage/gui.cpp | 11 | ||||
-rw-r--r-- | engines/wage/macwindow.cpp | 56 | ||||
-rw-r--r-- | engines/wage/macwindow.h | 10 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.cpp | 6 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.h | 2 |
5 files changed, 59 insertions, 26 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index b9635fb086..f2de8ad6b6 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -190,10 +190,10 @@ Gui::Gui(WageEngine *engine) { _menu = new Menu(this); - _sceneWindow = _wm.add(false); + _sceneWindow = _wm.add(false, false); _sceneWindow->setCallback(sceneWindowCallback, this); - _consoleWindow = _wm.add(true); + _consoleWindow = _wm.add(true, true); _consoleWindow->setCallback(consoleWindowCallback, this); } @@ -393,6 +393,13 @@ bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) { return false; } + if (click == kBorderResizeButton) { + _consoleDirty = true; + _consoleFullRedraw = true; + + return true; + } + if (click == kBorderInner) { if (event.type == Common::EVENT_LBUTTONDOWN) { startMarking(event.mouse.x, event.mouse.y); diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index f72def0a3a..42e03625e8 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -54,7 +54,8 @@ namespace Wage { -MacWindow::MacWindow(int id, bool scrollable) : _scrollable(scrollable), _id(id) { +MacWindow::MacWindow(int id, bool scrollable, bool resizable) : + _scrollable(scrollable), _id(id), _resizable(resizable) { _active = false; _borderIsDirty = true; _contentIsDirty = true; @@ -67,6 +68,7 @@ MacWindow::MacWindow(int id, bool scrollable) : _scrollable(scrollable), _id(id) _dataPtr = 0; _beingDragged = false; + _beingResized = false; } MacWindow::~MacWindow() { @@ -277,34 +279,35 @@ void MacWindow::fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h g->fillRect(r, color); } -static WindowClick isInBorder(Common::Rect &rect, int x, int y) { - if (rect.contains(x, y)) +WindowClick MacWindow::isInBorder(int x, int y) { + if (_innerDims.contains(x, y)) return kBorderInner; - if (x >= rect.left - kBorderWidth && x < rect.left && y >= rect.top - kBorderWidth && y < rect.top) + if (x >= _innerDims.left - kBorderWidth && x < _innerDims.left && y >= _innerDims.top - kBorderWidth && y < _innerDims.top) return kBorderCloseButton; - if (y >= rect.top - kBorderWidth && y < rect.top) - return kBorderHeader; + if (_resizable) + if (x >= _innerDims.right && x < _innerDims.right + kBorderWidth && y >= _innerDims.bottom && y < _innerDims.bottom + kBorderWidth) + return kBorderResizeButton; - if (x >= rect.right && x < rect.right + kBorderWidth) { - if (y < rect.top - kBorderWidth) - return kBorderNone; + if (_scrollable && x >= _innerDims.right && x < _innerDims.right + kBorderWidth) { + if (y < _innerDims.top - kBorderWidth) + return kBorderBorder; - if (y >= rect.bottom + kBorderWidth) - return kBorderNone; + if (y >= _innerDims.bottom + kBorderWidth) + return kBorderBorder; - if (y >= rect.top + rect.height() / 2) + if (y >= _innerDims.top + _innerDims.height() / 2) return kBorderScrollDown; return kBorderScrollUp; } - return kBorderNone; + return kBorderBorder; } bool MacWindow::processEvent(Common::Event &event) { - WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y); + WindowClick click = isInBorder(event.mouse.x, event.mouse.y); switch (event.type) { case Common::EVENT_MOUSEMOVE: @@ -317,21 +320,40 @@ bool MacWindow::processEvent(Common::Event &event) { ((WageEngine *)g_engine)->_gui->_wm.setFullRefresh(true); } + + if (_beingResized) { + _dims.setWidth(MAX(kBorderWidth * 4, _dims.width() + event.mouse.x - _draggedX)); + _dims.setHeight(MAX(kBorderWidth * 4, _dims.height() + event.mouse.y - _draggedY)); + updateInnerDims(); + + _draggedX = event.mouse.x; + _draggedY = event.mouse.y; + + ((WageEngine *)g_engine)->_gui->_wm.setFullRefresh(true); + (*_callback)(click, event, _dataPtr); + } break; case Common::EVENT_LBUTTONDOWN: setHighlight(click); - if (click == kBorderHeader) { + if (click == kBorderBorder) { _beingDragged = true; _draggedX = event.mouse.x; _draggedY = event.mouse.y; } + if (click == kBorderResizeButton) { + _beingResized = true; + + _draggedX = event.mouse.x; + _draggedY = event.mouse.y; + } + break; case Common::EVENT_LBUTTONUP: - if (_beingDragged) - _beingDragged = false; + _beingDragged = false; + _beingResized = false; setHighlight(kBorderNone); break; diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index a271a54566..527de4a13a 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -67,12 +67,13 @@ enum WindowClick { kBorderScrollDown, kBorderCloseButton, kBorderInner, - kBorderHeader + kBorderBorder, + kBorderResizeButton }; class MacWindow { public: - MacWindow(int id, bool scrollable); + MacWindow(int id, bool scrollable, bool resizable); ~MacWindow(); void move(int x, int y); void resize(int w, int h); @@ -89,6 +90,7 @@ public: bool processEvent(Common::Event &event); void setCallback(bool (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; } bool beingDragged() { return _beingDragged; } + bool beingResized() { return _beingResized; } private: void drawBorder(); @@ -97,18 +99,20 @@ private: const Graphics::Font *getTitleFont(); bool builtInFonts(); void updateInnerDims(); + WindowClick isInBorder(int x, int y); private: Graphics::ManagedSurface _surface; Graphics::ManagedSurface _borderSurface; Graphics::ManagedSurface _composeSurface; bool _scrollable; + bool _resizable; bool _active; bool _borderIsDirty; bool _contentIsDirty; int _id; - bool _beingDragged; + bool _beingDragged, _beingResized; int _draggedX, _draggedY; WindowClick _highlightedPart; diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 798d25f4ed..8625e86490 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -71,8 +71,8 @@ MacWindowManager::~MacWindowManager() { delete _windows[i]; } -MacWindow *MacWindowManager::add(bool scrollable) { - MacWindow *w = new MacWindow(_lastId, scrollable); +MacWindow *MacWindowManager::add(bool scrollable, bool resizable) { + MacWindow *w = new MacWindow(_lastId, scrollable, resizable); _windows.push_back(w); _windowStack.push_back(w); @@ -128,7 +128,7 @@ bool MacWindowManager::processEvent(Common::Event &event) { it--; MacWindow *w = *it; - if (w->beingDragged() || w->getDimensions().contains(event.mouse.x, event.mouse.y)) { + if (w->beingDragged() || w->beingResized() || w->getDimensions().contains(event.mouse.x, event.mouse.y)) { if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP) setActive(w->getId()); diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index 41744931a2..1e8b24b4ad 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -59,7 +59,7 @@ public: void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; } - MacWindow *add(bool scrollable); + MacWindow *add(bool scrollable, bool resizable); void setActive(int id); void setFullRefresh(bool redraw) { _fullRefresh = true; } |