summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-02-14 20:33:27 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-02-14 20:54:03 +0100
commit9c48d5f4d73e9810339c4959bea245020b4255c3 (patch)
tree867c2e18e6b88a5cda986a4c27b2f0e994f62d36 /src
parent79aee9aa7cd48dee1660e3b1bf50142ceda7ae34 (diff)
downloadmana-client-9c48d5f4d73e9810339c4959bea245020b4255c3.tar.gz
mana-client-9c48d5f4d73e9810339c4959bea245020b4255c3.tar.bz2
mana-client-9c48d5f4d73e9810339c4959bea245020b4255c3.tar.xz
mana-client-9c48d5f4d73e9810339c4959bea245020b4255c3.zip
Made the ScrollArea scrolling with buttons smoother
Update more frequently (every tick) and by a smaller amount.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/scrollarea.cpp54
-rw-r--r--src/gui/widgets/scrollarea.h2
2 files changed, 23 insertions, 33 deletions
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 6754b00c..8c88c2dc 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -24,7 +24,6 @@
#include "configuration.h"
#include "graphics.h"
-#include "gui/gui.h"
#include "gui/skin.h"
#include "resources/image.h"
@@ -89,6 +88,11 @@ void ScrollArea::init()
// Draw background by default
setOpaque(true);
+ setUpButtonScrollAmount(2);
+ setDownButtonScrollAmount(2);
+ setLeftButtonScrollAmount(2);
+ setRightButtonScrollAmount(2);
+
if (instances == 0)
{
// Load the background skin
@@ -160,18 +164,13 @@ 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();
@@ -192,32 +191,25 @@ void ScrollArea::logic()
}
}
- const int updateTicks = get_elapsed_time(mLastUpdate) / 100;
-
- if (updateTicks > 0)
+ if (mUpButtonPressed)
{
- 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;
+ setVerticalScrollAmount(getVerticalScrollAmount() -
+ mUpButtonScrollAmount);
+ }
+ else if (mDownButtonPressed)
+ {
+ setVerticalScrollAmount(getVerticalScrollAmount() +
+ mDownButtonScrollAmount);
+ }
+ else if (mLeftButtonPressed)
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount() -
+ mLeftButtonScrollAmount);
+ }
+ else if (mRightButtonPressed)
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount() +
+ mRightButtonScrollAmount);
}
}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index aa7b71a0..42e0923e 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -139,8 +139,6 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
int mX,mY;
bool mHasMouse;
bool mOpaque;
-
- int mLastUpdate;
};
#endif