[Scummvm-cvs-logs] SF.net SVN: scummvm:[49775] scummvm/trunk/gui
sev at users.sourceforge.net
sev at users.sourceforge.net
Tue Jun 15 12:52:53 CEST 2010
Revision: 49775
http://scummvm.svn.sourceforge.net/scummvm/?rev=49775&view=rev
Author: sev
Date: 2010-06-15 10:52:52 +0000 (Tue, 15 Jun 2010)
Log Message:
-----------
GUI: Add auto-repeater to scrollbar arrows.
Modified Paths:
--------------
scummvm/trunk/gui/ScrollBarWidget.cpp
scummvm/trunk/gui/ScrollBarWidget.h
Modified: scummvm/trunk/gui/ScrollBarWidget.cpp
===================================================================
--- scummvm/trunk/gui/ScrollBarWidget.cpp 2010-06-15 10:52:35 UTC (rev 49774)
+++ scummvm/trunk/gui/ScrollBarWidget.cpp 2010-06-15 10:52:52 UTC (rev 49775)
@@ -26,6 +26,8 @@
#include "gui/dialog.h"
#include "gui/GuiManager.h"
+#include "common/timer.h"
+
namespace GUI {
#define UP_DOWN_BOX_HEIGHT (_w+1)
@@ -47,6 +49,28 @@
_currentPos = 0;
}
+static void upArrowRepeater(void *ref) {
+ ScrollBarWidget *sb = (ScrollBarWidget *)ref;
+ int old_pos = sb->_currentPos;
+
+ sb->_currentPos -= 3;
+ sb->checkBounds(old_pos);
+
+ g_system->getTimerManager()->removeTimerProc(&upArrowRepeater);
+ g_system->getTimerManager()->installTimerProc(&upArrowRepeater, 1000000/10, ref);
+}
+
+static void downArrowRepeater(void *ref) {
+ ScrollBarWidget *sb = (ScrollBarWidget *)ref;
+ int old_pos = sb->_currentPos;
+
+ sb->_currentPos += 3;
+ sb->checkBounds(old_pos);
+
+ g_system->getTimerManager()->removeTimerProc(&downArrowRepeater);
+ g_system->getTimerManager()->installTimerProc(&downArrowRepeater, 1000000/10, ref);
+}
+
void ScrollBarWidget::handleMouseDown(int x, int y, int button, int clickCount) {
int old_pos = _currentPos;
@@ -58,10 +82,12 @@
// Up arrow
_currentPos--;
_draggingPart = kUpArrowPart;
+ g_system->getTimerManager()->installTimerProc(&upArrowRepeater, 1000000/2, this);
} else if (y >= _h - UP_DOWN_BOX_HEIGHT) {
// Down arrow
_currentPos++;
_draggingPart = kDownArrowPart;
+ g_system->getTimerManager()->installTimerProc(&downArrowRepeater, 1000000/2, this);
} else if (y < _sliderPos) {
_currentPos -= _entriesPerPage - 1;
} else if (y >= _sliderPos + _sliderHeight) {
@@ -77,6 +103,9 @@
void ScrollBarWidget::handleMouseUp(int x, int y, int button, int clickCount) {
_draggingPart = kNoPart;
+
+ g_system->getTimerManager()->removeTimerProc(&upArrowRepeater);
+ g_system->getTimerManager()->removeTimerProc(&downArrowRepeater);
}
void ScrollBarWidget::handleMouseWheel(int x, int y, int direction) {
Modified: scummvm/trunk/gui/ScrollBarWidget.h
===================================================================
--- scummvm/trunk/gui/ScrollBarWidget.h 2010-06-15 10:52:35 UTC (rev 49774)
+++ scummvm/trunk/gui/ScrollBarWidget.h 2010-06-15 10:52:52 UTC (rev 49775)
@@ -73,9 +73,10 @@
// should these accessors force a redraw?
void recalc();
+ void checkBounds(int old_pos);
+
protected:
void drawWidget();
- void checkBounds(int old_pos);
};
} // End of namespace GUI
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