diff --git a/doomsday/client/include/ui/widgets/scrollareawidget.h b/doomsday/client/include/ui/widgets/scrollareawidget.h index 86b98c0eca..b2d2907f7e 100644 --- a/doomsday/client/include/ui/widgets/scrollareawidget.h +++ b/doomsday/client/include/ui/widgets/scrollareawidget.h @@ -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. * diff --git a/doomsday/client/src/ui/widgets/scrollareawidget.cpp b/doomsday/client/src/ui/widgets/scrollareawidget.cpp index 3960c6c2a4..d163fd9b95 100644 --- a/doomsday/client/src/ui/widgets/scrollareawidget.cpp +++ b/doomsday/client/src/ui/widgets/scrollareawidget.cpp @@ -44,6 +44,7 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable Origin origin; bool pageKeysEnabled; + bool scrollingEnabled; Animation scrollOpacity; int scrollBarWidth; Rectanglef indicatorUv; @@ -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"); @@ -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; @@ -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(); if(mouse.wheelMotion() == MouseEvent::FineAngle) @@ -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();