Checkbox time

This commit is contained in:
2025-01-01 02:29:58 +01:00
parent 939fb58ac9
commit 47558576af
2 changed files with 18 additions and 8 deletions

View File

@@ -32,21 +32,29 @@ ui_button :: (text: string, identifier: s64 = 0, loc := #caller_location) -> cli
ui_checkbox :: (checked: bool, identifier: s64 = 0, loc := #caller_location) -> bool {
ui_set_next_background_color(.{0.2,0.2,0.2,1});
ui_set_next_text_color(.{1,1,1,1});
ui_set_next_size_x(.PIXELS, 20);
ui_set_next_size_y(.PIXELS, 20);
ui_set_next_size_x(.PIXELS, 12);
ui_set_next_size_y(.PIXELS, 12);
ui_set_next_padding(5);
//ui_set_next_padding(5);
//ui_set_next_text_alignment(CENTER_HORIZONTALLY | .CENTER_VERTICALLY);
box := ui_box_make(.CLICKABLE | .DRAW_BORDER | .DRAW_TEXT | .DRAW_BACKGROUND | .ANIMATE_ON_HOVER, get_hash(loc, identifier));
box := ui_box_make(.CLICKABLE | .DRAW_BORDER | .DRAW_TEXT | .DRAW_BACKGROUND, get_hash(loc, identifier));
ui_push_parent(box, .LEFT, .HORIZONTAL);
{
//ui_set_next_padding(5);
ui_set_next_background_color(.{1.0,1.0,1.0,1});
inner_box := ui_box_make(.DRAW_TEXT | .DRAW_BACKGROUND, get_hash(loc, 1));
if checked {
ui_set_next_size_x(.PCT, 1);
ui_set_next_size_y(.PCT, 1);
ui_set_next_background_color(.{0.4,0.4,0.4,1});
inner_box := ui_box_make(.DRAW_TEXT | .DRAW_BACKGROUND | .ANIMATE_ON_HOVER, get_hash(loc, 1));
}
}
ui_pop_parent();
return box.interaction.clicked;
if box.interaction.clicked {
return !checked;
}
return checked;
}
ui_button_with_texture :: (texture_handle: Texture_Handle, identifier: s64 = 0, loc := #caller_location) -> clicked: bool, Interaction_State {