From fd262c11c3c0f627927ecc7fd5115899033018bb Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Sat, 14 Oct 2023 13:11:39 +0200 Subject: New OUI version --- src/main.odin | 53 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'src/main.odin') diff --git a/src/main.odin b/src/main.odin index ac3f693..79b1a1e 100644 --- a/src/main.odin +++ b/src/main.odin @@ -13,6 +13,8 @@ font : rl.Font big_font : rl.Font small_font : rl.Font +c0 : ^oui.Context + main :: proc() { // TODO: Replace the dynamic array of Workday-pointers with @@ -87,9 +89,10 @@ main :: proc() { // oui stuff - c0 := oui.context_create(1028, 1028 * 8) + c0 = new(oui.Context) + defer free(c0) + oui.context_init(c0, 1028, 1028 * 8) defer oui.context_destroy(c0) - oui.context_make_current(c0) // Setting up the timelines @@ -130,8 +133,8 @@ main :: proc() { // bottom left of the screen. mousePosition: = rl.GetMousePosition() - oui.set_cursor(int(mousePosition.x), int(mousePosition.y)) - oui.set_button(.Left, rl.IsMouseButtonPressed(rl.MouseButton(0))) + oui.set_cursor(c0, int(mousePosition.x), int(mousePosition.y)) + oui.set_button(c0, .Left, rl.IsMouseButtonPressed(rl.MouseButton(0))) // DRAW // ------------------------------------------ @@ -141,26 +144,42 @@ main :: proc() { when true { // hotloop - oui.begin_layout() + oui.begin_layout(c0) master_container := panel() - oui.set_layout(master_container, .Absolute) - oui.set_size(master_container, int(GetScreenWidth()), int(GetScreenHeight())) + master_container.id = oui.push_id(c0, "big_mr_boss_man") + master_container.layout = .Absolute + master_container.layout_size = {int(GetScreenWidth()), int(GetScreenHeight())} - top_bar := panel(BGCOLOR) - oui.set_cut(master_container, .Top) - oui.set_height(top_bar, 30) - oui.set_margin(top_bar, 6) - oui.item_insert(master_container, top_bar) + { + top_bar := panel_line(master_container, BGCOLOR, 30) + top_bar.id = oui.push_id(c0, "small_boie") + defer oui.pop_id(c0) + top_bar.layout_margin = 6 date_label := label("Date", font, .Left) oui.item_insert(top_bar, date_label) + } + { bottom_bar := panel(PBGCOLOR) - oui.set_cut(master_container, .Bottom) - oui.set_height(bottom_bar, 50) + bottom_bar.id = oui.push_id(c0, "not_small_boie") + defer oui.pop_id(c0) + bottom_bar.layout_cut_children = .Left + master_container.layout_cut_children = .Bottom + bottom_bar.layout_size.y = 50 oui.item_insert(master_container, bottom_bar) + } + + { + middle_section := panel(WBGCOLOR) + middle_section.id = oui.push_id(c0, "middle_section") + defer oui.pop_id(c0) + master_container.layout_cut_children = .Fill + oui.item_insert(master_container, middle_section) + } + @@ -174,11 +193,11 @@ when true { oui.item_insert(a_panel, a_button)*/ - oui.end_layout() + oui.end_layout(c0) - ui_draw(0) + ui_draw(master_container) // DRAW HERE OR BELOW - oui.process() + oui.process(c0) } else { DrawTextEx(font, "Date", {20, 8}, font_size, 0, RAYWHITE); -- cgit v1.2.1