From 8fe9d06bcd20a790aeb5bad69536677b2af60760 Mon Sep 17 00:00:00 2001 From: skyjake Date: Thu, 20 Jun 2013 10:03:38 +0300 Subject: [PATCH] Client|ScrollAreaWidget: Scroll area clips children --- .../client/include/ui/widgets/scrollareawidget.h | 4 +++- .../client/src/ui/widgets/scrollareawidget.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doomsday/client/include/ui/widgets/scrollareawidget.h b/doomsday/client/include/ui/widgets/scrollareawidget.h index 600a456473..799c4a9863 100644 --- a/doomsday/client/include/ui/widgets/scrollareawidget.h +++ b/doomsday/client/include/ui/widgets/scrollareawidget.h @@ -44,8 +44,8 @@ class ScrollAreaWidget : public GuiWidget void setIndicatorUv(de::Vector2f const &uvPoint); void setContentWidth(int width); - void setContentHeight(int height); void setContentWidth(de::Rule const &width); + void setContentHeight(int height); void setContentHeight(de::Rule const &height); void setContentSize(de::Vector2i const &size); @@ -114,6 +114,8 @@ class ScrollAreaWidget : public GuiWidget // Events. void update(); + void preDrawChildren(); + void postDrawChildren(); bool handleEvent(de::Event const &event); public slots: diff --git a/doomsday/client/src/ui/widgets/scrollareawidget.cpp b/doomsday/client/src/ui/widgets/scrollareawidget.cpp index ced12ed611..deaee26819 100644 --- a/doomsday/client/src/ui/widgets/scrollareawidget.cpp +++ b/doomsday/client/src/ui/widgets/scrollareawidget.cpp @@ -21,6 +21,7 @@ #include "ui/widgets/scrollareawidget.h" +#include #include #include #include @@ -59,6 +60,8 @@ DENG2_PIMPL(ScrollAreaWidget), public Lockable margin(0), vertMargin(0) { + contentRule.setDebugName("ScrollArea-contentRule"); + updateStyle(); x = new ScalarRule(0); @@ -105,6 +108,8 @@ DENG2_PIMPL(ScrollAreaWidget), public Lockable ScrollAreaWidget::ScrollAreaWidget(String const &name) : GuiWidget(name), d(new Instance(this)) { + setBehavior(ChildHitClipping); + // Link the content rule into the widget's rectangle. d->contentRule.setInput(Rule::Left, rule().left() + *d->margin - OperatorRule::minimum(*d->x, *d->maxX)); @@ -448,3 +453,13 @@ void ScrollAreaWidget::update() d->y->set(d->maxY->value()); } } + +void ScrollAreaWidget::preDrawChildren() +{ + GLState::push().setNormalizedScissor(normalizedRect()); +} + +void ScrollAreaWidget::postDrawChildren() +{ + GLState::pop(); +}