diff options
author | Max Horn | 2002-10-16 20:32:12 +0000 |
---|---|---|
committer | Max Horn | 2002-10-16 20:32:12 +0000 |
commit | b1766c28b276e102bed83652c467df9db270b3ac (patch) | |
tree | 238986ad281e0864aa46979c0f8bf40c950019ea /gui | |
parent | d5bcb63f829f4c4aecd45cb60e492ca896ad77a5 (diff) | |
download | scummvm-rg350-b1766c28b276e102bed83652c467df9db270b3ac.tar.gz scummvm-rg350-b1766c28b276e102bed83652c467df9db270b3ac.tar.bz2 scummvm-rg350-b1766c28b276e102bed83652c467df9db270b3ac.zip |
patch #620627: mouse wheel support for NewGui
svn-id: r5169
Diffstat (limited to 'gui')
-rw-r--r-- | gui/ListWidget.cpp | 5 | ||||
-rw-r--r-- | gui/ListWidget.h | 1 | ||||
-rw-r--r-- | gui/ScrollBarWidget.cpp | 18 | ||||
-rw-r--r-- | gui/ScrollBarWidget.h | 1 | ||||
-rw-r--r-- | gui/dialog.cpp | 15 | ||||
-rw-r--r-- | gui/dialog.h | 1 | ||||
-rw-r--r-- | gui/newgui.cpp | 6 | ||||
-rw-r--r-- | gui/widget.h | 1 |
8 files changed, 48 insertions, 0 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index fb01146b35..b477f4f9ea 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -85,6 +85,11 @@ void ListWidget::handleMouseUp(int x, int y, int button, int clickCount) } } +void ListWidget::handleMouseWheel(int x, int y, int direction) +{ + _scrollBar->handleMouseWheel(x, y, direction); +} + bool ListWidget::handleKeyDown(char key, int modifiers) { bool handled = true; diff --git a/gui/ListWidget.h b/gui/ListWidget.h index 7f05f72a2b..59af0ba1b2 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -68,6 +68,7 @@ public: virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); + virtual void handleMouseWheel(int x, int y, int direction); virtual bool handleKeyDown(char key, int modifiers); virtual bool handleKeyUp(char key, int modifiers); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); diff --git a/gui/ScrollBarWidget.cpp b/gui/ScrollBarWidget.cpp index c9653ef72c..52dd22ef60 100644 --- a/gui/ScrollBarWidget.cpp +++ b/gui/ScrollBarWidget.cpp @@ -31,6 +31,7 @@ * - Allow for a horizontal scrollbar, too? * - If there are less items than fit on one pages, no scrolling can be done * and we thus should not highlight the arrows/slider. + * - Allow the mouse wheel to scroll more than one line at a time */ #define UP_DOWN_BOX_HEIGHT 10 @@ -104,6 +105,23 @@ void ScrollBarWidget::handleMouseUp(int x, int y, int button, int clickCount) _draggingPart = kNoPart; } +void ScrollBarWidget::handleMouseWheel(int x, int y, int direction) +{ + int old_pos = _currentPos; + + if (_numEntries < _entriesPerPage) + return; + + if (direction < 0) { + _currentPos--; + } else { + _currentPos++; + } + + // Make sure that _currentPos is still inside the bounds + checkBounds(old_pos); +} + void ScrollBarWidget::handleMouseMoved(int x, int y, int button) { // Do nothing if there are less items than fit on one page diff --git a/gui/ScrollBarWidget.h b/gui/ScrollBarWidget.h index e4b5752746..6dc76d72b9 100644 --- a/gui/ScrollBarWidget.h +++ b/gui/ScrollBarWidget.h @@ -61,6 +61,7 @@ public: void handleMouseDown(int x, int y, int button, int clickCount); void handleMouseUp(int x, int y, int button, int clickCount); + void handleMouseWheel(int x, int y, int direction); void handleMouseMoved(int x, int y, int button); void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); } void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); _part = kNoPart; draw(); } diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 09f76edb1c..679637967b 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -163,6 +163,21 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount) w->handleMouseUp(x - w->_x, y - w->_y, button, clickCount); } +void Dialog::handleMouseWheel(int x, int y, int direction) +{ + Widget *w; + + // This may look a bit backwards, but I think it makes more sense for + // the mouse wheel to primarily affect the widget the mouse is at than + // the widget that happens to be focused. + + w = findWidget(x, y); + if (!w) + w = _focusedWidget; + if (w) + w->handleMouseWheel(x, y, direction); +} + void Dialog::handleKeyDown(char key, int modifiers) { if (_focusedWidget) { diff --git a/gui/dialog.h b/gui/dialog.h index 7d7224c480..82ad3d9292 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -64,6 +64,7 @@ protected: virtual void handleTickle(); // Called periodically (in every guiloop() ) virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); + virtual void handleMouseWheel(int x, int y, int direction); virtual void handleKeyDown(char key, int modifiers); virtual void handleKeyUp(char key, int modifiers); virtual void handleMouseMoved(int x, int y, int button); diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 61f50e2b72..ffe8d503cc 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -169,6 +169,12 @@ void NewGui::runLoop() case OSystem::EVENT_RBUTTONUP: activeDialog->handleMouseUp(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count); break; + case OSystem::EVENT_WHEELUP: + activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, -1); + break; + case OSystem::EVENT_WHEELDOWN: + activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1); + break; } } diff --git a/gui/widget.h b/gui/widget.h index 718a50f444..99808d49a3 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -103,6 +103,7 @@ public: virtual void handleMouseEntered(int button) {} virtual void handleMouseLeft(int button) {} virtual void handleMouseMoved(int x, int y, int button) {} + virtual void handleMouseWheel(int x, int y, int direction) {} virtual bool handleKeyDown(char key, int modifiers) { return false; } // Return true if the event was handled virtual bool handleKeyUp(char key, int modifiers) { return false; } // Return true if the event was handled virtual void handleTickle() {} |