counter := 0;
test_button_count := 1;
+check_buttons : [10] bool
+
draw :: () {
gl.clearColor(0, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
master_rectangle := ui.Rectangle.{ x1 = ~~window_width, y1 = ~~window_height };
- left, right := ui.Flow.split_vertical(master_rectangle, left_width=400);
- right_top, right_bottom := ui.Flow.split_horizontal(right, top_percent=.6);
+ use ui.Flow;
+
+ left, right := split_vertical(master_rectangle, left_width=400);
+ right_top, right_bottom := split_horizontal(right, top_percent=.6);
ui.draw_rect(right_bottom, .{ 0, 0.25, 0.5 });
ui.draw_rect(right_top, .{ 0.5, 0.4, 0.4 });
{
- top, bottom := ui.Flow.split_horizontal(right_bottom, top_percent=.5);
+ panel, _ := split_vertical(right_top, left_width=300);
+ checkbox : ui.Rectangle;
+
+ ui.draw_rect(panel, .{ 0, 0, 0, 0.3 });
+
+ str_buffer : [32] u8;
+
+ i := 1;
+ for ^button_value: check_buttons {
+ checkbox, panel = split_horizontal(panel, top_height=48);
+
+ text := conv.str_format("Check me! %i", ~~ str_buffer, i);
+ ui.checkbox(checkbox, button_value, text, increment=i);
+
+ i += 1;
+ }
+
+ button_rect, _ := split_horizontal(panel, top_height=72);
+ button_rect = padding(button_rect, left=12, right=12, top=24);
+ if ui.button(button_rect, "Clear all") {
+ for ^value: check_buttons do *value = false;
+ }
+ }
+
+ {
+ top, bottom := split_horizontal(right_bottom, top_percent=.5);
text_theme := ui.default_text_theme;
text_theme.font_size = 1.0f;
ui.draw_text(bottom, "Something here\nSomething else here.\nAlso here.", ^text_theme);
red_theme := ui.default_button_theme;
red_theme.text_color = .{ 1, 0, 0 };
red_theme.click_color = .{ 1, 0, 0 };
- button_rect, sidebar = ui.Flow.split_horizontal(sidebar, top_height=200, padding=10);
+ button_rect, sidebar = split_horizontal(sidebar, top_height=200, padding=10);
if ui.button(button_rect, "Red\nWow this is cool", ^red_theme) {
counter += 1;
}
if counter % 2 == 0 {
red_theme = ui.default_button_theme;
- button_rect, sidebar = ui.Flow.split_horizontal(sidebar, top_height=75, padding=10);
+ button_rect, sidebar = split_horizontal(sidebar, top_height=75, padding=10);
ui.button(button_rect, "Another Button", ^red_theme);
}
- button_rect, sidebar = ui.Flow.split_horizontal(sidebar, top_height=75, padding = 10);
+ button_rect, sidebar = split_horizontal(sidebar, top_height=75, padding = 10);
if ui.button(button_rect, "Increase Buttons", ^red_theme) do test_button_count += 1;
- button_rect, sidebar = ui.Flow.split_horizontal(sidebar, top_height=75, padding = 10);
+ button_rect, sidebar = split_horizontal(sidebar, top_height=75, padding = 10);
if ui.button(button_rect, "Decrease Buttons", ^red_theme) do test_button_count -= 1;
test_button_count = math.clamp(test_button_count, 0, 10);
+ red_theme = ui.default_button_theme;
+ red_theme.font_size = 0.7f;
for i: test_button_count {
- button_rect, sidebar = ui.Flow.split_horizontal(sidebar, top_height=75, padding=10);
- ui.button(button_rect, "Test Button", increment=i);
+ button_rect, sidebar = split_horizontal(sidebar, top_height=75, padding=10);
+
+ left_button, right_button := split_vertical(button_rect, left_percent=.5, padding=10);
+ if ui.button(left_button, "Left Button", increment=i, theme=^red_theme) && i == 3 {
+ alert :: (message: str) -> void #foreign "game" "alert" ---
+ alert("Clicked the 4th left button!");
+ }
+ ui.button(right_button, "Right Button", increment=i, theme=^red_theme);
}
}