[Scummvm-cvs-logs] CVS: scummvm newgui.cpp,1.28,1.29 newgui.h,1.21,1.22
Max Horn
fingolfin at users.sourceforge.net
Sat Jul 27 07:17:03 CEST 2002
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.12,1.13 ListWidget.h,1.9,1.10 ScrollBarWidget.cpp,1.6,1.7 ScrollBarWidget.h,1.4,1.5 dialog.cpp,1.30,1.31 dialog.h,1.17,1.18 widget.cpp,1.25,1.26 widget.h,1.23,1.24
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv29419
Modified Files:
newgui.cpp newgui.h
Log Message:
heaps of changes to NewGUI: mouseDown/Up events now count the clicks (so you can detect double/triple clicks); ListWidget sends a message if an item was double clicked or changed; you can abort editing in the ListWidget by pressing ESC; SaveLoadDialog will save when you double click and item, and when you finish editing an item by pressing return, will save
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/newgui.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- newgui.cpp 27 Jul 2002 00:36:09 -0000 1.28
+++ newgui.cpp 27 Jul 2002 14:16:14 -0000 1.29
@@ -36,6 +36,8 @@
* - ...
*/
+#define ABS(x) ((x) < 0 ? -(x) : (x))
+
NewGui::NewGui(Scumm *s) : _s(s), _use_alpha_blending(true),
_need_redraw(false),_prepare_for_gui(true),
_pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0),
@@ -102,6 +104,10 @@
_eventList.clear();
_currentKeyDown = 0;
+
+ _lastClick.x = _lastClick.y = 0;
+ _lastClick.time = 0;
+ _lastClick.count = 0;
_prepare_for_gui = false;
}
@@ -130,8 +136,8 @@
// init continuous event stream
_currentKeyDown = t.kbd.ascii;
_currentKeyDownFlags = t.kbd.flags;
- _eventFiredCount = 1;
- _loopCount = 0;
+ _keyRepeatEvenCount = 1;
+ _keyRepeatLoopCount = 0;
break;
case OSystem::EVENT_KEYUP:
activeDialog->handleKeyUp(t.kbd.ascii, t.kbd.flags);
@@ -144,12 +150,24 @@
break;
// We don't distinguish between mousebuttons (for now at least)
case OSystem::EVENT_LBUTTONDOWN:
- case OSystem::EVENT_RBUTTONDOWN:
- activeDialog->handleMouseDown(t.mouse.x - activeDialog->_x, t.mouse.y - activeDialog->_y, 1);
+ case OSystem::EVENT_RBUTTONDOWN: {
+ uint32 time = _s->_system->get_msecs();
+ if (_lastClick.count && (time < _lastClick.time + 1000)
+ && ABS(_lastClick.x - t.mouse.x) < 3
+ && ABS(_lastClick.y - t.mouse.y) < 3) {
+ _lastClick.count++;
+ } else {
+ _lastClick.x = t.mouse.x;
+ _lastClick.y = t.mouse.y;
+ _lastClick.count = 1;
+ }
+ _lastClick.time = time;
+ }
+ activeDialog->handleMouseDown(t.mouse.x - activeDialog->_x, t.mouse.y - activeDialog->_y, 1, _lastClick.count);
break;
case OSystem::EVENT_LBUTTONUP:
case OSystem::EVENT_RBUTTONUP:
- activeDialog->handleMouseUp(t.mouse.x - activeDialog->_x, t.mouse.y - activeDialog->_y, 1);
+ activeDialog->handleMouseUp(t.mouse.x - activeDialog->_x, t.mouse.y - activeDialog->_y, 1, _lastClick.count);
break;
}
}
@@ -161,16 +179,16 @@
if (_currentKeyDown != 0)
{
// if only fired once, wait longer
- if ( _loopCount >= ((_eventFiredCount > 1) ? 2 : 4) )
- // ^ loops to wait first event
- // ^ loops to wait after first event
+ if ( _keyRepeatLoopCount >= ((_keyRepeatEvenCount > 1) ? 2 : 4) )
+ // ^ loops to wait first event
+ // ^ loops to wait after first event
{
// fire event
activeDialog->handleKeyDown(_currentKeyDown, _currentKeyDownFlags);
- _eventFiredCount++;
- _loopCount = 0;
+ _keyRepeatEvenCount++;
+ _keyRepeatLoopCount = 0;
}
- _loopCount++;
+ _keyRepeatLoopCount++;
}
_s->drawDirtyScreenParts();
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/newgui.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- newgui.h 27 Jul 2002 00:36:09 -0000 1.21
+++ newgui.h 27 Jul 2002 14:16:14 -0000 1.22
@@ -94,8 +94,8 @@
// for continuous events (keyDown)
int _currentKeyDown, _currentKeyDownFlags;
- int _loopCount;
- int _eventFiredCount;
+ int _keyRepeatLoopCount;
+ int _keyRepeatEvenCount;
// sound state
bool _old_soundsPaused;
@@ -105,10 +105,12 @@
int _old_cursorHotspotX, _old_cursorHotspotY, _old_cursorWidth, _old_cursorHeight;
byte _old_grabbedCursor[2048];
- // mouse pos
+ // position and time of last mouse click (used to detect double clicks)
struct {
- int16 x,y;
- } _old_mouse;
+ int16 x, y; // Position of mouse when the click occured
+ uint32 time; // Time
+ int count; // How often was it already pressed?
+ } _lastClick;
// List of events to be handled
EventList _eventList;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.12,1.13 ListWidget.h,1.9,1.10 ScrollBarWidget.cpp,1.6,1.7 ScrollBarWidget.h,1.4,1.5 dialog.cpp,1.30,1.31 dialog.h,1.17,1.18 widget.cpp,1.25,1.26 widget.h,1.23,1.24
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list