From 665e10fa3054bc1cc21910a7881d6aab1757d0ed Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Tue, 28 Oct 2025 00:26:18 +0100 Subject: [PATCH] fix absolute placement and scrollbar --- src/layout.c3 | 2 +- src/widgets/slider.c3 | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/layout.c3 b/src/layout.c3 index 8ed464d..6e3ee05 100644 --- a/src/layout.c3 +++ b/src/layout.c3 @@ -205,7 +205,7 @@ fn void resolve_placement(Elem* c, Elem* p) // if the element has absolute position assign the origin and do not update the parent if (cl.absolute) { c.bounds.x = p.bounds.x + pl.content_offset.x + cl.origin.x; - c.bounds.y = p.bounds.x + pl.content_offset.x + cl.origin.y; + c.bounds.y = p.bounds.y + pl.content_offset.y + cl.origin.y; return; } diff --git a/src/widgets/slider.c3 b/src/widgets/slider.c3 index 70927e7..b54cc18 100644 --- a/src/widgets/slider.c3 +++ b/src/widgets/slider.c3 @@ -140,23 +140,22 @@ fn void? Ctx.scrollbar(&ctx, Id id, float *value, float handle_percent, bool ver Style* style = ctx.styles.get_style(@str_hash("scrollbar")); Rect pb = parent.bounds.pad(parent.layout.content_offset); - elem.bounds.x = vertical ? pb.bottom_right().x - style.size: pb.x; - elem.bounds.y = vertical ? pb.y : pb.bottom_right().y - style.size; if (vertical) { elem.layout.w = @exact(style.size); elem.layout.h = @grow(); - elem.bounds.x -= style.margin.x + style.margin.w + style.border.x + style.border.w; + elem.layout.origin.x = pb.w - style.size; + elem.layout.origin.y = 0; } else { elem.layout.w = @grow(); elem.layout.h = @exact(style.size); - elem.bounds.y -= style.margin.y + style.margin.h + style.border.y + style.border.h; + elem.layout.origin.x = 0; + elem.layout.origin.y = pb.h - style.size; } elem.layout.content_offset = style.margin + style.border + style.padding; elem.layout.absolute = true; update_parent_size(elem, parent); Rect content_bounds = elem.bounds.pad(elem.layout.content_offset); - //elem.events = ctx.get_elem_events(elem); short o = vertical ? content_bounds.y : content_bounds.x; short m = vertical ? ctx.input.mouse.pos.y : ctx.input.mouse.pos.x;