48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
#import "kryon.h"
|
|
#style <material> as material
|
|
|
|
app "Kryon Basic Controls" {
|
|
size 800 600
|
|
fps 60
|
|
font examples
|
|
}
|
|
|
|
state {
|
|
radio: int = 1
|
|
spin: int = 4
|
|
dropdown: int = 0
|
|
progress: int = 45
|
|
choices: [3] const char * = {"Alpha","Beta","Gamma"}
|
|
}
|
|
|
|
BasicControlsExample :: (viewport: Rectangle) #ui {
|
|
Screen root: {
|
|
bounds = viewport
|
|
AppBackground()
|
|
Text((TextProps){.bounds={40, 40, 0, 0}, .text="Basic controls", .wrap=TextWrapNone})
|
|
picked: int = Radio((RadioProps){.bounds = {40,90,160,28}, .label = "Choice A", .id = 1, .checked = radio == 1})
|
|
if picked {
|
|
radio = picked
|
|
}
|
|
picked = Radio((RadioProps){.bounds = {40,124,160,28}, .label = "Choice B", .id = 2, .checked = radio == 2})
|
|
if picked {
|
|
radio = picked
|
|
}
|
|
Text((TextProps){.bounds={40, 166, 0, 0}, .text=TextFormat("Selected: Choice %s", radio == 1 ? "A" : "B"), .wrap=TextWrapNone})
|
|
Spinbox((SpinboxProps){{240,90,140,34},201,0,10,1,&spin,0})
|
|
Dropdown((DropdownProps){.bounds = {240,140,180,34}, .id = 202,
|
|
.options = choices, .option_count = 3, .selected_index = &dropdown})
|
|
Progress((ProgressProps){{40,210,380,28},0,100,progress,"Progress"})
|
|
if (IsKeyPressed(KEY_RIGHT)) {
|
|
if progress < 100 {
|
|
progress += 5
|
|
}
|
|
}
|
|
if (IsKeyPressed(KEY_LEFT)) {
|
|
if progress > 0 {
|
|
progress -= 5
|
|
}
|
|
}
|
|
}
|
|
}
|