summaryrefslogtreecommitdiff
path: root/src/gui/widgets/scrollarea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/scrollarea.cpp')
-rw-r--r--src/gui/widgets/scrollarea.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 71f1a1a8..6754b00c 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -24,6 +24,7 @@
#include "configuration.h"
#include "graphics.h"
+#include "gui/gui.h"
#include "gui/skin.h"
#include "resources/image.h"
@@ -159,13 +160,18 @@ void ScrollArea::init()
resman->getImage("graphics/gui/hscroll_right_pressed.png");
}
+ mLastUpdate = tick_time;
+
instances++;
}
void ScrollArea::logic()
{
if (!isVisible())
+ {
+ mLastUpdate = tick_time;
return;
+ }
gcn::ScrollArea::logic();
gcn::Widget *content = getContent();
@@ -185,6 +191,34 @@ void ScrollArea::logic()
2 * content->getFrameSize());
}
}
+
+ const int updateTicks = get_elapsed_time(mLastUpdate) / 100;
+
+ if (updateTicks > 0)
+ {
+ if (mUpButtonPressed)
+ {
+ setVerticalScrollAmount(getVerticalScrollAmount() -
+ mUpButtonScrollAmount);
+ }
+ else if (mDownButtonPressed)
+ {
+ setVerticalScrollAmount(getVerticalScrollAmount() +
+ mDownButtonScrollAmount);
+ }
+ else if (mLeftButtonPressed)
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount() -
+ mLeftButtonScrollAmount);
+ }
+ else if (mRightButtonPressed)
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount() +
+ mRightButtonScrollAmount);
+ }
+
+ mLastUpdate = tick_time;
+ }
}
void ScrollArea::updateAlpha()
@@ -346,8 +380,8 @@ void ScrollArea::drawHMarker(gcn::Graphics *graphics)
void ScrollArea::mouseMoved(gcn::MouseEvent& event)
{
-mX = event.getX();
-mY = event.getY();
+ mX = event.getX();
+ mY = event.getY();
}
void ScrollArea::mouseEntered(gcn::MouseEvent& event)