[Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.7,1.8 ListWidget.h,1.6,1.7 ScrollBarWidget.cpp,1.4,1.5 ScrollBarWidget.h,1.1.1.1,1.2 dialog.cpp,1.19,1.20 dialog.h,1.9,1.10 newgui.cpp,1.21,1.22 widget.h,1.6,1.7
Max Horn
fingolfin at users.sourceforge.net
Wed Oct 16 13:33:06 CEST 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv2225/gui
Modified Files:
ListWidget.cpp ListWidget.h ScrollBarWidget.cpp
ScrollBarWidget.h dialog.cpp dialog.h newgui.cpp widget.h
Log Message:
patch #620627: mouse wheel support for NewGui
Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ListWidget.cpp 1 Oct 2002 23:11:19 -0000 1.7
+++ ListWidget.cpp 16 Oct 2002 20:32:11 -0000 1.8
@@ -85,6 +85,11 @@
}
}
+void ListWidget::handleMouseWheel(int x, int y, int direction)
+{
+ _scrollBar->handleMouseWheel(x, y, direction);
+}
+
bool ListWidget::handleKeyDown(char key, int modifiers)
{
bool handled = true;
Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ListWidget.h 1 Oct 2002 23:11:19 -0000 1.6
+++ ListWidget.h 16 Oct 2002 20:32:11 -0000 1.7
@@ -68,6 +68,7 @@
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);
Index: ScrollBarWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ScrollBarWidget.cpp 9 Oct 2002 19:32:54 -0000 1.4
+++ ScrollBarWidget.cpp 16 Oct 2002 20:32:11 -0000 1.5
@@ -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
@@ -102,6 +103,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)
Index: ScrollBarWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- ScrollBarWidget.h 21 Aug 2002 16:07:25 -0000 1.1.1.1
+++ ScrollBarWidget.h 16 Oct 2002 20:32:11 -0000 1.2
@@ -61,6 +61,7 @@
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(); }
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- dialog.cpp 16 Oct 2002 17:37:29 -0000 1.19
+++ dialog.cpp 16 Oct 2002 20:32:11 -0000 1.20
@@ -163,6 +163,21 @@
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) {
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- dialog.h 16 Oct 2002 17:37:29 -0000 1.9
+++ dialog.h 16 Oct 2002 20:32:11 -0000 1.10
@@ -64,6 +64,7 @@
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);
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- newgui.cpp 16 Oct 2002 17:37:29 -0000 1.21
+++ newgui.cpp 16 Oct 2002 20:32:11 -0000 1.22
@@ -169,6 +169,12 @@
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;
}
}
Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- widget.h 12 Oct 2002 00:26:24 -0000 1.6
+++ widget.h 16 Oct 2002 20:32:12 -0000 1.7
@@ -103,6 +103,7 @@
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() {}
More information about the Scummvm-git-logs
mailing list