aboutsummaryrefslogtreecommitdiff
path: root/src/ui_implementation.odin
diff options
context:
space:
mode:
authorSan Jacobs2023-10-13 12:00:49 +0200
committerSan Jacobs2023-10-13 12:00:49 +0200
commite77dec086f94da480af8c42bec6cac8e873a6931 (patch)
tree79aca74dfb34a00658c1d23af11822a4e26b4682 /src/ui_implementation.odin
parent40687c8c5624dda5bd6b9c6b0e281fb079755040 (diff)
downloadsatscalc-e77dec086f94da480af8c42bec6cac8e873a6931.tar.gz
satscalc-e77dec086f94da480af8c42bec6cac8e873a6931.tar.bz2
satscalc-e77dec086f94da480af8c42bec6cac8e873a6931.zip
Progressed ability to write text using new oui system
Diffstat (limited to 'src/ui_implementation.odin')
-rw-r--r--src/ui_implementation.odin20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/ui_implementation.odin b/src/ui_implementation.odin
index 4842a76..7c5f9e3 100644
--- a/src/ui_implementation.odin
+++ b/src/ui_implementation.odin
@@ -1,6 +1,8 @@
package main
import "../lib/oui"
+import "core:strings"
+import "core:fmt"
import rl "vendor:raylib"
@@ -44,6 +46,8 @@ Data_Button :: struct {
Data_Label :: struct {
using _: Data_Head,
text: string,
+ font: rl.Font,
+ font_size: i32,
alignment: Text_Alignment,
}
@@ -84,6 +88,7 @@ button :: proc(text: string, width: int, selected := false) -> Item {
Text_Alignment :: enum int {
Left,
Right,
+ Center
}
label :: proc(text: string, font: rl.Font, alignment: Text_Alignment = .Left) -> Item {
item := oui.item_make()
@@ -91,6 +96,7 @@ label :: proc(text: string, font: rl.Font, alignment: Text_Alignment = .Left) ->
data := oui.alloc_typed(item, Data_Label)
data.subtype = .Label
data.text = text
+ data.font_size = font.baseSize // This should not be necesssary
data.alignment = alignment
return item
@@ -121,10 +127,18 @@ ui_draw :: proc(item: oui.Item) {
case .Button:
rl.DrawRectangle(i32(rect.l), i32(rect.t), i32(rect.r-rect.l), i32(rect.b-rect.t), PBGCOLOR)
case .Panel:
- subtyped := cast(^Data_Panel) head
- rl.DrawRectangle(i32(rect.l), i32(rect.t), i32(rect.r-rect.l), i32(rect.b-rect.t), subtyped.color)
+ data := cast(^Data_Panel) head
+ rl.DrawRectangle(i32(rect.l), i32(rect.t), i32(rect.r-rect.l), i32(rect.b-rect.t), data.color)
ui_draw_children(item)
case .Label:
-
+ data := cast(^Data_Label) oui.get_handle(item)
+
+ // For some reason, data.font.baseSize == 0 here. It doesn't outside of this function. Dunno why.
+ font_height := f32(data.font_size)
+
+ rl.DrawTextEx(data.font, strings.unsafe_string_to_cstring(data.text), { 0, 0 }, font_height, 0.0, rl.RAYWHITE);
+ //rl.DrawTextEx(rl.GetFontDefault(), strings.unsafe_string_to_cstring(data.text), { 0, 0 }, 40, 0, rl.WHITE);
+ //rl.DrawFPS(0, 0)
+ //fmt.println(font_height)
}
} \ No newline at end of file