Compare commits

..

No commits in common. "14e0a6ad0a6103d2235d010ee110f001460f301c" and "e193109570cc0bb93eb669833e42872c3765b1c5" have entirely different histories.

5 changed files with 52 additions and 44 deletions

View File

@ -96,7 +96,8 @@ 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)
{ {
const BITS = @bitsizeof(cache.present.data[0]); // TODO: in the upgrade to c3 1.7.5 use @bitsof()
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,3 +214,4 @@ 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 + p.layout.scroll_offset.x; e.bounds.w = p.content_space().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 + p.layout.scroll_offset.y; e.bounds.h = p.content_space().y;
} }
} }
} }

View File

@ -308,6 +308,7 @@ 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;
@ -319,6 +320,9 @@ 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()));
} }
@ -580,3 +584,5 @@ fn TextSize? Ctx.measure_string(&ctx, String text)
return ts; return ts;
} }

View File

@ -124,9 +124,8 @@ 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
Rect scissor = elem.bounds.pad(elem.layout.content_offset).max({0,0,0,0}); ctx.div_scissor = elem.bounds.pad(elem.layout.content_offset).max({0,0,0,0});
ctx.push_scissor(scissor, elem.z_index)!; ctx.push_scissor(ctx.div_scissor, elem.z_index)!;
ctx.div_scissor = scissor;
//elem.events = ctx.get_elem_events(elem); //elem.events = ctx.get_elem_events(elem);
@ -235,6 +234,7 @@ 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