Navigation Menu

Skip to content

Commit

Permalink
UI|Client|ScrollAreaWidget: Scrolling can be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 2, 2014
1 parent 6e47a56 commit da4658a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
7 changes: 7 additions & 0 deletions doomsday/client/include/ui/widgets/scrollareawidget.h
Expand Up @@ -112,6 +112,13 @@ class ScrollAreaWidget : public GuiWidget
*/
bool isAtBottom() const;

/**
* Enables or disables scrolling. By default, scrolling is enabled.
*
* @param enabled @c true to enable scrolling.
*/
void enableScrolling(bool enabled);

/**
* Enables or disables scrolling with Page Up/Down keys.
*
Expand Down
31 changes: 19 additions & 12 deletions doomsday/client/src/ui/widgets/scrollareawidget.cpp
Expand Up @@ -44,6 +44,7 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable

Origin origin;
bool pageKeysEnabled;
bool scrollingEnabled;
Animation scrollOpacity;
int scrollBarWidth;
Rectanglef indicatorUv;
Expand All @@ -58,16 +59,17 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable
GLUniform uColor;

Instance(Public *i)
: Base(i),
origin(Top),
pageKeysEnabled(true),
scrollOpacity(0),
scrollBarWidth(0),
indicatorAnimating(false),
scrollBarColorId("accent"),
indicatorShown(false),
uMvpMatrix("uMvpMatrix", GLUniform::Mat4),
uColor ("uColor", GLUniform::Vec4)
: Base(i)
, origin(Top)
, pageKeysEnabled(true)
, scrollingEnabled(true)
, scrollOpacity(0)
, scrollBarWidth(0)
, indicatorAnimating(false)
, scrollBarColorId("accent")
, indicatorShown(false)
, uMvpMatrix("uMvpMatrix", GLUniform::Mat4)
, uColor ("uColor", GLUniform::Vec4)
{
contentRule.setDebugName("ScrollArea-contentRule");

Expand Down Expand Up @@ -356,6 +358,11 @@ bool ScrollAreaWidget::isAtBottom() const
return d->origin == Bottom && d->y->animation().target() == 0;
}

void ScrollAreaWidget::enableScrolling(bool enabled)
{
d->scrollingEnabled = enabled;
}

void ScrollAreaWidget::enablePageKeys(bool enabled)
{
d->pageKeysEnabled = enabled;
Expand All @@ -369,7 +376,7 @@ void ScrollAreaWidget::enableIndicatorDraw(bool enabled)
bool ScrollAreaWidget::handleEvent(Event const &event)
{
// Mouse wheel scrolling.
if(event.type() == Event::MouseWheel && hitTest(event))
if(d->scrollingEnabled && event.type() == Event::MouseWheel && hitTest(event))
{
MouseEvent const &mouse = event.as<MouseEvent>();
if(mouse.wheelMotion() == MouseEvent::FineAngle)
Expand All @@ -383,7 +390,7 @@ bool ScrollAreaWidget::handleEvent(Event const &event)
}

// Page key scrolling.
if(event.isKeyDown())
if(d->scrollingEnabled && event.isKeyDown())
{
KeyEvent const &ev = event.as<KeyEvent>();

Expand Down

0 comments on commit da4658a

Please sign in to comment.