aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2010-06-15 10:52:52 +0000
committerEugene Sandulenko2010-06-15 10:52:52 +0000
commitd19807e983d001c3bd910275a274eda4ec0ed26d (patch)
treebefd862bfe2ad0228148c36ae3241b37ad37c568
parent01f9006ee7e8d0fd153f42fb00afbc25c4804d2b (diff)
downloadscummvm-rg350-d19807e983d001c3bd910275a274eda4ec0ed26d.tar.gz
scummvm-rg350-d19807e983d001c3bd910275a274eda4ec0ed26d.tar.bz2
scummvm-rg350-d19807e983d001c3bd910275a274eda4ec0ed26d.zip
GUI: Add auto-repeater to scrollbar arrows.
svn-id: r49775
-rw-r--r--gui/ScrollBarWidget.cpp29
-rw-r--r--gui/ScrollBarWidget.h3
2 files changed, 31 insertions, 1 deletions
diff --git a/gui/ScrollBarWidget.cpp b/gui/ScrollBarWidget.cpp
index f6b36b3aa0..f4aaa8ffc9 100644
--- a/gui/ScrollBarWidget.cpp
+++ b/gui/ScrollBarWidget.cpp
@@ -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 @@ ScrollBarWidget::ScrollBarWidget(GuiObject *boss, int x, int y, int w, int h)
_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 @@ void ScrollBarWidget::handleMouseDown(int x, int y, int button, int clickCount)
// 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::handleMouseDown(int x, int y, int button, int clickCount)
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) {
diff --git a/gui/ScrollBarWidget.h b/gui/ScrollBarWidget.h
index 9379736f05..dd2b702686 100644
--- a/gui/ScrollBarWidget.h
+++ b/gui/ScrollBarWidget.h
@@ -73,9 +73,10 @@ public:
// 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