enlarge scrollbars when focused

This commit is contained in:
Alessandro Mauri 2024-12-20 02:17:41 +01:00
parent f7985f8c7f
commit ca691d1294
2 changed files with 7 additions and 6 deletions

View file

@ -11,13 +11,11 @@ struct ElemDiv {
struct scroll_x {
bool enabled;
bool on;
bool focus;
float value;
}
struct scroll_y {
bool enabled;
bool on;
bool focus;
float value;
}
Rect children_bounds; // current frame children bounds
@ -99,8 +97,11 @@ fn void! Ctx.div_end(&ctx)
// vertical overflow
elem.div.scroll_y.on = cbc.y > bc.y && elem.div.scroll_y.enabled;
short wdim = elem.div.scroll_y.on ? (elem.div.scroll_y.focus ? SCROLLBAR_DIM*3 : SCROLLBAR_DIM) : 0;
short hdim = elem.div.scroll_x.on ? (elem.div.scroll_x.focus ? SCROLLBAR_DIM*3 : SCROLLBAR_DIM) : 0;
Id hsid = ctx.gen_id("div_scrollbar_horizontal")!;
Id vsid = ctx.gen_id("div_scrollbar_vertical")!;
short wdim = elem.div.scroll_y.on ? (ctx.focus_id == vsid ? SCROLLBAR_DIM*3 : SCROLLBAR_DIM) : 0;
short hdim = elem.div.scroll_x.on ? (ctx.focus_id == hsid ? SCROLLBAR_DIM*3 : SCROLLBAR_DIM) : 0;
if (elem.div.scroll_y.on) {
Rect vslider = {