Initial commit
This commit is contained in:
commit
20540c69b1
2 changed files with 188 additions and 0 deletions
51
example/main.odin
Normal file
51
example/main.odin
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package main
|
||||
|
||||
import rl "vendor:raylib"
|
||||
import ui ".."
|
||||
import "core:fmt"
|
||||
|
||||
WINDOW_WIDTH :: 1280
|
||||
WINDOW_HEIGHT :: 720
|
||||
WINDOW_CAPTION :: "Immediate mode GUI"
|
||||
WINDOW_FRAMERATE :: 60
|
||||
|
||||
main :: proc() {
|
||||
rl.SetTraceLogLevel(.WARNING)
|
||||
rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_CAPTION)
|
||||
defer rl.CloseWindow()
|
||||
rl.SetTargetFPS(WINDOW_FRAMERATE)
|
||||
|
||||
ctx: ui.Context
|
||||
ui.init(&ctx, 4000)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
ui.start(&ctx, {0, 0})
|
||||
ui.container_begin(
|
||||
dimensions = {ui.Size_Pixels(WINDOW_WIDTH), ui.Size_Pixels(WINDOW_HEIGHT)},
|
||||
margin = {4.0, 8.0},
|
||||
padding = {12.0, 24.0},
|
||||
color = cast([4]u8)rl.RED,
|
||||
label = "",
|
||||
)
|
||||
ui.container_end()
|
||||
elements := ui.end()
|
||||
|
||||
rl.BeginDrawing()
|
||||
defer rl.EndDrawing()
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
|
||||
for element in elements {
|
||||
switch data in element.data {
|
||||
case ui.ElementData_Container:
|
||||
area := rl.Rectangle(element.area)
|
||||
fmt.println(area)
|
||||
if len(element.label) == 0 {
|
||||
rl.DrawRectangleRoundedLinesEx(area, 0.1, 4.0, 1.0, rl.Color(element.color))
|
||||
} else {
|
||||
rl.GuiLabel(area, element.label)
|
||||
}
|
||||
case ui.ElementData_Button:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue