Compare commits

..

2 Commits

Author SHA1 Message Date
14e0a6ad0a use @bitsizeof() 2026-03-20 18:21:37 +01:00
bafadae1e0 scissoring fixes and scroll offset of grow elements 2026-03-15 00:07:50 +01:00
5 changed files with 44 additions and 52 deletions

View File

@ -96,8 +96,7 @@ fn void Cache.remove(&cache, Key id)
/* If there is no free space left then just return the first position */ /* If there is no free space left then just return the first position */
fn usz Cache.get_free_spot(&cache) fn usz Cache.get_free_spot(&cache)
{ {
// TODO: in the upgrade to c3 1.7.5 use @bitsof() const BITS = @bitsizeof(cache.present.data[0]);
const BITS = $typeof(cache.present.data[0]).sizeof*8;
foreach (idx, d: cache.present.data) { foreach (idx, d: cache.present.data) {
if (d != $typeof(d).max) { if (d != $typeof(d).max) {
usz spot = idx*BITS + BITS-d.clz(); usz spot = idx*BITS + BITS-d.clz();

View File

@ -214,4 +214,3 @@ fn void? Ctx.push_update_atlas(&ctx, Atlas* atlas)
} }
macro Ctx.dbg_rect(&ctx, Rect r, uint c = 0xff000042u) => ctx.push_rect(r, int.max, &&(Style){.bg=c.to_rgba()})!!; macro Ctx.dbg_rect(&ctx, Rect r, uint c = 0xff000042u) => ctx.push_rect(r, int.max, &&(Style){.bg=c.to_rgba()})!!;

View File

@ -179,7 +179,7 @@ fn void resolve_grow_elements(Elem* e, Elem* p)
p.layout.grow_children--; p.layout.grow_children--;
p.layout.occupied += slot; p.layout.occupied += slot;
} else if (p.layout.dir == COLUMN) { // grow across the layout axis, inherit width of the parent } else if (p.layout.dir == COLUMN) { // grow across the layout axis, inherit width of the parent
e.bounds.w = p.content_space().x; e.bounds.w = p.content_space().x + p.layout.scroll_offset.x;
} }
} }
@ -193,7 +193,7 @@ fn void resolve_grow_elements(Elem* e, Elem* p)
p.layout.grow_children--; p.layout.grow_children--;
p.layout.occupied += slot; p.layout.occupied += slot;
} else if (p.layout.dir == ROW) { // grow across the layout axis, inherit width of the parent } else if (p.layout.dir == ROW) { // grow across the layout axis, inherit width of the parent
e.bounds.h = p.content_space().y; e.bounds.h = p.content_space().y + p.layout.scroll_offset.y;
} }
} }
} }

View File

@ -308,7 +308,6 @@ fn void? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
{ {
if (text == "") return; if (text == "") return;
if (bounds.w <= 0 || bounds.h <= 0) return; if (bounds.w <= 0 || bounds.h <= 0) return;
ctx.push_scissor(bounds, z_index)!;
Font* font = &ctx.font; Font* font = &ctx.font;
Id texture_id = font.id; Id texture_id = font.id;
@ -320,9 +319,6 @@ fn void? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
Rect uv = gi.gp.uv(); Rect uv = gi.gp.uv();
ctx.push_sprite(b, uv, texture_id, z_index, hue)!; ctx.push_sprite(b, uv, texture_id, z_index, hue)!;
} }
ctx.reset_scissor(z_index)!;
// ctx.dbg_rect(str_bounds.off(bounds.position()));
} }
@ -584,5 +580,3 @@ fn TextSize? Ctx.measure_string(&ctx, String text)
return ts; return ts;
} }

View File

@ -124,8 +124,9 @@ fn void? Ctx.div_begin_id(&ctx,
ctx.push_rect(elem.bounds.pad(style.margin), elem.z_index, style)!; ctx.push_rect(elem.bounds.pad(style.margin), elem.z_index, style)!;
// update the ctx scissor, it HAS to be after drawing the background // update the ctx scissor, it HAS to be after drawing the background
ctx.div_scissor = elem.bounds.pad(elem.layout.content_offset).max({0,0,0,0}); Rect scissor = elem.bounds.pad(elem.layout.content_offset).max({0,0,0,0});
ctx.push_scissor(ctx.div_scissor, elem.z_index)!; ctx.push_scissor(scissor, elem.z_index)!;
ctx.div_scissor = scissor;
//elem.events = ctx.get_elem_events(elem); //elem.events = ctx.get_elem_events(elem);
@ -234,7 +235,6 @@ fn Id? Ctx.div_end(&ctx)
elem.div.resized.y = true; elem.div.resized.y = true;
elem.div.resize_size.y = content_bounds.h - (elem.bounds.y - m.y); elem.div.resize_size.y = content_bounds.h - (elem.bounds.y - m.y);
} }
} }
// the active_div returns to the parent of the current one // the active_div returns to the parent of the current one