Skip to content

Commit

Permalink
Widgets|Debug|libappfw: UI framework improvements
Browse files Browse the repository at this point in the history
Print a warning about incomplete layout rules.
  • Loading branch information
skyjake committed Nov 14, 2018
1 parent 54f8861 commit fe62631
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 22 deletions.
6 changes: 3 additions & 3 deletions doomsday/sdk/libappfw/src/dialogs/directorylistdialog.cpp
Expand Up @@ -47,7 +47,7 @@ DENG2_PIMPL(DirectoryListDialog)
Id groupId;
std::unique_ptr<Group> group(new Group);

self().area().add(group->title = new LabelWidget);
self().area().add(group->title = new LabelWidget("group-title"));
group->title->setText(title);
group->title->setMaximumTextWidth(self().area().rule().width() -
self().margins().width());
Expand All @@ -57,7 +57,7 @@ DENG2_PIMPL(DirectoryListDialog)
group->title->setTextColor("accent");
group->title->margins().setTop("gap");

self().area().add(group->description = new LabelWidget);
self().area().add(group->description = new LabelWidget("group-desc"));
group->description->setText(description);
group->description->setFont("small");
group->description->setTextColor("altaccent");
Expand All @@ -69,7 +69,7 @@ DENG2_PIMPL(DirectoryListDialog)
group->description->margins().setBottom(ConstantRule::zero());

group->array.set(new ArrayValue);
group->list = new DirectoryArrayWidget(group->array);
group->list = new DirectoryArrayWidget(group->array, "group-direc-array");
group->list->margins().setZero();
self().add(group->list->detachAddButton(self().area().rule().width()));
group->list->addButton().hide();
Expand Down
4 changes: 2 additions & 2 deletions doomsday/sdk/libappfw/src/dialogs/messagedialog.cpp
Expand Up @@ -36,8 +36,8 @@ DENG_GUI_PIMPL(MessageDialog)
ScrollAreaWidget &area = self().area();

// Create widgets.
area.add(title = new LabelWidget);
area.add(message = new LabelWidget);
area.add(title = new LabelWidget("title"));
area.add(message = new LabelWidget("message"));

// Configure style.
title->setFont("title");
Expand Down
14 changes: 14 additions & 0 deletions doomsday/sdk/libappfw/src/guiwidget.cpp
Expand Up @@ -1309,6 +1309,20 @@ void GuiWidget::postDrawChildren()

void GuiWidget::collectNotReadyAssets(AssetGroup &collected, Widget &widget)
{
if (widget.behavior().testFlag(Hidden)) return; // Won't be visible right now.

#if defined (DENG2_DEBUG)
if (auto *gw = maybeAs<GuiWidget>(widget))
{
if (!gw->rule().isFullyDefined())
{
qDebug() << gw->path() << "rule rectangle not fully defined";
qDebug("%s", gw->rule().description().toLatin1().constData());
qDebug("Widget layout will be undefined");
}
}
#endif

if (auto *assetGroup = maybeAs<IAssetGroup>(widget))
{
if (!assetGroup->assets().isReady())
Expand Down
11 changes: 5 additions & 6 deletions doomsday/sdk/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -130,7 +130,7 @@ DENG_GUI_PIMPL(DialogWidget)
buttons->setItems(mainButtonItems);
buttons->organizer().audienceForWidgetCreation() += this;
buttons->organizer().audienceForWidgetUpdate() += this;

extraButtons = new MenuWidget("extra");
extraButtons->margins().setTop("");
extraButtons->setItems(extraButtonItems);
Expand Down Expand Up @@ -167,13 +167,13 @@ DENG_GUI_PIMPL(DialogWidget)
// Will a title be included?
if (flags & WithHeading)
{
heading = new LabelWidget;
heading = new LabelWidget("heading");
heading->setFont("heading");
heading->margins()
.setBottom("")
.setTop (rule("gap") + rule("dialog.gap"))
.setLeft(rule("gap") + rule("dialog.gap"));
heading->setSizePolicy(ui::Filled, ui::Expand);
heading->setSizePolicy(ui::Expand, ui::Expand);
heading->setTextColor("accent");
heading->setImageColor(style().colors().colorf("accent"));
heading->setOverrideImageSize(heading->font().ascent().valuei());
Expand All @@ -184,9 +184,8 @@ DENG_GUI_PIMPL(DialogWidget)
container->add(heading);

heading->rule()
.setInput(Rule::Top, self().rule().top())
.setInput(Rule::Left, self().rule().left())
.setInput(Rule::Right, area->rule().right());
.setInput(Rule::Top, self().rule().top())
.setInput(Rule::Left, self().rule().left());

area->rule().setInput(Rule::Top, heading->rule().bottom());
}
Expand Down
7 changes: 5 additions & 2 deletions doomsday/sdk/libappfw/src/widgets/foldpanelwidget.cpp
Expand Up @@ -112,7 +112,7 @@ FoldPanelWidget::FoldPanelWidget(String const &name) : PanelWidget(name), d(new

ButtonWidget *FoldPanelWidget::makeTitle(String const &text)
{
d->title.reset(new ButtonWidget);
d->title.reset(new ButtonWidget("fold-title"));

d->title->setSizePolicy(Expand, Expand);
d->title->setText(text);
Expand Down Expand Up @@ -175,7 +175,10 @@ FoldPanelWidget *FoldPanelWidget::makeOptionsGroup(const String &name, const Str
fold->title().margins().setTop("gap");
// fold->title().set(Background(Vector4f(1, 0, 1, .5f)));
fold->title().setImageAlignment(ui::AlignRight);
// fold->title().rule().setInput(Rule::Width, fold->rule().width());
fold->title().rule()
.setInput(Rule::Left, fold->rule().left())
.setInput(Rule::Bottom, fold->rule().top())
.setInput(Rule::Width, fold->rule().width());
return fold;
}

Expand Down
17 changes: 8 additions & 9 deletions doomsday/sdk/libappfw/src/widgets/panelwidget.cpp
Expand Up @@ -30,9 +30,9 @@

namespace de {

static TimeSpan const OPENING_ANIM_SPAN = 0.4;
static TimeSpan const OPENING_ANIM_SPAN_EASED_OUT = 0.25;
static TimeSpan const CLOSING_ANIM_SPAN = 0.3;
constexpr double OPENING_ANIM_SPAN = 0.3;
constexpr double OPENING_ANIM_SPAN_EASED_OUT = 0.18;
constexpr double CLOSING_ANIM_SPAN = 0.22;

DENG_GUI_PIMPL(PanelWidget)
, DENG2_OBSERVES(Asset, StateChange)
Expand Down Expand Up @@ -79,23 +79,21 @@ DENG_GUI_PIMPL(PanelWidget)

void updateLayout()
{
DENG2_ASSERT(content != 0);

// Widget's size depends on the opening animation.
if (isVerticalAnimation())
{
self().rule().setInput(Rule::Height, *openingRule);
if (secondaryPolicy == ui::Expand)
{
self().rule().setInput(Rule::Width, content->rule().width());
self().rule().setInput(Rule::Width, content ? content->rule().width() : Const(0));
}
}
else
{
self().rule().setInput(Rule::Width, *openingRule);
if (secondaryPolicy == ui::Expand)
{
self().rule().setInput(Rule::Height, content->rule().height());
self().rule().setInput(Rule::Height, content ? content->rule().height() : Const(0));
}
}
}
Expand Down Expand Up @@ -161,7 +159,7 @@ DENG_GUI_PIMPL(PanelWidget)
emit self().closed();

dismissTimer.start();
dismissTimer.setInterval((CLOSING_ANIM_SPAN + delay).asMilliSeconds());
dismissTimer.setInterval(TimeSpan(CLOSING_ANIM_SPAN + delay).asMilliSeconds());
}

void waitForAssetsInContent()
Expand All @@ -176,7 +174,7 @@ DENG_GUI_PIMPL(PanelWidget)
DENG2_ASSERT(content);
GuiWidget::collectNotReadyAssets(*pendingShow, *content);

if (pendingShow->isEmpty())
if (/* DISABLES CODE */ (true) || pendingShow->isEmpty())
{
// Nothing to wait for, actually.
pendingShow.reset();
Expand Down Expand Up @@ -218,6 +216,7 @@ PanelWidget::PanelWidget(String const &name) : GuiWidget(name), d(new Impl(this)
{
setBehavior(ChildHitClipping);
setBehavior(ChildVisibilityClipping);
d->updateLayout(); // initial, empty layout
hide();
}

Expand Down
2 changes: 2 additions & 0 deletions doomsday/sdk/libappfw/src/widgets/variablearraywidget.cpp
Expand Up @@ -209,6 +209,8 @@ VariableArrayWidget::VariableArrayWidget(Variable &variable, String const &name)
add(d->menu);
add(d->deleteButton);
add(d->addButton);

d->menu->updateLayout();
}

Variable &VariableArrayWidget::variable() const
Expand Down

0 comments on commit fe62631

Please sign in to comment.