aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSan Jacobs2023-08-17 01:48:00 +0200
committerSan Jacobs2023-08-17 01:48:00 +0200
commita7c2d13bcca784350d851b665b8a19697e113b34 (patch)
treeb29207528bc4cbc4ef5d2d162c0a8d53b47da677 /src
parent80362dbf454bb4bc5b19deb438b7c485240ef367 (diff)
downloadsatscalc-a7c2d13bcca784350d851b665b8a19697e113b34.tar.gz
satscalc-a7c2d13bcca784350d851b665b8a19697e113b34.tar.bz2
satscalc-a7c2d13bcca784350d851b665b8a19697e113b34.zip
Screw everything, we do oui now
Diffstat (limited to 'src')
-rw-r--r--src/main.odin127
1 files changed, 125 insertions, 2 deletions
diff --git a/src/main.odin b/src/main.odin
index bcbaeec..17517c7 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -1,4 +1,5 @@
package main
+import "../lib/oui"
import "core:fmt"
import "core:math"
@@ -78,6 +79,11 @@ main :: proc() {
big_font: Font = LoadFontEx("res/UbuntuMono-Regular.ttf", big_font_size, nil, 0)
defer UnloadFont(big_font)
+ // oui stuff
+
+ c0 := oui.context_create(1028, 1028 * 8)
+ defer oui.context_destroy(c0)
+ oui.context_make_current(c0)
// Setting up the timelines
@@ -116,13 +122,42 @@ main :: proc() {
// clicking will put a white border around the timeblock,
// and display information about the block in the
// 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)))
// DRAW
// ------------------------------------------
BeginDrawing()
ClearBackground(BGCOLOR)
+
+ // hotloop
+ oui.begin_layout()
+
+ a_panel := panel()
+ oui.set_layout(a_panel, .Absolute)
+ oui.set_size(a_panel, 200, 200)
+ oui.set_offset(a_panel, 20, 20)
+
+ a_button := button("Testerino", 50)
+ if oui.latest_clicked() {
+ fmt.println("CLICKO BOIO")
+ }
+ 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()
+
+ ui_draw(0)
+ // DRAW HERE OR BELOW
+ oui.process()
+
+ /*
DrawTextEx(font, "Date", {20, 8}, font_size, 0, RAYWHITE);
DrawTextEx(font, "Calltime", {105, 8}, font_size, 0, RAYWHITE);
DrawTextEx(font, "Wraptime", {f32(width)-83, 8}, font_size, 0, RAYWHITE);
@@ -176,7 +211,7 @@ main :: proc() {
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);
-
+ */
EndDrawing()
}
}
@@ -187,3 +222,91 @@ PBGCOLOR : rl.Color : {40, 40, 40, 255}
DAY_HEIGHT :: 35
TIMELINE_START :: 175
TIMELINE_END :: -85
+
+Item :: oui.Item
+Call :: oui.Call
+
+Data_Element :: enum int {
+ Panel,
+ Button,
+ Text_Input,
+ Timeblock,
+// ...
+}
+
+Data_Head :: struct {
+ subtype: Data_Element,
+}
+
+Data_Panel :: struct {
+ using _: Data_Head,
+}
+
+Data_Button :: struct {
+ using _: Data_Head,
+ text: string,
+ selected: bool,
+}
+
+button_callback :: proc(item: Item, event: Call) -> int {
+ data := cast(^Data_Button) oui.get_handle(item)
+
+ #partial switch event {
+ case .Cursor_Handle:
+ //return int(Cursor_Type.Hand)
+ }
+
+ return -1
+}
+
+panel :: proc() -> Item {
+ item := oui.item_make()
+
+ data := oui.alloc_typed(item, Data_Panel)
+ data.subtype = .Panel
+
+ return item
+}
+
+button :: proc(text: string, width: int, selected := false) -> Item {
+ item := oui.item_make()
+ oui.set_size(item, width, 35)
+ oui.set_callback(item, button_callback)
+
+ data := oui.alloc_typed(item, Data_Button)
+ data.subtype = .Button
+ data.text = text
+ data.selected = selected
+
+ return item
+}
+
+// recursive loop
+ui_draw_children :: proc(item: oui.Item) {
+ list := oui.children_sorted(item)
+ for kid in list {
+ ui_draw(kid)
+ }
+}
+
+ui_draw :: proc(item: oui.Item) {
+ head := cast(^Data_Head) oui.get_handle(item)
+ rect := oui.get_rect(item)
+
+ //fmt.println(rect, head, item)
+
+ if head == nil {
+ ui_draw_children(item)
+ return
+ }
+
+ #partial switch head.subtype {
+ //case .Panel_Root:
+ // ... render any type of item
+ case .Button:
+ rl.DrawRectangle(i32(rect.l), i32(rect.t), i32(rect.r-rect.l), i32(rect.b-rect.t), PBGCOLOR)
+ case .Panel:
+ rl.DrawRectangle(i32(rect.l), i32(rect.t), i32(rect.r-rect.l), i32(rect.b-rect.t), rl.RED)
+ ui_draw_children(item)
+ }
+} \ No newline at end of file