diff options
-rw-r--r-- | gui/dialog.cpp | 13 | ||||
-rw-r--r-- | gui/dialog.h | 4 | ||||
-rw-r--r-- | gui/widget.cpp | 2 | ||||
-rw-r--r-- | gui/widget.h | 16 | ||||
-rw-r--r-- | newgui.cpp | 4 | ||||
-rw-r--r-- | newgui.h | 25 | ||||
-rw-r--r-- | scumm.h | 14 |
7 files changed, 54 insertions, 24 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 2cdc1f4380..31ab646236 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -43,6 +43,19 @@ void Dialog::handleClick(int x, int y, int button) w->handleClick(button); } +void Dialog::handleMouseMoved(int x, int y, int button) +{ + Widget *w = findWidget(x - _x, y - _y); + if (_mouseWidget != w) { + if (_mouseWidget) + _mouseWidget->handleMouseLeft(button); + if (w) + w->handleMouseEntered(button); + _mouseWidget = w; + } +} + + /* * Determine the widget at location (x,y) if any. Assumes the coordinates are * in the local coordinate system, i.e. relative to the top left of the dialog. diff --git a/gui/dialog.h b/gui/dialog.h index 424af5cebb..a164cc0185 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -35,9 +35,10 @@ protected: Widget *_firstWidget; int16 _x, _y; uint16 _w, _h; + Widget *_mouseWidget; public: Dialog(NewGui *gui, int x, int y, int w, int h) - : _gui(gui), _firstWidget(0), _x(x), _y(y), _w(w), _h(h) + : _gui(gui), _firstWidget(0), _x(x), _y(y), _w(w), _h(h), _mouseWidget(0) {} virtual void draw(); @@ -46,6 +47,7 @@ public: virtual void handleClick(int x, int y, int button); virtual void handleKey(char key, int modifiers) // modifiers = alt/shift/ctrl etc. { if (key == 27) close(); } + virtual void handleMouseMoved(int x, int y, int button); virtual void handleCommand(uint32 cmd) {} diff --git a/gui/widget.cpp b/gui/widget.cpp index 6168eca278..35e0afc366 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -53,7 +53,7 @@ void Widget::draw() } // Now perform the actual widget draw - drawWidget(false); + drawWidget(_flags & WIDGET_HILITED); if (_flags & WIDGET_BORDER) { _x -= 4; diff --git a/gui/widget.h b/gui/widget.h index 30b0b6c431..ec83d723ad 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -29,9 +29,10 @@ class Dialog; enum { WIDGET_ENABLED = 1 << 0, WIDGET_INVISIBLE = 1 << 1, - WIDGET_BORDER = 1 << 2, - WIDGET_CLEARBG = 1 << 3, - WIDGET_WANT_TICKLE = 1 << 4, + WIDGET_HILITED = 1 << 2, + WIDGET_BORDER = 1 << 3, + WIDGET_CLEARBG = 1 << 4, + WIDGET_WANT_TICKLE = 1 << 5, }; /* Widget */ @@ -47,7 +48,9 @@ protected: public: Widget(Dialog *boss, int x, int y, int w, int h); - virtual void handleClick(int button) {} + virtual void handleClick(int button) {} + virtual void handleMouseEntered(int button) {} + virtual void handleMouseLeft(int button) {} void draw(); void setFlags(int flags) { _flags |= flags; } @@ -76,13 +79,16 @@ protected: /* ButtonWidget */ class ButtonWidget : public StaticTextWidget { protected: - uint8 _hotkey; uint32 _cmd; + uint8 _hotkey; public: ButtonWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd); void setCmd(uint32 cmd); uint32 getCmd(); void handleClick(int button); + + void handleMouseEntered(int button) { printf("handleMouseEntered\n"); setFlags(WIDGET_HILITED); draw(); } + void handleMouseLeft(int button) { printf("handleMouseLeft\n"); clearFlags(WIDGET_HILITED); draw(); } }; diff --git a/newgui.cpp b/newgui.cpp index 5383a4d78b..5bfcb43870 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -61,6 +61,10 @@ void NewGui::loop() _activeDialog->handleClick(_s->mouse.x, _s->mouse.y, _s->_mouseButStat); } else if (_s->_lastKeyHit) { _activeDialog->handleKey(_s->_lastKeyHit, 0); + } else if (_old_mouse.x != _s->mouse.x || _old_mouse.y != _s->mouse.y) { + _activeDialog->handleMouseMoved(_s->mouse.x, _s->mouse.y, _s->_mouseButStat); + _old_mouse.x = _s->mouse.x; + _old_mouse.y = _s->mouse.y; } _s->drawDirtyScreenParts(); @@ -44,21 +44,26 @@ public: NewGui(Scumm *s); protected: - Scumm *_s; - bool _active; - bool _need_redraw; - Dialog *_activeDialog; + Scumm *_s; + bool _active; + bool _need_redraw; + Dialog *_activeDialog; - Dialog *_pauseDialog; - Dialog *_saveLoadDialog; + Dialog *_pauseDialog; + Dialog *_saveLoadDialog; // sound state - bool _old_soundsPaused; + bool _old_soundsPaused; // mouse cursor state - bool _old_cursor_mode; - int _old_cursorHotspotX, _old_cursorHotspotY, _old_cursorWidth, _old_cursorHeight; - byte _old_grabbedCursor[2048]; + bool _old_cursor_mode; + int _old_cursorHotspotX, _old_cursorHotspotY, _old_cursorWidth, _old_cursorHeight; + byte _old_grabbedCursor[2048]; + + // mouse pos + struct { + int16 x,y; + } _old_mouse; void saveState(); void restoreState(); @@ -74,7 +74,7 @@ enum { }; struct ScummPoint { - int x,y; + int x, y; }; struct MemBlkHeader { @@ -417,12 +417,12 @@ struct ArrayHeader { }; struct SentenceTab { - byte unk5; - byte unk2; - uint16 unk4; - uint16 unk3; - byte unk; - byte pad; + byte unk5; + byte unk2; + uint16 unk4; + uint16 unk3; + byte unk; + byte pad; }; struct StringTab { |