[Scummvm-cvs-logs] CVS: scummvm/gui dialog.cpp,1.1,1.2 dialog.h,1.1,1.2 widget.cpp,1.1,1.2 widget.h,1.1,1.2

Max Horn fingolfin at users.sourceforge.net
Sat Jul 6 05:58:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv2500/gui

Modified Files:
	dialog.cpp dialog.h widget.cpp widget.h 
Log Message:
added mouse over effect

Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dialog.cpp	5 Jul 2002 16:56:53 -0000	1.1
+++ dialog.cpp	6 Jul 2002 12:57:51 -0000	1.2
@@ -43,6 +43,19 @@
 		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.

Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dialog.h	5 Jul 2002 16:56:53 -0000	1.1
+++ dialog.h	6 Jul 2002 12:57:51 -0000	1.2
@@ -35,9 +35,10 @@
 	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 @@
 	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)
 		{}
 

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- widget.cpp	5 Jul 2002 16:56:53 -0000	1.1
+++ widget.cpp	6 Jul 2002 12:57:51 -0000	1.2
@@ -53,7 +53,7 @@
 	}
 	
 	// Now perform the actual widget draw
-	drawWidget(false);
+	drawWidget(_flags & WIDGET_HILITED);
 	
 	if (_flags & WIDGET_BORDER) {
 		_x -= 4;

Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- widget.h	5 Jul 2002 16:56:53 -0000	1.1
+++ widget.h	6 Jul 2002 12:57:51 -0000	1.2
@@ -29,9 +29,10 @@
 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 @@
 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 @@
 /* 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(); }
 };
 
 





More information about the Scummvm-git-logs mailing list