Compare commits
No commits in common. "d47b835020468ebffc5c9d75fb512bc4867b9bc5" and "63b3d05b194901289014066f61625ccdb96777d5" have entirely different histories.
d47b835020
...
63b3d05b19
@ -414,11 +414,18 @@ fn Rect? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
|
||||
next_line_x += bounds.w;
|
||||
}
|
||||
|
||||
// reset the cursor to the line
|
||||
if (line_start <= cursor && cursor <= line_end) {
|
||||
cursor_rect.x = origin.x;
|
||||
cursor_rect.y = origin.y;
|
||||
cursor_rect.w = 0;
|
||||
if (cursor && text[cursor-1] == '\n') {
|
||||
cursor_rect.x = next_line_x;
|
||||
cursor_rect.y += line_height;
|
||||
}
|
||||
}
|
||||
|
||||
Point line_origin = origin;
|
||||
|
||||
// see the fixme when measuring the height
|
||||
//ctx.push_rect({.x = origin.x,.y=origin.y,.w=(short)line_width,.h=(short)string_height}, z_index, &&(Style){.bg=0xff000042u.@to_rgba()})!;
|
||||
@ -447,26 +454,22 @@ fn Rect? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
|
||||
};
|
||||
ctx.push_sprite(b, uv, texture_id, z_index, hue)!;
|
||||
//ctx.push_rect(b, z_index, &&(Style){.bg=0x0000ff66u.@to_rgba()})!;
|
||||
|
||||
origin.x += gp.adv;
|
||||
}
|
||||
|
||||
if (line_start + off + x == cursor) {
|
||||
if (line_start + off < cursor && text[cursor-1] != '\n') {
|
||||
cursor_rect.x = origin.x;
|
||||
cursor_rect.y = origin.y;
|
||||
cursor_rect.w = gp.adv;
|
||||
}
|
||||
}
|
||||
|
||||
// done with the line
|
||||
line_start = line_end;
|
||||
origin.y += line_height + line_gap;
|
||||
|
||||
if (cursor == text.len && text[^1] == '\n') {
|
||||
cursor_rect.x = next_line_x;
|
||||
cursor_rect.y = origin.y;
|
||||
}
|
||||
|
||||
} while(line_end < text.len);
|
||||
|
||||
|
||||
ctx.reset_scissor(z_index)!;
|
||||
|
||||
return cursor_rect;
|
||||
|
@ -39,9 +39,9 @@ fn void? Ctx.text_id(&ctx, Id id, String text)
|
||||
}
|
||||
|
||||
|
||||
macro Ctx.text_box(&ctx, Size w, Size h, TextEdit* te, Anchor text_alignment = TOP_LEFT, ...)
|
||||
=> ctx.text_box_id(@compute_id($vasplat), w, h, te, text_alignment);
|
||||
fn ElemEvents? Ctx.text_box_id(&ctx, Id id, Size w, Size h, TextEdit* te, Anchor text_alignment)
|
||||
macro Ctx.text_box(&ctx, Size w, Size h, TextEdit* te, ...)
|
||||
=> ctx.text_box_id(@compute_id($vasplat), w, h, te);
|
||||
fn ElemEvents? Ctx.text_box_id(&ctx, Id id, Size w, Size h, TextEdit* te)
|
||||
{
|
||||
id = ctx.gen_id(id)!;
|
||||
|
||||
@ -77,11 +77,10 @@ fn ElemEvents? Ctx.text_box_id(&ctx, Id id, Size w, Size h, TextEdit* te, Anchor
|
||||
Rect text_bounds = elem.bounds.pad(elem.layout.content_offset);
|
||||
ctx.push_rect(bg_bounds, parent.div.z_index, style)!;
|
||||
Rect cur;
|
||||
cur = ctx.layout_string(elem.text.te.to_string(), text_bounds, text_alignment, parent.div.z_index, style.fg, elem.text.te.cursor)!;
|
||||
cur = ctx.layout_string(elem.text.te.to_string(), text_bounds, TOP_LEFT, parent.div.z_index, style.fg, elem.text.te.cursor)!;
|
||||
|
||||
// draw the cursor if the element has focus
|
||||
cur.w = 2;
|
||||
cur.x -= 2;
|
||||
if (elem.events.has_focus) {
|
||||
ctx.push_scissor(text_bounds, parent.div.z_index)!;
|
||||
ctx.push_rect(cur, parent.div.z_index, &&(Style){.bg = style.fg})!;
|
||||
|
@ -423,7 +423,7 @@ fn void calculator(ugui::Ctx* ui, TextEdit* te)
|
||||
ui.slider_ver(ugui::@exact(20), ugui::@exact(100), &f)!!;
|
||||
}!!;
|
||||
ui.@div(ugui::@grow(), ugui::@fit(), anchor: CENTER, scroll_y: true) {
|
||||
ui.text_box(ugui::@grow(), ugui::@exact(100), te, RIGHT)!!;
|
||||
ui.text_box(ugui::@grow(), ugui::@exact(100), te)!!;
|
||||
}!!;
|
||||
|
||||
}!!; }!!;
|
||||
|
Loading…
x
Reference in New Issue
Block a user