diff options
author | Tametomo <irarice@gmail.com> | 2009-05-20 12:47:39 -0600 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-14 20:54:03 +0100 |
commit | 79aee9aa7cd48dee1660e3b1bf50142ceda7ae34 (patch) | |
tree | 16365f61183d3f37dd19ce144c0aea2f543b0f6d /src | |
parent | c686e575c0715eb8738cb9d3a619549df4695e87 (diff) | |
download | mana-client-79aee9aa7cd48dee1660e3b1bf50142ceda7ae34.tar.gz mana-client-79aee9aa7cd48dee1660e3b1bf50142ceda7ae34.tar.bz2 mana-client-79aee9aa7cd48dee1660e3b1bf50142ceda7ae34.tar.xz mana-client-79aee9aa7cd48dee1660e3b1bf50142ceda7ae34.zip |
Fixed ScrollAreas to allow for continual scrolling, as long as the mouse
button is pressed, instead of just moving one tick for each press.
Signed-off-by: Tametomo <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 38 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.h | 2 |
2 files changed, 38 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) diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 42e0923e..aa7b71a0 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -139,6 +139,8 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener int mX,mY; bool mHasMouse; bool mOpaque; + + int mLastUpdate; }; #endif |