enlarge scrollbars when focused
This commit is contained in:
parent
f7985f8c7f
commit
ca691d1294
@ -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 = {
|
||||
|
@ -54,7 +54,7 @@ fn ElemEvents! Ctx.slider_hor(&ctx,
|
||||
Point m = ctx.input.mouse.pos;
|
||||
elem.events = ctx.get_elem_events(elem);
|
||||
|
||||
if (ctx.elem_focus(elem) && elem.events.mouse_hold) {
|
||||
if (ctx.elem_focus(elem) && ctx.is_mouse_down(BTN_LEFT)) {
|
||||
*value = calc_value(elem.bounds.x, m.x, elem.bounds.w, hw);
|
||||
elem.slider.handle.x = calc_slider(elem.bounds.x, elem.bounds.w-hw, *value);
|
||||
elem.events.update = true;
|
||||
@ -117,7 +117,7 @@ fn ElemEvents! Ctx.slider_ver(&ctx,
|
||||
Point m = ctx.input.mouse.pos;
|
||||
elem.events = ctx.get_elem_events(elem);
|
||||
|
||||
if (ctx.elem_focus(elem) && elem.events.mouse_hold) {
|
||||
if (ctx.elem_focus(elem) && ctx.is_mouse_down(BTN_LEFT)) {
|
||||
*value = calc_value(elem.bounds.y, m.y, elem.bounds.h, hh);
|
||||
elem.slider.handle.y = calc_slider(elem.bounds.y, elem.bounds.h-hh, *value);
|
||||
elem.events.update = true;
|
||||
|
Loading…
Reference in New Issue
Block a user