[Scummvm-cvs-logs] SF.net SVN: scummvm:[35662] scummvm/trunk/gui

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Jan 2 02:31:46 CET 2009


Revision: 35662
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35662&view=rev
Author:   lordhoto
Date:     2009-01-02 01:31:46 +0000 (Fri, 02 Jan 2009)

Log Message:
-----------
Got rid of GuiManager::clearDragWidget instead handle it via a new widget flag WIDGET_IGNORE_DRAG.

Modified Paths:
--------------
    scummvm/trunk/gui/PopUpWidget.cpp
    scummvm/trunk/gui/dialog.cpp
    scummvm/trunk/gui/newgui.cpp
    scummvm/trunk/gui/newgui.h
    scummvm/trunk/gui/widget.h

Modified: scummvm/trunk/gui/PopUpWidget.cpp
===================================================================
--- scummvm/trunk/gui/PopUpWidget.cpp	2009-01-02 01:23:17 UTC (rev 35661)
+++ scummvm/trunk/gui/PopUpWidget.cpp	2009-01-02 01:31:46 UTC (rev 35662)
@@ -358,7 +358,7 @@
 
 PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth)
 	: Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) {
-	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS);
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
 	_type = kPopUpWidget;
 
 	_selectedItem = -1;
@@ -375,7 +375,6 @@
 			_selectedItem = newSel;
 			sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
 		}
-		g_gui.clearDragWidget();
 	}
 }
 

Modified: scummvm/trunk/gui/dialog.cpp
===================================================================
--- scummvm/trunk/gui/dialog.cpp	2009-01-02 01:23:17 UTC (rev 35661)
+++ scummvm/trunk/gui/dialog.cpp	2009-01-02 01:31:46 UTC (rev 35662)
@@ -152,7 +152,8 @@
 
 	w = findWidget(x, y);
 
-	_dragWidget = w;
+	if (w && !(w->getFlags() & WIDGET_IGNORE_DRAG))
+		_dragWidget = w;
 
 	// If the click occured inside a widget which is not the currently
 	// focused one, change the focus to that widget.
@@ -184,7 +185,10 @@
 		}
 	}
 
-	w = _dragWidget;
+	if (_dragWidget)
+		w = _dragWidget;
+	else
+		w = findWidget(x, y);
 
 	if (w)
 		w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);

Modified: scummvm/trunk/gui/newgui.cpp
===================================================================
--- scummvm/trunk/gui/newgui.cpp	2009-01-02 01:23:17 UTC (rev 35661)
+++ scummvm/trunk/gui/newgui.cpp	2009-01-02 01:31:46 UTC (rev 35662)
@@ -394,11 +394,6 @@
 	}
 }
 
-void GuiManager::clearDragWidget() {
-	if (!_dialogStack.empty())
-		_dialogStack.top()->_dragWidget = 0;
-}
-
 bool GuiManager::checkScreenChange() {
 	int tmpScreenChangeID = _system->getScreenChangeID();
 	if (_lastScreenChangeID != tmpScreenChangeID) {

Modified: scummvm/trunk/gui/newgui.h
===================================================================
--- scummvm/trunk/gui/newgui.h	2009-01-02 01:23:17 UTC (rev 35661)
+++ scummvm/trunk/gui/newgui.h	2009-01-02 01:31:46 UTC (rev 35662)
@@ -82,11 +82,6 @@
 	int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
 	int getCharWidth(byte c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
 
-	// FIXME: clearDragWidget is apparently there for the sake of PopUpWidget::handleMouseDown.
-	// This seems to be an ugly hack. At the very least, it should be thoroughly documented.
-	// Better would be to replace it with a proper solution.
-	void clearDragWidget();
-
 	/**
 	 * Tell the GuiManager to check whether the screen resolution has changed.
 	 * If that is the case, the GuiManager will reload/refresh the active theme.

Modified: scummvm/trunk/gui/widget.h
===================================================================
--- scummvm/trunk/gui/widget.h	2009-01-02 01:23:17 UTC (rev 35661)
+++ scummvm/trunk/gui/widget.h	2009-01-02 01:31:46 UTC (rev 35662)
@@ -37,15 +37,24 @@
 class Dialog;
 
 enum {
-	WIDGET_ENABLED		= 1 << 0,
-	WIDGET_INVISIBLE	= 1 << 1,
-	WIDGET_HILITED		= 1 << 2,
-	WIDGET_BORDER		= 1 << 3,
-	//WIDGET_INV_BORDER	= 1 << 4,
-	WIDGET_CLEARBG		= 1 << 5,
-	WIDGET_WANT_TICKLE	= 1 << 7,
-	WIDGET_TRACK_MOUSE	= 1 << 8,
-	WIDGET_RETAIN_FOCUS	= 1 << 9		// Retain focus on mouse up. By default widgets lose focus on mouseup, but some widgets might want to retain it - widgets where you enter text, for instance
+	WIDGET_ENABLED		= 1 <<  0,
+	WIDGET_INVISIBLE	= 1 <<  1,
+	WIDGET_HILITED		= 1 <<  2,
+	WIDGET_BORDER		= 1 <<  3,
+	//WIDGET_INV_BORDER	= 1 <<  4,
+	WIDGET_CLEARBG		= 1 <<  5,
+	WIDGET_WANT_TICKLE	= 1 <<  7,
+	WIDGET_TRACK_MOUSE	= 1 <<  8,
+	// Retain focus on mouse up. By default widgets lose focus on mouseup, 
+	// but some widgets might want to retain it - widgets where you enter
+	// text, for instance
+	WIDGET_RETAIN_FOCUS	= 1 <<  9,
+	// Usually widgets would lock mouse input when the user pressed the
+	// left mouse button till the user releases it.
+	// The PopUpWidget for example does not want this behavior, since the
+	// mouse down will open up a new dialog which silently eats the mouse
+	// up event for its own purposes.
+	WIDGET_IGNORE_DRAG	= 1 << 10
 };
 
 enum {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list