Skip to content

Commit

Permalink
libappfw: Widget improvements
Browse files Browse the repository at this point in the history
MenuWidget’s layout can be modified by outsiders (non-const accessor).
Ensure only the main thread creates widgets in ChildWidgetOrganizer.
PopupWidget doesn’t extend beyond the top of the view when opening.
ScrollAreaWidget’s child clipping can be disabled.
  • Loading branch information
skyjake committed Jan 28, 2014
1 parent 52d20df commit c24775a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doomsday/libappfw/include/de/widgets/menuwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class LIBAPPFW_PUBLIC MenuWidget : public ScrollAreaWidget
*/
GridLayout const &layout() const;

GridLayout &layout();

// Events.
void update();
bool handleEvent(Event const &event);
Expand Down
2 changes: 2 additions & 0 deletions doomsday/libappfw/src/childwidgetorganizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "de/LabelWidget"
#include "de/ui/Item"

#include <de/App>
#include <QMap>

namespace de {
Expand Down Expand Up @@ -84,6 +85,7 @@ DENG2_OBSERVES(ui::Item, Change )

void addItemWidget(ui::Data::Pos pos, bool alwaysAppend = false)
{
DENG2_ASSERT_IN_MAIN_THREAD(); // widgets should only be manipulated in UI thread
DENG2_ASSERT(factory != 0);

if(filter)
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libappfw/src/widgets/menuwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ GridLayout const &MenuWidget::layout() const
return d->layout;
}

GridLayout &MenuWidget::layout()
{
return d->layout;
}

ChildWidgetOrganizer &MenuWidget::organizer()
{
return d->organizer;
Expand Down
3 changes: 2 additions & 1 deletion doomsday/libappfw/src/widgets/popupwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ DENG_GUI_PIMPL(PopupWidget)
{
case ui::Up:
self.rule()
.setInput(Rule::Bottom, *anchorY - *marker)
.setInput(Rule::Bottom, OperatorRule::maximum(
*anchorY - *marker, self.rule().height()))
.setInput(Rule::Left, OperatorRule::clamped(
*anchorX - self.rule().width() / 2,
self.margins().left(),
Expand Down
10 changes: 8 additions & 2 deletions doomsday/libappfw/src/widgets/scrollareawidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,18 @@ void ScrollAreaWidget::drawContent()

void ScrollAreaWidget::preDrawChildren()
{
GLState::push().setNormalizedScissor(normalizedRect());
if(behavior().testFlag(ChildVisibilityClipping))
{
GLState::push().setNormalizedScissor(normalizedRect());
}
}

void ScrollAreaWidget::postDrawChildren()
{
GLState::pop();
if(behavior().testFlag(ChildVisibilityClipping))
{
GLState::pop();
}
}

} // namespace de

0 comments on commit c24775a

Please sign in to comment.