aboutsummaryrefslogtreecommitdiff
path: root/src/main.odin
diff options
context:
space:
mode:
authorSan Jacobs2023-10-14 16:19:16 +0200
committerSan Jacobs2023-10-14 16:19:16 +0200
commit44d408583ab8811f2b89d8fcb9e21b98f1409b7d (patch)
tree7cf4751661269cf7d65c74246e7feb1745e4e585 /src/main.odin
parentfca6955979f4791acb016ef5da86fed1013b524e (diff)
downloadsatscalc-44d408583ab8811f2b89d8fcb9e21b98f1409b7d.tar.gz
satscalc-44d408583ab8811f2b89d8fcb9e21b98f1409b7d.tar.bz2
satscalc-44d408583ab8811f2b89d8fcb9e21b98f1409b7d.zip
There is a theme editor now???
Diffstat (limited to 'src/main.odin')
-rw-r--r--src/main.odin65
1 files changed, 36 insertions, 29 deletions
diff --git a/src/main.odin b/src/main.odin
index fcb425d..bed835a 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -4,6 +4,7 @@ import "../lib/oui"
import "core:fmt"
import "core:math"
import "core:slice"
+import "core:runtime"
import "core:strings"
import rl "vendor:raylib"
@@ -136,7 +137,8 @@ main :: proc() {
mousePosition: = rl.GetMousePosition()
oui.set_cursor(c0, int(mousePosition.x), int(mousePosition.y))
- oui.set_button(c0, .Left, rl.IsMouseButtonPressed(rl.MouseButton(0)))
+ if rl.IsMouseButtonPressed(rl.MouseButton(0)) do oui.set_button(c0, .Left, true)
+ if rl.IsMouseButtonReleased(rl.MouseButton(0)) do oui.set_button(c0, .Left, false)
// DRAW
// ------------------------------------------
@@ -150,22 +152,24 @@ when true {
master_container := panel()
- master_container.id = oui.push_id(c0, "big_mr_boss_man")
+ master_container.id = oui.push_id(c0, "big_mr_boss_man") // Make ID for master thing just because.
+ // Does not need to be freed because master.
master_container.layout = .Absolute
master_container.layout_size = {int(GetScreenWidth()), int(GetScreenHeight())}
{
- top_bar := panel_line(master_container, theme.background_top, 30)
- top_bar.id = oui.push_id(c0, "small_boie")
- defer oui.pop_id(c0)
+ top_bar := panel_line(master_container, theme.background_bar, 30)
+ top_bar.id = oui.push_id(c0, "small_boie") // Make ID for anything that will have children.
+ defer oui.pop_id(c0) // These need to be pop'ed before the next item at the same level in the hierachy.
top_bar.layout_margin = 6
- date_label := label("Date", font, .Left)
- oui.item_insert(top_bar, date_label)
+ oui.item_insert(top_bar, label("Date", font, .Left))
+ oui.item_insert(top_bar, label("Calltime", font, .Left))
+ oui.item_insert(top_bar, label("Lunch", font, .Left))
}
{
- bottom_bar := panel(theme.background_bottom)
+ bottom_bar := panel(theme.background_bar)
bottom_bar.id = oui.push_id(c0, "not_small_boie")
defer oui.pop_id(c0)
bottom_bar.layout_cut_children = .Left
@@ -178,32 +182,35 @@ when true {
middle_section := panel(theme.background)
middle_section.id = oui.push_id(c0, "middle_section")
defer oui.pop_id(c0)
+ middle_section.layout_margin = 10 // Spacing from edges
+ middle_section.layout_cut_gap = 5 // Spacing between children
master_container.layout_cut_children = .Fill
oui.item_insert(master_container, middle_section)
- {
- line := panel_line(middle_section, theme.background, 40)
- line.id = oui.push_id(c0, "a_line")
+ // To loop over the members of a struct you need to do this goofy shit:
+ info := runtime.type_info_base(type_info_of(Theme))
+ st := info.variant.(runtime.Type_Info_Struct)
+ root := uintptr(&theme)
+ for offset, i in st.offsets {
+
+ line := panel_line(middle_section, theme.background, 25)
+ line.layout_cut_gap = 10
+ line.id = oui.push_id(c0, fmt.tprintf("line_%d", i))
defer oui.pop_id(c0)
- {
- a_button := button("Testor", 100)
- oui.item_insert(line, a_button)
- }
+
+ oui.item_insert(line, label(st.names[i], font, ))
+
+ // To then access the member of the struct you're looping over
+ // you need to do this shit:
+ // v------------------------v
+ color_sliders(line, cast(^Color) (root+offset))
}
- }
-
-
-
-/* a_button := button("Testerino", 50)
- if oui.latest_clicked() {
- fmt.println("CLICKO BOIO")
+ output_theme_button := button("output theme", 100)
+ oui.item_insert(middle_section, output_theme_button)
+ if oui.is_clicked(c0, output_theme_button) do fmt.printf("%#v", theme)
}
- oui.set_cut(a_panel, .Left)
- oui.set_height(a_button, 50)
- oui.set_offset(a_button, 20, 20)
-
- oui.item_insert(a_panel, a_button)*/
+
oui.end_layout(c0)
@@ -227,7 +234,7 @@ when true {
// (At least, given how lunch breaks are currently implemented,
// as holes in the workday)
- DrawRectangle(10, DAY_HEIGHT*i32(i+1)-4, width-20, DAY_HEIGHT-1, PBGCOLOR)
+ DrawRectangle(10, DAY_HEIGHT*i32(i+1)-4, width-20, DAY_HEIGHT-1, theme.background_top)
for block, j in day.blocks {
if j == day.total_timeblocks do break
block_color: = GREEN
@@ -261,7 +268,7 @@ when true {
}
}
- DrawRectangle(0, height-50, width+10, 60, PBGCOLOR)
+ DrawRectangle(0, height-50, width+10, 60, theme.background_top)
DrawTextEx(small_font, total_sum, {f32(width)-120, f32(height)-43}, small_font_size, 0, RAYWHITE);
DrawTextEx(big_font, inc_soc, {f32(width)-120, f32(height)-29}, big_font_size, 0, RAYWHITE);