Skip to content

Commit

Permalink
libappfw|FoldPanelWidget: Fold title must be manually created
Browse files Browse the repository at this point in the history
Previously the title button would be created but never deleted, if
it was unused.
  • Loading branch information
skyjake committed Feb 2, 2014
1 parent 8b30915 commit 47c69e2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Expand Up @@ -99,6 +99,7 @@ DENG2_OBSERVES(App, GameChange)
{
_group = new GuiWidget;
setContent(_group);
makeTitle(titleText);
title().setText(titleText);
title().setTextColor("accent");

Expand Down
10 changes: 10 additions & 0 deletions doomsday/libappfw/include/de/widgets/foldpanelwidget.h
Expand Up @@ -44,6 +44,16 @@ class LIBAPPFW_PUBLIC FoldPanelWidget : public PanelWidget
public:
FoldPanelWidget(String const &name = "");

/**
* Creates a title button widget for toggling the fold open and closed.
* The method does not add the title as a child to anything.
*
* @param text Text.
*
* @return Button widget instance. Caller gets ownership.
*/
ButtonWidget *makeTitle(String const &text = "");

ButtonWidget &title();

void setContent(GuiWidget *content);
Expand Down
10 changes: 9 additions & 1 deletion doomsday/libappfw/src/widgets/foldpanelwidget.cpp
Expand Up @@ -61,16 +61,21 @@ DENG2_PIMPL_NOREF(FoldPanelWidget)
}
};*/

ButtonWidget *title;
ButtonWidget *title; // not owned
GuiWidget *container; ///< Held here while not part of the widget tree.
DialogContentStylist stylist;

Instance() : title(0), container(0) {}
};

FoldPanelWidget::FoldPanelWidget(String const &name) : PanelWidget(name), d(new Instance)
{}

ButtonWidget *FoldPanelWidget::makeTitle(String const &text)
{
d->title = new ButtonWidget;

d->title->setText(text);
d->title->setSizePolicy(Expand, Expand);
d->title->set(Background()); // no frame or background
d->title->setHoverTextColor("text");
Expand All @@ -81,10 +86,13 @@ FoldPanelWidget::FoldPanelWidget(String const &name) : PanelWidget(name), d(new
// Icon is disabled for now, doesn't look quite right.
//d->title->setImage(new Instance::FoldImage(*this));
//d->title->setTextAlignment(ui::AlignRight); // Text is on the right from the image.

return d->title;
}

ButtonWidget &FoldPanelWidget::title()
{
DENG2_ASSERT(d->title != 0);
return *d->title;
}

Expand Down

0 comments on commit 47c69e2

Please sign in to comment.