[Scummvm-cvs-logs] CVS: scummvm/gui dialog.cpp,1.44,1.45 dialog.h,1.29,1.30 widget.cpp,1.38,1.39

Max Horn fingolfin at users.sourceforge.net
Tue Dec 28 13:08:03 CET 2004


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5076

Modified Files:
	dialog.cpp dialog.h widget.cpp 
Log Message:
Renamed _clickedWidget -> _dragWidget; if a drag is in process, send the mouse moved / mouse up events to the widget on which the drag is performed (this fixes at least one bug and improves the user experience)

Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- dialog.cpp	25 Dec 2004 23:20:37 -0000	1.44
+++ dialog.cpp	28 Dec 2004 21:07:33 -0000	1.45
@@ -38,7 +38,7 @@
 
 Dialog::Dialog(int x, int y, int w, int h)
 	: GuiObject(x, y, w, h),
-	  _mouseWidget(0), _focusedWidget(0), _clickedWidget(0), _visible(false) {
+	  _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false) {
 }
 
 Dialog::~Dialog() {
@@ -120,7 +120,7 @@
 	Widget *w;
 	w = findWidget(x, y);
 	
-	_clickedWidget = w;
+	_dragWidget = w;
 
 	// If the click occured inside a widget which is not the currently
 	// focused one, change the focus to that widget.
@@ -143,8 +143,6 @@
 void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
 	Widget *w;
 
-	w = findWidget(x, y);
-
 	if (_focusedWidget) {
 		//w = _focusedWidget;
 		
@@ -154,10 +152,12 @@
 		}
 	}
 
-	if (w && w == _clickedWidget)
+	w = _dragWidget;
+
+	if (w)
 		w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
 
-	_clickedWidget = 0;
+	_dragWidget = 0;
 }
 
 void Dialog::handleMouseWheel(int x, int y, int direction) {
@@ -215,9 +215,9 @@
 	Widget *w;
 	
 	//if (!button)
-	//	_clickedWidget = 0;
+	//	_dragWidget = 0;
 	
-	if (_focusedWidget && !_clickedWidget) {
+	if (_focusedWidget && !_dragWidget) {
 		w = _focusedWidget;
 		int wx = w->getAbsX() - _x;
 		int wy = w->getAbsY() - _y;
@@ -237,14 +237,13 @@
 
 		w->handleMouseMoved(x - wx, y - wy, button);
 	}
-
-	w = findWidget(x, y);
 	
 	// While a "drag" is in process (i.e. mouse is moved while a button is pressed),
 	// only deal with the widget in which the click originated.
-	if (_clickedWidget && w != _clickedWidget) {
-		w = 0;
-	}
+	if (_dragWidget)
+		w = _dragWidget;
+	else
+		w = findWidget(x, y);
 
 	if (_mouseWidget != w) {
 		if (_mouseWidget)

Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- dialog.h	25 Dec 2004 23:20:37 -0000	1.29
+++ dialog.h	28 Dec 2004 21:07:34 -0000	1.30
@@ -41,7 +41,7 @@
 protected:
 	Widget	*_mouseWidget;
 	Widget  *_focusedWidget;
-	Widget  *_clickedWidget;
+	Widget  *_dragWidget;
 	bool	_visible;
 
 private:

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- widget.cpp	13 Mar 2004 13:03:25 -0000	1.38
+++ widget.cpp	28 Dec 2004 21:07:34 -0000	1.39
@@ -201,15 +201,13 @@
 
 SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint labelWidth, uint32 cmd, uint8 hotkey)
 	: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
-	  _value(0), _oldValue(0),_valueMin(0), _valueMax(100), _isDragging(false),
+	  _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false),
 	  _labelWidth(labelWidth) {
 	_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
 	_type = kSliderWidget;
 }
 
 void SliderWidget::handleMouseMoved(int x, int y, int button) {
-	// TODO: when the mouse is dragged outside the widget, the slider should
-	// snap back to the old value.
 	if (isEnabled() && _isDragging && x >= (int)_labelWidth) {
 		int newValue = posToValue(x - _labelWidth);
 		if (newValue < _valueMin)





More information about the Scummvm-git-logs mailing list