Skip to content

Commit

Permalink
Fixed|Widgets: Scroll indicator unnecessarily visible
Browse files Browse the repository at this point in the history
With a UI scale level other than 100%, the scroll indicator was
sometimes visible in a scroll area. Now the indicator is only visible if
the scroll area can actually be scrolled.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent df25cd7 commit 20e7eb2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions doomsday/libs/gui/src/widgets/scrollareawidget.cpp
Expand Up @@ -125,11 +125,11 @@ DE_GUI_PIMPL(ScrollAreaWidget), public Lockable
indicatorAnimating = true;
if (origin == Bottom && self().isAtBottom())
{
scrollOpacity.setValue(0, .7f, .2f);
scrollOpacity.setValue(0, 700_ms, 200_ms);
}
else
{
scrollOpacity.setValueFrom(.8f, .333f, 5.0, 2.0);
scrollOpacity.setValueFrom(.8f, .333f, 5.0_s, 2.0_s);
}
}

Expand All @@ -147,8 +147,11 @@ DE_GUI_PIMPL(ScrollAreaWidget), public Lockable

RectanglefPair scrollIndicatorRects(Vec2f const &originPos) const
{
Vec2i const viewSize = self().viewportSize();
if (viewSize == Vec2i()) return RectanglefPair();
const Vec2i viewSize = self().viewportSize();
if (viewSize == Vec2i() || self().maximumScrollY().valuei() == 0)
{
return RectanglefPair();
}

const auto &margins = self().margins();
const float contentHeight = float(contentRule.height().value());
Expand All @@ -165,7 +168,7 @@ DE_GUI_PIMPL(ScrollAreaWidget), public Lockable
float indPos = self().scrollPositionY().value() / self().maximumScrollY().value();
if (origin == Top) indPos = 1 - indPos;

float const avail = viewSize.y - indHeight;
const float avail = viewSize.y - indHeight;
Rectanglef rect { originPos + Vec2f(viewSize.x + margins.left().value() - 2 * scrollBarWidth,
avail - indPos * avail),
originPos + Vec2f(viewSize.x + margins.left().value() - scrollBarWidth,
Expand Down Expand Up @@ -507,7 +510,7 @@ bool ScrollAreaWidget::handleEvent(Event const &event)
{
if (event.type() == Event::MousePosition)
{
bool const hovering = (d->scrollBarVisRect.expanded(pointsToPixels(1))
const bool hovering = (d->scrollBarVisRect.expanded(pointsToPixels(1))
.contains(event.as<MouseEvent>().pos()));
d->setScrollBarHovering(hovering);
}
Expand Down

0 comments on commit 20e7eb2

Please sign in to comment.