Skip to content

Commit

Permalink
libappfw|DocumentPopupWidget: Added an optional action button
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 24, 2016
1 parent b83b20f commit 9dfa92b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Expand Up @@ -20,6 +20,7 @@
#define LIBAPPFW_DOCUMENTPOPUPWIDGET_H

#include "../DocumentWidget"
#include "../ButtonWidget"
#include "../PopupWidget"

namespace de {
Expand All @@ -35,10 +36,13 @@ class LIBAPPFW_PUBLIC DocumentPopupWidget : public PopupWidget

public:
DocumentPopupWidget(String const &name = "");
DocumentPopupWidget(ButtonWidget *actionButton, String const &name = "");

DocumentWidget &document();
DocumentWidget const &document() const;

ButtonWidget *button();

private:
DENG2_PRIVATE(d)
};
Expand Down
41 changes: 40 additions & 1 deletion doomsday/sdk/libappfw/src/widgets/documentpopupwidget.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/DocumentPopupWidget"
Expand All @@ -23,6 +23,7 @@ namespace de {
DENG2_PIMPL_NOREF(DocumentPopupWidget)
{
DocumentWidget *doc;
ButtonWidget *button = nullptr;
};

DocumentPopupWidget::DocumentPopupWidget(String const &name)
Expand All @@ -32,6 +33,38 @@ DocumentPopupWidget::DocumentPopupWidget(String const &name)
setContent(d->doc = new DocumentWidget);
}

DocumentPopupWidget::DocumentPopupWidget(ButtonWidget *actionButton, String const &name)
: PopupWidget(name), d(new Instance)
{
DENG2_ASSERT(actionButton);

useInfoStyle();
actionButton->useInfoStyle();

GuiWidget *box = new GuiWidget;
d->doc = new DocumentWidget;
box->add(d->doc);
box->add(actionButton);
actionButton->setSizePolicy(ui::Expand, ui::Expand);

Rule const &gap = style().rules().rule("gap");

box->rule()
.setInput(Rule::Width, d->doc->rule().width())
.setInput(Rule::Height, d->doc->rule().height() +
actionButton->rule().height() +
gap);
d->doc->rule()
.setInput(Rule::Left, box->rule().left())
.setInput(Rule::Right, box->rule().right())
.setInput(Rule::Top, box->rule().top());
actionButton->rule()
.setInput(Rule::Right, box->rule().right() - gap)
.setInput(Rule::Top, d->doc->rule().bottom());

setContent(box);
}

DocumentWidget &DocumentPopupWidget::document()
{
return *d->doc;
Expand All @@ -42,4 +75,10 @@ DocumentWidget const &DocumentPopupWidget::document() const
return *d->doc;
}

ButtonWidget *DocumentPopupWidget::button()
{
return d->button;
}


} // namespace de

0 comments on commit 9dfa92b

Please sign in to comment.