diff options
author | Max Horn | 2002-07-06 12:57:51 +0000 |
---|---|---|
committer | Max Horn | 2002-07-06 12:57:51 +0000 |
commit | 671678a6c50d9e6c8aed01e9ff86ad77ead930cc (patch) | |
tree | 73de9e88b858812c2ea9662a4e06eed0595ee5e1 /gui | |
parent | 71080f98ab69cb080c8f09349f72e969bfd5a7e5 (diff) | |
download | scummvm-rg350-671678a6c50d9e6c8aed01e9ff86ad77ead930cc.tar.gz scummvm-rg350-671678a6c50d9e6c8aed01e9ff86ad77ead930cc.tar.bz2 scummvm-rg350-671678a6c50d9e6c8aed01e9ff86ad77ead930cc.zip |
added mouse over effect
svn-id: r4466
Diffstat (limited to 'gui')
-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 |
4 files changed, 28 insertions, 7 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(); } }; |