Skip to content

Commit

Permalink
libappfw: Various widget improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 1, 2016
1 parent 805f3ec commit 1a6c3f9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 2 additions & 0 deletions doomsday/sdk/libappfw/include/de/framework/sequentiallayout.h
Expand Up @@ -42,6 +42,8 @@ class LIBAPPFW_PUBLIC SequentialLayout

void clear();

void setStartY(Rule const &startY);

/**
* Sets the direction of the layout. The direction can only be changed
* when the layout is empty.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/sdk/libappfw/include/de/widgets/panelwidget.h
Expand Up @@ -42,6 +42,8 @@ class LIBAPPFW_PUBLIC PanelWidget : public GuiWidget
Q_OBJECT

public:
DENG2_DEFINE_AUDIENCE2(AboutToOpen, void panelAboutToOpen(PanelWidget &))

/**
* Audience to be notified when the panel is closing.
*/
Expand Down
7 changes: 6 additions & 1 deletion doomsday/sdk/libappfw/src/sequentiallayout.cpp
Expand Up @@ -13,7 +13,7 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
* http://www.gnu.org/licenses</small>
*/

#include "de/SequentialLayout"
Expand Down Expand Up @@ -177,6 +177,11 @@ void SequentialLayout::clear()
d->clear();
}

void SequentialLayout::setStartY(Rule const &startY)
{
changeRef(d->initialY, startY);
}

void SequentialLayout::setDirection(ui::Direction direction)
{
DENG2_ASSERT(isEmpty());
Expand Down
14 changes: 7 additions & 7 deletions doomsday/sdk/libappfw/src/widgets/foldpanelwidget.cpp
Expand Up @@ -13,7 +13,7 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
* http://www.gnu.org/licenses</small>
*/

#include "de/FoldPanelWidget"
Expand Down Expand Up @@ -94,14 +94,14 @@ DENG2_PIMPL_NOREF(FoldPanelWidget)
}
};

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

~Instance()
{
stylist.clear(); // References the container.

// We have ownership of the content when the fold is closed.
delete container;
}
Expand All @@ -112,7 +112,7 @@ FoldPanelWidget::FoldPanelWidget(String const &name) : PanelWidget(name), d(new

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

d->title->setSizePolicy(Expand, Expand);
d->title->setText(text);
Expand All @@ -133,7 +133,7 @@ ButtonWidget *FoldPanelWidget::makeTitle(String const &text)

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

Expand Down
7 changes: 7 additions & 0 deletions doomsday/sdk/libappfw/src/widgets/panelwidget.cpp
Expand Up @@ -208,9 +208,11 @@ DENG_GUI_PIMPL(PanelWidget)
}
}

DENG2_PIMPL_AUDIENCE(AboutToOpen)
DENG2_PIMPL_AUDIENCE(Close)
};

DENG2_AUDIENCE_METHOD(PanelWidget, AboutToOpen)
DENG2_AUDIENCE_METHOD(PanelWidget, Close)

PanelWidget::PanelWidget(String const &name) : GuiWidget(name), d(new Instance(this))
Expand Down Expand Up @@ -337,6 +339,11 @@ void PanelWidget::open()
{
if(d->opened) return;

DENG2_FOR_AUDIENCE2(AboutToOpen, i)
{
i->panelAboutToOpen(*this);
}

d->dismissTimer.stop();

unsetBehavior(DisableEventDispatchToChildren);
Expand Down

0 comments on commit 1a6c3f9

Please sign in to comment.