UI fun
This commit is contained in:
@@ -61,11 +61,11 @@ ui_checkbox_field :: (label: string, value: *bool, identifier: s64 = 0, loc := #
|
||||
changed := false;
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_set_next_size_y(.CHILDREN_SUM);
|
||||
ui_set_next_padding(5.0);
|
||||
ui_set_next_padding(2.0);
|
||||
container := ui_box_make(0, hash=get_hash(loc, identifier));
|
||||
ui_push_parent(container, .LEFT, .HORIZONTAL);
|
||||
{
|
||||
ui_label_half_parent(label);
|
||||
ui_label(label);
|
||||
ui_checkbox(value, identifier);
|
||||
}
|
||||
ui_pop_parent();
|
||||
@@ -138,49 +138,51 @@ ui_label :: (text: string, text_color: Color = .{1,1,1,1}, identifier: s64 = 0,
|
||||
ui_set_next_text_color(text_color);
|
||||
ui_set_next_size_x(.TEXT_DIM);
|
||||
ui_set_next_size_y(.TEXT_DIM);
|
||||
ui_set_next_padding(5);
|
||||
//ui_set_next_padding(5);
|
||||
ui_set_next_text_alignment(.CENTER_VERTICALLY);
|
||||
box := ui_box_make(.DRAW_TEXT, get_hash(loc, identifier));
|
||||
}
|
||||
|
||||
ui_label_half_parent :: (text: string, text_color: Color = .{1,1,1,1}, identifier: s64 = 0, loc := #caller_location) {
|
||||
ui_set_next_text(text);
|
||||
ui_set_next_background_color(.{0.0,1.0,1.0,0.0});
|
||||
ui_set_next_text_color(text_color);
|
||||
ui_set_next_size_x(.PCT, 0.5);
|
||||
ui_set_next_size_y(.TEXT_DIM);
|
||||
ui_set_next_padding(5);
|
||||
box := ui_box_make(.DRAW_TEXT, get_hash(loc, identifier));
|
||||
}
|
||||
ui_field_label :: (label: string, value: Any, identifier: s64 = 0, loc := #caller_location) {
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
|
||||
ui_label_for_fields :: (text: string, text_color: Color = .{1,1,1,1}, identifier: s64 = 0, loc := #caller_location) {
|
||||
ui_set_next_text(text);
|
||||
ui_set_next_background_color(.{0.0,1.0,1.0,0.0});
|
||||
ui_set_next_text_color(text_color);
|
||||
ui_set_next_size_x(.PCT, 0.5);
|
||||
ui_set_next_size_y(.TEXT_DIM);
|
||||
ui_set_next_padding(5);
|
||||
box := ui_box_make(.DRAW_TEXT, get_hash(loc, identifier));
|
||||
}
|
||||
text_size := get_text_size(engine.renderer, label, ui_state.fonts.button);
|
||||
ui_set_next_size_y(.PIXELS, text_size.y);
|
||||
//ui_set_next_padding(2.0);
|
||||
container := ui_box_make(0, hash=get_hash(loc, identifier));
|
||||
|
||||
ui_label_fill_parent_x :: (text: string, identifier: s64 = 0, loc := #caller_location) {
|
||||
ui_set_next_text(text);
|
||||
ui_set_next_background_color(.{0.0,1.0,1.0,0.0});
|
||||
ui_set_next_text_color(.{1,1,1,1});
|
||||
ui_set_next_size_x(.PCT, 1);
|
||||
ui_set_next_size_y(.TEXT_DIM);
|
||||
ui_set_next_padding(5);
|
||||
//ui_set_next_text_alignment(.CENTER_VERTICALLY);
|
||||
box := ui_box_make(.DRAW_TEXT | .ANIMATE_ON_HOVER, get_hash(loc, identifier));
|
||||
ui_push_parent(ui_state.last_box, .LEFT, .HORIZONTAL);
|
||||
{
|
||||
ui_set_next_size_x(.PCT, 0.5);
|
||||
ui_set_next_size_y(.CHILDREN_SUM);
|
||||
left := ui_box_make(0, hash=get_hash(loc, 2));
|
||||
{
|
||||
ui_push_parent(left, .LEFT, .HORIZONTAL);
|
||||
defer ui_pop_parent();
|
||||
ui_label(label);
|
||||
}
|
||||
ui_set_next_size_x(.PCT, 0.5);
|
||||
ui_set_next_size_y(.CHILDREN_SUM);
|
||||
right := ui_box_make(0, hash=get_hash(loc, 2));
|
||||
{
|
||||
ui_push_parent(right, .LEFT, .HORIZONTAL);
|
||||
defer ui_pop_parent();
|
||||
ui_label(tprint("%", value));
|
||||
}
|
||||
}
|
||||
ui_pop_parent();
|
||||
}
|
||||
|
||||
ui_textfield :: (label: string, text: *string, identifier: s64 = 0, loc := #caller_location) {
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_set_next_size_y(.CHILDREN_SUM);
|
||||
ui_set_next_padding(2.0);
|
||||
//ui_set_next_background_color(.{1,1,1,1});
|
||||
container := ui_box_make(0, hash=get_hash(loc, identifier));
|
||||
|
||||
ui_push_parent(ui_state.last_box, .LEFT, .HORIZONTAL);
|
||||
{
|
||||
ui_label_half_parent(label);
|
||||
ui_label(label);
|
||||
ui_set_next_background_color(.{0.0,1.0,1.0,0.0});
|
||||
ui_set_next_border_color(.{0.3,0.3,0.3,1.0});
|
||||
|
||||
@@ -256,7 +258,7 @@ ui_int_field :: (label: string, value: *int, identifier: s64 = 0, loc := #caller
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_push_parent(ui_state.last_box, .LEFT, .HORIZONTAL);
|
||||
{
|
||||
ui_label_half_parent(label);
|
||||
ui_label(label);
|
||||
|
||||
text_size := get_text_size(engine.renderer, tprint("%", <<value), ui_state.fonts.button);
|
||||
|
||||
@@ -354,8 +356,11 @@ ui_int_field :: (label: string, value: *int, identifier: s64 = 0, loc := #caller
|
||||
|
||||
ui_float_field :: (label: string, value: *float, identifier: s64 = 0, loc := #caller_location) -> bool {
|
||||
changed := false;
|
||||
ui_container_layout(identifier=identifier, loc=loc);
|
||||
ui_push_parent(ui_state.last_box, .LEFT, .HORIZONTAL);
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_set_next_size_y(.CHILDREN_SUM);
|
||||
ui_set_next_padding(2.0);
|
||||
container := ui_box_make(0, hash=get_hash(loc, identifier));
|
||||
ui_push_parent(container, .LEFT, .HORIZONTAL);
|
||||
{
|
||||
ui_label(label);
|
||||
changed |= ui_float_field(value, identifier);
|
||||
@@ -492,11 +497,12 @@ ui_float_field :: (value: *float, identifier: s64 = 0, loc := #caller_location)
|
||||
ui_vector_field :: (label: string, value: *Vector3, identifier: s64 = 0, loc := #caller_location) -> bool {
|
||||
changed := false;
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_set_next_size_y(.TEXT_DIM);
|
||||
ui_container_layout(identifier=identifier, loc=loc);
|
||||
ui_push_parent(ui_state.last_box, .LEFT, .HORIZONTAL);
|
||||
ui_set_next_size_y(.CHILDREN_SUM);
|
||||
ui_set_next_padding(2.0);
|
||||
container := ui_box_make(0, hash=get_hash(loc, identifier));
|
||||
ui_push_parent(container, .LEFT, .HORIZONTAL);
|
||||
{
|
||||
ui_label_for_fields(label);
|
||||
ui_label(label);
|
||||
|
||||
//ui_set_next_size_x(.PCT, 0.5);
|
||||
//ui_set_next_size_y(.CHILDREN_SUM);
|
||||
|
||||
Reference in New Issue
Block a user