From e6c5c96b07545bb37c2dc7b3359c35e1e35d0b4e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 18 Apr 2016 19:03:11 +0200 Subject: [PATCH] WAGE: Started mouse processing in the WM --- engines/wage/gui.cpp | 2 ++ engines/wage/macwindow.cpp | 6 +++++- engines/wage/macwindow.h | 14 +++++++++----- engines/wage/macwindowmanager.cpp | 25 ++++++++++++++++++++++++- engines/wage/macwindowmanager.h | 2 ++ 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 3afdb48853ae..8833f7f63db8 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -645,6 +645,8 @@ Designed *Gui::mouseUp(int x, int y) { void Gui::mouseDown(int x, int y) { int borderClick; + _wm.mouseDown(x, y); + if (_menu->mouseClick(x, y)) { _menuDirty = true; } else if (_consoleTextArea.contains(x, y)) { diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index 83907400c4f0..e517b7230be0 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -53,7 +53,7 @@ namespace Wage { -MacWindow::MacWindow(bool scrollable) : _scrollable(scrollable) { +MacWindow::MacWindow(int id, bool scrollable) : _scrollable(scrollable), _id(id) { _active = false; _borderIsDirty = true; @@ -235,4 +235,8 @@ void MacWindow::fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h g->fillRect(r, color); } +WindowClick MacWindow::mouseDown(int x, int y) { + return kBorderNone; +} + } // End of namespace Wage diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index 51bc9dfe163b..c47675ef83e3 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -61,16 +61,17 @@ enum { kBorderWidth = 17 }; -enum BorderHighlight { +enum WindowClick { kBorderNone = 0, kBorderScrollUp, kBorderScrollDown, - kBorderCloseButton + kBorderCloseButton, + kBorderInner }; class MacWindow { public: - MacWindow(bool scrollable); + MacWindow(int id, bool scrollable); ~MacWindow(); void move(int x, int y); void resize(int w, int h); @@ -80,9 +81,11 @@ class MacWindow { void setActive(bool active); Graphics::ManagedSurface *getSurface() { return &_surface; } void setTitle(Common::String &title) { _title = title; } - void setHighlight(BorderHighlight highlightedPart) { _highlightedPart = highlightedPart; } + void setHighlight(WindowClick highlightedPart) { _highlightedPart = highlightedPart; } void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; } void setDirty(bool dirty) { _contentIsDirty = dirty; } + int getId() { return _id; } + WindowClick mouseDown(int x, int y); private: void drawBorder(); @@ -99,8 +102,9 @@ class MacWindow { bool _active; bool _borderIsDirty; bool _contentIsDirty; + int _id; - BorderHighlight _highlightedPart; + WindowClick _highlightedPart; float _scrollPos, _scrollSize; Common::Rect _dims; diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index d33fb3355b46..78ca6aded4a3 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -69,7 +69,7 @@ MacWindowManager::~MacWindowManager() { } int MacWindowManager::add(bool scrollable) { - MacWindow *w = new MacWindow(scrollable); + MacWindow *w = new MacWindow(_lastId, scrollable); _windows.push_back(w); _windowStack.push_back(w); @@ -113,4 +113,27 @@ void MacWindowManager::draw() { _fullRefresh = false; } +bool MacWindowManager::mouseDown(int x, int y) { + for (Common::List::const_iterator it = _windowStack.end(); it != _windowStack.begin();) { + it--; + MacWindow *w = *it; + + if (w->getDimensions().contains(x, y)) { + setActive(w->getId()); + + WindowClick click = w->mouseDown(x, y); + + if (click == kBorderInner) { + + } else { + w->setHighlight(click); + } + + return true; + } + } + + return false; +} + } // End of namespace Wage diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index d840799961b2..adb086df8a6f 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -66,6 +66,8 @@ class MacWindowManager { void draw(); + bool mouseDown(int x, int y); + MacWindow *getWindow(int id) { return _windows[id]; } private: