Skip to content

Commit

Permalink
UI|Client|Default Style: Color for scroll bar indicator
Browse files Browse the repository at this point in the history
ScrollAreaWidget now allows specifying a color to be used for the
scroll indicator.

CommandWidget now uses an "inverted" color in the completions popup
document's indicator to make it more visible.

IssueID #1588
  • Loading branch information
skyjake committed Oct 23, 2013
1 parent 8858cec commit 7f566e3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions doomsday/client/data/defaultstyle.pack/colors.dei
Expand Up @@ -16,6 +16,7 @@ color textaccent { rgb $= gui.colorMix(text.rgb, accent.rgb, 0.6) }
group inverted {
color text { rgb <0.0, 0.0, 0.0> }
color background { rgb <1.0, 1.0, 1.0, 0.75> }
color accent { rgb <0.5, 0.4, 0.2> }
color glow { rgb <0.0, 0.0, 0.0, 0.15> }
}

Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/include/ui/widgets/scrollareawidget.h
Expand Up @@ -48,6 +48,8 @@ class ScrollAreaWidget : public GuiWidget
public:
ScrollAreaWidget(de::String const &name = "");

void setScrollBarColor(de::DotPath const &colorId);

void setOrigin(Origin origin);
Origin origin() const;

Expand Down
1 change: 1 addition & 0 deletions doomsday/client/src/ui/widgets/commandwidget.cpp
Expand Up @@ -39,6 +39,7 @@ DENG_GUI_PIMPL(CommandWidget)
// Popup for autocompletions.
completions = new DocumentWidget;
completions->setMaximumLineWidth(640);
completions->setScrollBarColor("inverted.accent");

popup = new PopupWidget;
popup->useInfoStyle();
Expand Down
14 changes: 11 additions & 3 deletions doomsday/client/src/ui/widgets/scrollareawidget.cpp
Expand Up @@ -48,7 +48,8 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable
int scrollBarWidth;
Rectanglef indicatorUv;
bool indicatorAnimating;
ColorBank::Colorf accent;
String scrollBarColorId;
ColorBank::Colorf scrollBarColor;

// GL objects.
bool indicatorShown;
Expand All @@ -63,6 +64,7 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable
scrollOpacity(0),
scrollBarWidth(0),
indicatorAnimating(false),
scrollBarColorId("accent"),
indicatorShown(false),
uMvpMatrix("uMvpMatrix", GLUniform::Mat4),
uColor ("uColor", GLUniform::Vec4)
Expand Down Expand Up @@ -111,7 +113,7 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable
Style const &st = style();

scrollBarWidth = st.rules().rule("scrollarea.bar").valuei();
accent = st.colors().colorf("accent");
scrollBarColor = st.colors().colorf(scrollBarColorId);
}

void restartScrollOpacityFade()
Expand Down Expand Up @@ -142,6 +144,12 @@ ScrollAreaWidget::ScrollAreaWidget(String const &name)
setContentHeight(0);
}

void ScrollAreaWidget::setScrollBarColor(DotPath const &colorId)
{
d->scrollBarColorId = colorId;
d->updateStyle();
}

void ScrollAreaWidget::setOrigin(Origin origin)
{
DENG2_GUARD(d);
Expand Down Expand Up @@ -483,7 +491,7 @@ void ScrollAreaWidget::glMakeScrollIndicatorGeometry(DefaultVertexBuf::Builder &
avail - indPos * avail + indHeight),
origin + Vector2f(viewSize.x + margins().left().value() - d->scrollBarWidth,
avail - indPos * avail)),
Vector4f(1, 1, 1, d->scrollOpacity) * d->accent,
Vector4f(1, 1, 1, d->scrollOpacity) * d->scrollBarColor,
d->indicatorUv);
}

Expand Down

0 comments on commit 7f566e3

Please sign in to comment.