ScrollView: Add a subtle drop shadow to the top.

This commit is contained in:
Henrik Rydgård committed 2025-08-28 23:21:32 +02:00
1 parent 6b5d4fdd86
commit 3268d2afd0
1 file changed
+17
+17
View File
@@ -239,6 +239,23 @@ void ScrollView::Draw(UIContext &dc) {
// For debugging layout issues, this can be useful.
// dc.FillRect(Drawable(0x60FF00FF), bounds_);
views_[0]->Draw(dc);
// If not anchored at the top of the screen exactly, and not scrolled to the top,
// draw a subtle drop shadow to indicate scrollability.
if (bounds_.y > 0.0f && orientation_ == ORIENT_VERTICAL) {
float radius = 20.0f;
Bounds shadowBounds = bounds_;
shadowBounds.x -= radius;
shadowBounds.w += radius * 2;
shadowBounds.y -= radius * 2;
shadowBounds.h = radius * 2;
float fade = std::clamp(scrollPos_ * 0.1f, 0.0f, 0.6f);
dc.DrawRectDropShadow(shadowBounds, radius, fade);
}
dc.PopScissor();
// Vertical scroll bob. We don't support a horizontal yet.