summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-27 14:18:43 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-27 14:18:43 +0300
commitd247f8b13d2bc69ed1996d247de9ca7643acdb76 (patch)
treed4bc25085effaa686b64b9c930e5b53d8c179a2f
parent79bfdef91b4745517f9a51ea82d203b50776a0b3 (diff)
Fixed disappearing scrollbars
Scrollbar visibility depends on it having a non-zero area.
-rw-r--r--src/ui/listwidget.c9
-rw-r--r--src/ui/scrollwidget.c3
2 files changed, 9 insertions, 3 deletions
diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c
index a43b11ee..f7c43a93 100644
--- a/src/ui/listwidget.c
+++ b/src/ui/listwidget.c
@@ -148,11 +148,16 @@ void updateVisible_ListWidget(iListWidget *d) {
148 const int contentSize = size_PtrArray(&d->items) * d->itemHeight; 148 const int contentSize = size_PtrArray(&d->items) * d->itemHeight;
149 const iRect bounds = innerBounds_Widget(as_Widget(d)); 149 const iRect bounds = innerBounds_Widget(as_Widget(d));
150 const iBool wasVisible = isVisible_Widget(d->scroll); 150 const iBool wasVisible = isVisible_Widget(d->scroll);
151 if (area_Rect(bounds) == 0) { 151 if (width_Rect(bounds) <= 0 || height_Rect(bounds) <= 0) {
152 return; 152 return;
153 } 153 }
154 /* The scroll widget's visibility depends on it having a valid non-zero size.
155 However, this may be called during arrangement (sizeChanged_ListWidget_),
156 which means the child hasn't been arranged yet. The child cannot update
157 its visibility unless it knows its correct size. */
158 arrange_Widget(as_Widget(d->scroll));
154 setMax_SmoothScroll(&d->scrollY, scrollMax_ListWidget_(d)); 159 setMax_SmoothScroll(&d->scrollY, scrollMax_ListWidget_(d));
155 setRange_ScrollWidget(d->scroll, (iRangei){ 0, d->scrollY.max }); 160 setRange_ScrollWidget(d->scroll, (iRangei){ 0, d->scrollY.max });
156 setThumb_ScrollWidget(d->scroll, 161 setThumb_ScrollWidget(d->scroll,
157 pos_SmoothScroll(&d->scrollY), 162 pos_SmoothScroll(&d->scrollY),
158 contentSize > 0 ? height_Rect(bounds_Widget(as_Widget(d->scroll))) * 163 contentSize > 0 ? height_Rect(bounds_Widget(as_Widget(d->scroll))) *
diff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c
index ff5144b2..0bab601a 100644
--- a/src/ui/scrollwidget.c
+++ b/src/ui/scrollwidget.c
@@ -54,7 +54,8 @@ struct Impl_ScrollWidget {
54}; 54};
55 55
56static void updateMetrics_ScrollWidget_(iScrollWidget *d) { 56static void updateMetrics_ScrollWidget_(iScrollWidget *d) {
57 as_Widget(d)->rect.size.x = gap_UI * 3; 57 iWidget *w = as_Widget(d);
58 w->rect.size.x = gap_UI * 3;
58} 59}
59 60
60static void animateOpacity_ScrollWidget_(void *ptr) { 61static void animateOpacity_ScrollWidget_(void *ptr) {