Compare commits
3 Commits
225f61079d
...
1f66c23919
Author | SHA1 | Date | |
---|---|---|---|
1f66c23919 | |||
a9642f28bd | |||
6a7dd998a6 |
@ -177,3 +177,5 @@ fn void? Ctx.push_update_atlas(&ctx, Atlas* atlas)
|
|||||||
ctx.push_cmd(&up, -1)!;
|
ctx.push_cmd(&up, -1)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro Ctx.dbg_rect(&ctx, Rect r, uint c = 0xff000042u) => ctx.push_rect(r, int.max, &&(Style){.bg=c.to_rgba()})!!;
|
||||||
|
|
||||||
|
@ -363,6 +363,7 @@ fn Rect? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
|
|||||||
|
|
||||||
Codepoint cp;
|
Codepoint cp;
|
||||||
isz off = line_start;
|
isz off = line_start;
|
||||||
|
short first_off;
|
||||||
for ITER: (usz x; (cp = str_to_codepoint(text[off..], &x)) != 0; off += x) {
|
for ITER: (usz x; (cp = str_to_codepoint(text[off..], &x)) != 0; off += x) {
|
||||||
Glyph* gp = font.get_glyph(cp)!;
|
Glyph* gp = font.get_glyph(cp)!;
|
||||||
|
|
||||||
@ -375,6 +376,8 @@ fn Rect? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
|
|||||||
case ascii::is_cntrl((char)cp):
|
case ascii::is_cntrl((char)cp):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (off == line_start) first_off = gp.ox;
|
||||||
|
|
||||||
Rect b = {
|
Rect b = {
|
||||||
.x = o.x + gp.ox,
|
.x = o.x + gp.ox,
|
||||||
.y = o.y + gp.oy + baseline,
|
.y = o.y + gp.oy + baseline,
|
||||||
@ -393,7 +396,7 @@ fn Rect? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
|
|||||||
if (line_end == line_start) unreachable("something went wrong in measuring the line");
|
if (line_end == line_start) unreachable("something went wrong in measuring the line");
|
||||||
|
|
||||||
// with the line width calculate the right origin and layout the line
|
// with the line width calculate the right origin and layout the line
|
||||||
origin.x = bounds.x;
|
origin.x = bounds.x - first_off;
|
||||||
short next_line_x = bounds.x; // the x coordinate of the origin if the line_width is zero
|
short next_line_x = bounds.x; // the x coordinate of the origin if the line_width is zero
|
||||||
switch (anchor) {
|
switch (anchor) {
|
||||||
case TOP_LEFT: nextcase;
|
case TOP_LEFT: nextcase;
|
||||||
@ -446,7 +449,6 @@ fn Rect? Ctx.layout_string(&ctx, String text, Rect bounds, Anchor anchor, int z_
|
|||||||
.h = gp.h
|
.h = gp.h
|
||||||
};
|
};
|
||||||
ctx.push_sprite(b, uv, texture_id, z_index, hue)!;
|
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;
|
origin.x += gp.adv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/main.c3
12
src/main.c3
@ -390,33 +390,33 @@ fn void calculator(ugui::Ctx* ui, TextEdit* te)
|
|||||||
ui.@div(ugui::@grow(), ugui::@exact(100), ROW, RIGHT) {
|
ui.@div(ugui::@grow(), ugui::@exact(100), ROW, RIGHT) {
|
||||||
ui.text((String)buffer[:len])!!;
|
ui.text((String)buffer[:len])!!;
|
||||||
}!!;
|
}!!;
|
||||||
ui.@div(ugui::@fit(), ugui::@fit(), ROW, TOP_LEFT) {
|
ui.@row() {
|
||||||
ui.@div(ugui::@fit(), ugui::@fit(), COLUMN) {
|
ui.@column() {
|
||||||
ui.button("7")!!.mouse_press ? buffer[len++] = '7' : 0;
|
ui.button("7")!!.mouse_press ? buffer[len++] = '7' : 0;
|
||||||
ui.button("4")!!.mouse_press ? buffer[len++] = '4' : 0;
|
ui.button("4")!!.mouse_press ? buffer[len++] = '4' : 0;
|
||||||
ui.button("1")!!.mouse_press ? buffer[len++] = '1' : 0;
|
ui.button("1")!!.mouse_press ? buffer[len++] = '1' : 0;
|
||||||
ui.button("0")!!.mouse_press ? buffer[len++] = '0' : 0;
|
ui.button("0")!!.mouse_press ? buffer[len++] = '0' : 0;
|
||||||
}!!;
|
}!!;
|
||||||
ui.@div(ugui::@fit(), ugui::@fit(), COLUMN) {
|
ui.@column() {
|
||||||
ui.button("8")!!.mouse_press ? buffer[len++] = '8' : 0;
|
ui.button("8")!!.mouse_press ? buffer[len++] = '8' : 0;
|
||||||
ui.button("5")!!.mouse_press ? buffer[len++] = '5' : 0;
|
ui.button("5")!!.mouse_press ? buffer[len++] = '5' : 0;
|
||||||
ui.button("2")!!.mouse_press ? buffer[len++] = '2' : 0;
|
ui.button("2")!!.mouse_press ? buffer[len++] = '2' : 0;
|
||||||
ui.button(".")!!.mouse_press ? buffer[len++] = '.' : 0;
|
ui.button(".")!!.mouse_press ? buffer[len++] = '.' : 0;
|
||||||
}!!;
|
}!!;
|
||||||
ui.@div(ugui::@fit(), ugui::@fit(), COLUMN) {
|
ui.@column() {
|
||||||
ui.button("9")!!.mouse_press ? buffer[len++] = '9' : 0;
|
ui.button("9")!!.mouse_press ? buffer[len++] = '9' : 0;
|
||||||
ui.button("6")!!.mouse_press ? buffer[len++] = '6' : 0;
|
ui.button("6")!!.mouse_press ? buffer[len++] = '6' : 0;
|
||||||
ui.button("3")!!.mouse_press ? buffer[len++] = '3' : 0;
|
ui.button("3")!!.mouse_press ? buffer[len++] = '3' : 0;
|
||||||
ui.button("(")!!.mouse_press ? buffer[len++] = '(' : 0;
|
ui.button("(")!!.mouse_press ? buffer[len++] = '(' : 0;
|
||||||
}!!;
|
}!!;
|
||||||
ui.@div(ugui::@exact(10), ugui::@exact(10)) {}!!;
|
ui.@div(ugui::@exact(10), ugui::@exact(10)) {}!!;
|
||||||
ui.@div(ugui::@fit(), ugui::@fit(), COLUMN) {
|
ui.@column() {
|
||||||
ui.button("x")!!.mouse_press ? buffer[len++] = '*' : 0;
|
ui.button("x")!!.mouse_press ? buffer[len++] = '*' : 0;
|
||||||
ui.button("/")!!.mouse_press ? buffer[len++] = '/' : 0;
|
ui.button("/")!!.mouse_press ? buffer[len++] = '/' : 0;
|
||||||
ui.button("+")!!.mouse_press ? buffer[len++] = '+' : 0;
|
ui.button("+")!!.mouse_press ? buffer[len++] = '+' : 0;
|
||||||
ui.button(")")!!.mouse_press ? buffer[len++] = ')' : 0;
|
ui.button(")")!!.mouse_press ? buffer[len++] = ')' : 0;
|
||||||
}!!;
|
}!!;
|
||||||
ui.@div(ugui::@fit(), ugui::@fit(), COLUMN) {
|
ui.@column() {
|
||||||
ui.button("C")!!.mouse_press ? len = 0 : 0;
|
ui.button("C")!!.mouse_press ? len = 0 : 0;
|
||||||
ui.button("D")!!.mouse_press ? len > 0 ? len-- : 0 : 0;
|
ui.button("D")!!.mouse_press ? len > 0 ? len-- : 0 : 0;
|
||||||
ui.button("-")!!.mouse_press ? buffer[len++] = '-' : 0;
|
ui.button("-")!!.mouse_press ? buffer[len++] = '-' : 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user