diff options
author | Eugene Sandulenko | 2016-04-25 10:56:45 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-25 10:59:16 +0200 |
commit | b8fcb449c40f742a96aa45bcb01044611bfbf8fa (patch) | |
tree | a0d05110f7356208ed0c7c22ca1663c97a93167e | |
parent | 438ddd586fff6d6a0755aaf83b2d714942cbb9a8 (diff) | |
download | scummvm-rg350-b8fcb449c40f742a96aa45bcb01044611bfbf8fa.tar.gz scummvm-rg350-b8fcb449c40f742a96aa45bcb01044611bfbf8fa.tar.bz2 scummvm-rg350-b8fcb449c40f742a96aa45bcb01044611bfbf8fa.zip |
WAGE: Virtualized MacWindow class
-rw-r--r-- | engines/wage/gui.cpp | 4 | ||||
-rw-r--r-- | engines/wage/macwindow.cpp | 15 | ||||
-rw-r--r-- | engines/wage/macwindow.h | 27 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.cpp | 12 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.h | 8 |
5 files changed, 39 insertions, 27 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 50dadc881f..2841013a26 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -189,10 +189,10 @@ Gui::Gui(WageEngine *engine) { _menu = new Menu(this); - _sceneWindow = _wm.add(false, false); + _sceneWindow = _wm.addWindow(false, false); _sceneWindow->setCallback(sceneWindowCallback, this); - _consoleWindow = _wm.add(true, true); + _consoleWindow = _wm.addWindow(true, true); _consoleWindow->setCallback(consoleWindowCallback, this); } diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index 012574ab0a..36b27a3e56 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -54,21 +54,28 @@ namespace Wage { +BaseMacWindow::BaseMacWindow(int id) : _id(id) { + _callback = 0; + _dataPtr = 0; + + _contentIsDirty = true; + + _type = kWindowUnknown; +} + MacWindow::MacWindow(int id, bool scrollable, bool resizable) : BaseMacWindow(id), _scrollable(scrollable), _resizable(resizable) { _active = false; _borderIsDirty = true; - _contentIsDirty = true; _highlightedPart = kBorderNone; _scrollPos = _scrollSize = 0.0; - _callback = 0; - _dataPtr = 0; - _beingDragged = false; _beingResized = false; + + _type = kWindowWindow; } MacWindow::~MacWindow() { diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index c90fee891f..797e2f9c2a 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -53,8 +53,9 @@ namespace Wage { enum WindowType { - kWindowScene, - kWindowConsole + kWindowUnknown, + kWindowWindow, + kWindowMenu }; enum { @@ -73,22 +74,29 @@ enum WindowClick { class BaseMacWindow { public: - BaseMacWindow(int id) : _id(id) {} - ~BaseMacWindow() {} + BaseMacWindow(int id); + virtual ~BaseMacWindow() {} const Common::Rect &getDimensions() { return _dims; } int getId() { return _id; } + WindowType getType() { return _type; } Graphics::ManagedSurface *getSurface() { return &_surface; } + virtual void setActive(bool active) = 0; + void setDirty(bool dirty) { _contentIsDirty = dirty; } + + virtual bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false) = 0; + virtual bool processEvent(Common::Event &event) = 0; - bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false) { return false; } - bool processEvent(Common::Event &event) { return false; } + virtual bool hasAllFocus() = 0; void setCallback(bool (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; } protected: int _id; + WindowType _type; Graphics::ManagedSurface _surface; + bool _contentIsDirty; Common::Rect _dims; @@ -99,7 +107,7 @@ protected: class MacWindow : public BaseMacWindow { public: MacWindow(int id, bool scrollable, bool resizable); - ~MacWindow(); + virtual ~MacWindow(); void move(int x, int y); void resize(int w, int h); void setDimensions(const Common::Rect &r); @@ -111,10 +119,8 @@ public: void setTitle(Common::String &title) { _title = title; } void setHighlight(WindowClick highlightedPart); void setScroll(float scrollPos, float scrollSize); - void setDirty(bool dirty) { _contentIsDirty = dirty; } bool processEvent(Common::Event &event); - bool beingDragged() { return _beingDragged; } - bool beingResized() { return _beingResized; } + bool hasAllFocus() { return _beingDragged || _beingResized; } private: void drawBorder(); @@ -132,7 +138,6 @@ private: bool _resizable; bool _active; bool _borderIsDirty; - bool _contentIsDirty; bool _beingDragged, _beingResized; int _draggedX, _draggedY; diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 7985f5b624..a86b16a8bb 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -84,7 +84,7 @@ MacWindowManager::~MacWindowManager() { delete _windows[i]; } -MacWindow *MacWindowManager::add(bool scrollable, bool resizable) { +MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) { MacWindow *w = new MacWindow(_lastId, scrollable, resizable); _windows.push_back(w); @@ -120,8 +120,8 @@ void MacWindowManager::draw() { if (_fullRefresh) drawDesktop(); - for (Common::List<MacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++) { - MacWindow *w = *it; + for (Common::List<BaseMacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++) { + BaseMacWindow *w = *it; if (w->draw(_screen, _fullRefresh)) { w->setDirty(false); @@ -147,11 +147,11 @@ bool MacWindowManager::processEvent(Common::Event &event) { event.type != Common::EVENT_LBUTTONUP) return false; - for (Common::List<MacWindow *>::const_iterator it = _windowStack.end(); it != _windowStack.begin();) { + for (Common::List<BaseMacWindow *>::const_iterator it = _windowStack.end(); it != _windowStack.begin();) { it--; - MacWindow *w = *it; + BaseMacWindow *w = *it; - if (w->beingDragged() || w->beingResized() || w->getDimensions().contains(event.mouse.x, event.mouse.y)) { + if (w->hasAllFocus() || 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 5efd0f4037..06b7689706 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, bool resizable); + MacWindow *addWindow(bool scrollable, bool resizable); void setActive(int id); void setFullRefresh(bool redraw) { _fullRefresh = true; } @@ -68,7 +68,7 @@ public: bool processEvent(Common::Event &event); - MacWindow *getWindow(int id) { return _windows[id]; } + BaseMacWindow *getWindow(int id) { return _windows[id]; } private: void drawDesktop(); @@ -76,8 +76,8 @@ private: private: Graphics::ManagedSurface *_screen; - Common::List<MacWindow *> _windowStack; - Common::Array<MacWindow *> _windows; + Common::List<BaseMacWindow *> _windowStack; + Common::Array<BaseMacWindow *> _windows; int _lastId; int _activeWindow; |