From d247f8b13d2bc69ed1996d247de9ca7643acdb76 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 27 May 2021 14:18:43 +0300 Subject: Fixed disappearing scrollbars Scrollbar visibility depends on it having a non-zero area. --- src/ui/listwidget.c | 9 +++++++-- src/ui/scrollwidget.c | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/ui') 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) { const int contentSize = size_PtrArray(&d->items) * d->itemHeight; const iRect bounds = innerBounds_Widget(as_Widget(d)); const iBool wasVisible = isVisible_Widget(d->scroll); - if (area_Rect(bounds) == 0) { + if (width_Rect(bounds) <= 0 || height_Rect(bounds) <= 0) { return; } + /* The scroll widget's visibility depends on it having a valid non-zero size. + However, this may be called during arrangement (sizeChanged_ListWidget_), + which means the child hasn't been arranged yet. The child cannot update + its visibility unless it knows its correct size. */ + arrange_Widget(as_Widget(d->scroll)); setMax_SmoothScroll(&d->scrollY, scrollMax_ListWidget_(d)); - setRange_ScrollWidget(d->scroll, (iRangei){ 0, d->scrollY.max }); + setRange_ScrollWidget(d->scroll, (iRangei){ 0, d->scrollY.max }); setThumb_ScrollWidget(d->scroll, pos_SmoothScroll(&d->scrollY), 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 { }; static void updateMetrics_ScrollWidget_(iScrollWidget *d) { - as_Widget(d)->rect.size.x = gap_UI * 3; + iWidget *w = as_Widget(d); + w->rect.size.x = gap_UI * 3; } static void animateOpacity_ScrollWidget_(void *ptr) { -- cgit v1.2.3