Skip to content

Commit

Permalink
libappfw: Popup menu annotation hiding; button style changes
Browse files Browse the repository at this point in the history
The variable 'Config.ui.showAnnotations', which PopupMenuWidget
now expects to find in the Config, determines the visibility of the
annotation items.
  • Loading branch information
skyjake committed Oct 29, 2014
1 parent 682a599 commit 979ff5e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
4 changes: 3 additions & 1 deletion doomsday/libappfw/include/de/widgets/buttonwidget.h
Expand Up @@ -66,7 +66,9 @@ class LIBAPPFW_PUBLIC ButtonWidget : public LabelWidget
ModulateColor
};

void useInfoStyle();
void useInfoStyle(bool yes = true);

void useNormalStyle() { useInfoStyle(false); }

bool isUsingInfoStyle() const;

Expand Down
19 changes: 14 additions & 5 deletions doomsday/libappfw/src/widgets/buttonwidget.cpp
Expand Up @@ -192,12 +192,21 @@ DENG2_AUDIENCE_METHOD(ButtonWidget, Triggered)
ButtonWidget::ButtonWidget(String const &name) : LabelWidget(name), d(new Instance(this))
{}

void ButtonWidget::useInfoStyle()
void ButtonWidget::useInfoStyle(bool yes)
{
d->infoStyle = true;
setTextColor("inverted.text");
setHoverTextColor("inverted.text", ReplaceColor);
setBackgroundColor("inverted.background");
d->infoStyle = yes;
if(yes)
{
setTextColor("inverted.text");
setHoverTextColor("inverted.text", ReplaceColor);
setBackgroundColor("inverted.background");
}
else
{
setTextColor("text");
setHoverTextColor("text", ReplaceColor);
setBackgroundColor("background");
}
updateStyle();
}

Expand Down
30 changes: 30 additions & 0 deletions doomsday/libappfw/src/widgets/popupmenuwidget.cpp
Expand Up @@ -23,16 +23,20 @@
#include "de/ChildWidgetOrganizer"
#include "de/AtlasProceduralImage"
#include "de/ui/Item"
#include "de/App"

#include <de/IndirectRule>

namespace de {

static String const VAR_SHOW_ANNOTATIONS("ui.showAnnotations");

DENG_GUI_PIMPL(PopupMenuWidget)
, DENG2_OBSERVES(ButtonWidget, StateChange)
, DENG2_OBSERVES(ButtonWidget, Triggered)
, DENG2_OBSERVES(ChildWidgetOrganizer, WidgetCreation)
, DENG2_OBSERVES(ChildWidgetOrganizer, WidgetUpdate)
, DENG2_OBSERVES(Variable, Change)
{
class HeadingOverlayImage : public ProceduralImage
{
Expand Down Expand Up @@ -97,10 +101,12 @@ DENG_GUI_PIMPL(PopupMenuWidget)
, maxItemWidth(0)
{
maxItemWidth = new IndirectRule;
App::config(VAR_SHOW_ANNOTATIONS).audienceForChange() += this;
}

~Instance()
{
App::config(VAR_SHOW_ANNOTATIONS).audienceForChange() -= this;
releaseRef(maxItemWidth);
releaseRef(widestItem);
}
Expand Down Expand Up @@ -161,6 +167,11 @@ DENG_GUI_PIMPL(PopupMenuWidget)
{
if(item.semantics().testFlag(ui::Item::Annotation))
{
if(!App::config().getb(VAR_SHOW_ANNOTATIONS))
{
widget.hide();
}

widget.margins().set("halfunit").setLeft("unit");
widget.setFont("separator.annotation");
}
Expand Down Expand Up @@ -276,6 +287,25 @@ DENG_GUI_PIMPL(PopupMenuWidget)

self.requestGeometry();
}

void variableValueChanged(Variable &, Value const &newValue)
{
bool changed = false;

// Update widgets of annotation items.
self.items().forAll([this, &newValue, &changed] (ui::Item const &item) {
if(item.semantics().testFlag(ui::Item::Annotation)) {
self.menu().itemWidget<GuiWidget>(item).show(newValue.isTrue());
changed = true;
}
return LoopContinue;
});

if(changed)
{
self.menu().updateLayout();
}
}
};

PopupMenuWidget::PopupMenuWidget(String const &name)
Expand Down
4 changes: 4 additions & 0 deletions doomsday/libgui/net.dengine.stdlib.gui.pack/modules/gui.de
Expand Up @@ -29,6 +29,10 @@ def setDefaults(d)
# The default audio and video subsystems.
d.video = 'opengl'
d.audio = 'fmod'

# Generic user interface settings.
record d.ui
d.ui.showAnnotations = True

# Window manager defaults.
record d.window
Expand Down

0 comments on commit 979ff5e

Please sign in to comment.