Skip to content

Commit

Permalink
Client|ScrollAreaWidget: Scroll area clips children
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 20, 2013
1 parent 2d2d143 commit 8fe9d06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doomsday/client/include/ui/widgets/scrollareawidget.h
Expand Up @@ -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);

Expand Down Expand Up @@ -114,6 +114,8 @@ class ScrollAreaWidget : public GuiWidget

// Events.
void update();
void preDrawChildren();
void postDrawChildren();
bool handleEvent(de::Event const &event);

public slots:
Expand Down
15 changes: 15 additions & 0 deletions doomsday/client/src/ui/widgets/scrollareawidget.cpp
Expand Up @@ -21,6 +21,7 @@

#include "ui/widgets/scrollareawidget.h"

#include <de/GLState>
#include <de/KeyEvent>
#include <de/MouseEvent>
#include <de/Lockable>
Expand Down Expand Up @@ -59,6 +60,8 @@ DENG2_PIMPL(ScrollAreaWidget), public Lockable
margin(0),
vertMargin(0)
{
contentRule.setDebugName("ScrollArea-contentRule");

updateStyle();

x = new ScalarRule(0);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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();
}

0 comments on commit 8fe9d06

Please sign in to comment.