[Scummvm-cvs-logs] scummvm master -> 9dbf05890919bbe248e32a0cfd48b0f42d7f820a

eriktorbjorn eriktorbjorn at telia.com
Mon May 16 23:42:31 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9dbf058909 TSAGE: Fix graphics button behaviour (slightly hackish)


Commit: 9dbf05890919bbe248e32a0cfd48b0f42d7f820a
    https://github.com/scummvm/scummvm/commit/9dbf05890919bbe248e32a0cfd48b0f42d7f820a
Author: eriktorbjorn (eriktorbjorn at users.sourceforge.net)
Date: 2011-05-16T14:37:20-07:00

Commit Message:
TSAGE: Fix graphics button behaviour (slightly hackish)

Don't rely on event.mousePos staying the same throughout the loop.
This makes sure the button stays highlighted for as long as the
mouse button is depressed, unless the mouse is moved off the button.
The calculation of mousePos is slightly hackish. It should probably
use a GfxManager object for that, but this will do for now.

Changed paths:
    engines/tsage/graphics.cpp



diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index 85dfc5d..a212c5d 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -670,12 +670,18 @@ void GfxElement::drawFrame() {
  * @event Event to process
  */
 bool GfxElement::focusedEvent(Event &event) {
+	Common::Point mousePos = event.mousePos;
 	bool highlightFlag = false;
 
-	while (!_vm->getEventManager()->shouldQuit()) {
+	// HACK: It should use the GfxManager object to figure out the relative
+	// position, but for now this seems like the easiest way.
+	int xOffset = mousePos.x - _globals->_events._mousePos.x;
+	int yOffset = mousePos.y - _globals->_events._mousePos.y;
+
+	while (event.eventType != EVENT_BUTTON_UP && !_vm->getEventManager()->shouldQuit()) {
 		g_system->delayMillis(10);
 
-		if (_bounds.contains(event.mousePos)) {
+		if (_bounds.contains(mousePos)) {
 			if (!highlightFlag) {
 				// First highlight call to show the highlight
 				highlightFlag = true;
@@ -687,8 +693,12 @@ bool GfxElement::focusedEvent(Event &event) {
 			highlight();
 		}
 
-		if (_globals->_events.getEvent(event, EVENT_BUTTON_UP))
-			break;
+		if (_globals->_events.getEvent(event, EVENT_MOUSE_MOVE | EVENT_BUTTON_UP)) {
+			if (event.eventType == EVENT_MOUSE_MOVE) {
+				mousePos.x = event.mousePos.x + xOffset;
+				mousePos.y = event.mousePos.y + yOffset;
+			}
+		}
 	}
 
 	if (highlightFlag) {






More information about the Scummvm-git-logs mailing list