Checkboxerino
This commit is contained in:
@@ -29,7 +29,7 @@ ui_button :: (text: string, identifier: s64 = 0, loc := #caller_location) -> cli
|
||||
return box.interaction.clicked, box.interaction;
|
||||
}
|
||||
|
||||
ui_checkbox :: (checked: bool, identifier: s64 = 0, loc := #caller_location) -> bool {
|
||||
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, 12);
|
||||
@@ -41,7 +41,7 @@ ui_checkbox :: (checked: bool, identifier: s64 = 0, loc := #caller_location) ->
|
||||
box := ui_box_make(.CLICKABLE | .DRAW_BORDER | .DRAW_TEXT | .DRAW_BACKGROUND, get_hash(loc, identifier));
|
||||
ui_push_parent(box, .LEFT, .HORIZONTAL);
|
||||
{
|
||||
if checked {
|
||||
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});
|
||||
@@ -51,10 +51,23 @@ ui_checkbox :: (checked: bool, identifier: s64 = 0, loc := #caller_location) ->
|
||||
ui_pop_parent();
|
||||
|
||||
if box.interaction.clicked {
|
||||
return !checked;
|
||||
checked.* = !checked.*;
|
||||
}
|
||||
|
||||
return checked;
|
||||
return checked.*;
|
||||
}
|
||||
|
||||
ui_checkbox_field :: (label: string, value: *bool, 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_label(label);
|
||||
ui_checkbox(value, identifier);
|
||||
}
|
||||
ui_pop_parent();
|
||||
|
||||
return value.*;
|
||||
}
|
||||
|
||||
ui_button_with_texture :: (texture_handle: Texture_Handle, identifier: s64 = 0, loc := #caller_location) -> clicked: bool, Interaction_State {
|
||||
|
||||
Reference in New Issue
Block a user