Skip to content

Commit

Permalink
Widgets|libappfw: Widgets can optionally hide the focus rectangle
Browse files Browse the repository at this point in the history
If the widget shows its own focus indicator, showing the focus widget
is redundant.
  • Loading branch information
skyjake committed Feb 21, 2016
1 parent b291aa9 commit 5d336d3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
23 changes: 15 additions & 8 deletions doomsday/sdk/libappfw/include/de/framework/guiwidget.h
Expand Up @@ -170,31 +170,38 @@ class LIBAPPFW_PUBLIC GuiWidget : public QObject, public Widget
enum Attribute
{
/**
* Enables or disables automatic state serialization for widgets derived from
* IPersistent. State serialization occurs when the widget is gl(De)Init'd.
* Enables or disables automatic state serialization for widgets
* derived from IPersistent. State serialization occurs when the widget
* is gl(De)Init'd.
*/
RetainStatePersistently = 0x1,

AnimateOpacityWhenEnabledOrDisabled = 0x2,

/**
* Widget will not automatically change opacity depending on state (e.g., when
* disabled).
* Widget will not automatically change opacity depending on state
* (e.g., when disabled).
*/
ManualOpacity = 0x10,

/**
* Prevents the drawing of the widget contents even if it visible. The texture
* containing the blurred background is updated regardless.
* Prevents the drawing of the widget contents even if it visible. The
* texture containing the blurred background is updated regardless.
*/
DontDrawContent = 0x4,

/**
* Visible opacity determined solely by the widget itself, not affected by
* ancestors.
* Visible opacity determined solely by the widget itself, not affected
* by ancestors.
*/
IndependentOpacity = 0x8,

/**
* When focused, don't show the normal focus indicator. The assumption
* is that the widget will indicate focused state on its own.
*/
FocusHidden = 0x20,

DefaultAttributes = RetainStatePersistently | AnimateOpacityWhenEnabledOrDisabled
};
Q_DECLARE_FLAGS(Attributes, Attribute)
Expand Down
4 changes: 4 additions & 0 deletions doomsday/sdk/libappfw/src/guirootwidget.cpp
Expand Up @@ -185,6 +185,10 @@ DENG2_PIMPL(GuiRootWidget)
{
focusIndicator->rule().setRect(w->rule());
focusIndicator->startFlashing();
if(w->attributes().testFlag(GuiWidget::FocusHidden))
{
focusIndicator->hide();
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libappfw/src/widgets/focuswidget.cpp
Expand Up @@ -63,10 +63,10 @@ FocusWidget::FocusWidget(String const &name)

void FocusWidget::startFlashing()
{
show();
if(!d->flashing.isActive())
{
setOpacity(0);
show();
d->flashing.start();
}
}
Expand Down
1 change: 1 addition & 0 deletions doomsday/sdk/libappfw/src/widgets/lineeditwidget.cpp
Expand Up @@ -236,6 +236,7 @@ LineEditWidget::LineEditWidget(String const &name)
d(new Instance(this))
{
setBehavior(ContentClipping | Focusable);
setAttribute(FocusHidden);

// The widget's height is tied to the number of lines.
rule().setInput(Rule::Height, *d->height);
Expand Down

0 comments on commit 5d336d3

Please sign in to comment.