Files
kryon/examples/11_basic_controls.kry
T

46 lines
1.4 KiB
Plaintext

#import "kryon.h"
app "Kryon Basic Controls" {
size 800 600
fps 60
font examples
}
state {
radio: int = 1
spin: int = 4
combo: int = 0
progress: int = 45
choices: [3] const char * = {"Alpha","Beta","Gamma"}
}
BasicControlsExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
Text((TextProps){.bounds={40, 40, 0, 0}, .text="Basic controls", .font=Text24, .color=GetThemeText(), .wrap=TextWrapNone})
picked: int = Radio((RadioButtonProps){{40,90,160,28},"Choice A",1,radio==1,0})
if picked {
radio = picked
}
picked = Radio((RadioButtonProps){{40,124,160,28},"Choice B",2,radio==2,0})
if picked {
radio = picked
}
Text((TextProps){.bounds={40, 166, 0, 0}, .text=TextFormat("Selected: Choice %s", radio == 1 ? "A" : "B"), .font=Text16, .color=GetThemeText(), .wrap=TextWrapNone})
Spinbox((SpinboxProps){{240,90,140,34},201,0,10,1,&spin,0})
Combobox((ComboboxProps){{240,140,180,34},202,choices,3,&combo,0})
Progress((ProgressBarProps){{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
}
}
}
}