Skip to content

Commit a436f41

Browse files
committed
feat(gui): set the container padding when the ScrollBar is visible
1 parent eab71b0 commit a436f41

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/gui/widget/scrollbar.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ scrollbar {
120120
width: 100%;
121121
height: 14px;
122122
}
123-
123+
.has-horizontal-scrollbar {
124+
padding-bottom: 14px;
125+
}
126+
.has-vertical-scrollbar {
127+
padding-right: 14px;
128+
}
124129
);
125130

126131
/* clang-format on */
@@ -325,7 +330,8 @@ static void ScrollBar_OnLink(LCUI_Widget w, LCUI_WidgetEvent e, void *arg)
325330
}
326331
}
327332

328-
static void ScrollBar_OnBoxDestroy(LCUI_Widget box, LCUI_WidgetEvent e, void *arg)
333+
static void ScrollBar_OnBoxDestroy(LCUI_Widget box, LCUI_WidgetEvent e,
334+
void *arg)
329335
{
330336
LCUI_Widget w = e->data;
331337

@@ -393,8 +399,22 @@ static void ScrollBar_UpdateSize(LCUI_Widget w)
393399
Widget_UpdateStyle(slider, FALSE);
394400
if (n < 1.0) {
395401
Widget_Show(w);
402+
if (scrollbar->direction == SBD_HORIZONTAL) {
403+
Widget_AddClass(scrollbar->box,
404+
"has-horizontal-scrollbar");
405+
} else {
406+
Widget_AddClass(scrollbar->box,
407+
"has-vertical-scrollbar");
408+
}
396409
} else {
397410
Widget_Hide(w);
411+
if (scrollbar->direction == SBD_HORIZONTAL) {
412+
Widget_RemoveClass(scrollbar->box,
413+
"has-horizontal-scrollbar");
414+
} else {
415+
Widget_RemoveClass(scrollbar->box,
416+
"has-vertical-scrollbar");
417+
}
398418
}
399419
}
400420

0 commit comments

Comments
 (0)