ui.jamo (built in)
ui: labels, panels, buttons, checkboxes, sliders, lists and text boxes, drawn with gfx. use "ui.jamo"
Controls are drawn fresh every frame between begin() and finish(), and each call answers with the control's value, so there's nothing to set up or keep in step. They stack down the window from the top left, as wide as the window or the panel they're in. Every control that can take the keyboard gets a number from the order it's drawn in: focus holds the number of the one that has the keyboard, and Tab moves to the next number at the end of the frame.
structTheme
struct Theme
background: Color
panel: Color
text: Color
soft_text: Color
control: Color
hover: Color
accent: Color
on_accent: Color
field: Color
text_size: float
gap: float
padding: float
height: float
round: float
endHow everything looks. Change any field of ui.theme to restyle
structUi
struct Ui
gfx: Gfx
window: Window
theme: Theme
surface: Color
left: float
y: float
width: float
columns: int
column: int
row_height: float
count: int
focus: int
active: int
pressed: bool
claimed: bool
caret: int
view: int
blink_from: int
frame: int
scrolls: [int]
last_x: float
last_y: float
last_width: float
last_height: float
endfuncstart_ui
func start_ui(g: Gfx): Ui
funclight_theme
func light_theme(): Theme
funcdark_theme
func dark_theme(): Theme
funcUi.begin
func Ui.begin()
Starts a frame of controls, at the window's top left
funcUi.finish
func Ui.finish()
Ends the frame: a click on nothing drops the keyboard focus, and Tab or Shift+Tab moves it
funcUi.focus_on
func Ui.focus_on(id: int)
funcUi.place
func Ui.place(x: float, y: float, width: float)
Puts the next controls at x and y, this wide
funcUi.panel
func Ui.panel(x: float, y: float, width: float, height: float)
Draws a panel, and puts the next controls inside it
funcUi.columns
func Ui.columns(count: int)
The next few controls sit side by side, sharing the width
funcUi.space
func Ui.space(height: float)
Leaves an empty gap before the next control
funcUi.next
func Ui.next(height: float)
Saves where the next control goes in last_x, last_y, last_width and last_height
funcUi.hovered
func Ui.hovered(): bool
funcUi.control
func Ui.control(drag: bool): int
Gives the control its number, and takes the keyboard for it when it's clicked
funcUi.clicked
func Ui.clicked(id: int): bool
True when the mouse went down on this control and came back up over it
funcUi.text_at
func Ui.text_at(words: string, x: float, top: float, height: float, color: Color)
funcUi.ring
func Ui.ring(id: int)
funcui_round
func ui_round(g: Gfx, x: float, y: float, width: float, height: float, radius: float, color: Color)
A rectangle with round corners
funcui_part
func ui_part(words: string, from: int, to: int): string
Part of a text, from one place up to another
funcUi.fit
func Ui.fit(words: string, width: float): string
The front of a text that fits in a width, with ... when it's cut
funcui_short
func ui_short(value: float): string
A number with up to 2 decimals, and none when it's whole
funcUi.label
func Ui.label(words: string)
funcUi.title
func Ui.title(words: string)
Larger text, for the top of a page or panel
funcUi.note
func Ui.note(words: string)
Text in the softer color, for notes and hints
funcUi.button
func Ui.button(words: string): bool
True in the frame it's clicked, or pressed with Space or Enter while it has the keyboard
funcUi.checkbox
func Ui.checkbox(words: string, checked: bool): bool
Answers whether it's checked, after any click or Space
funcUi.slider
func Ui.slider(words: string, value: float, low: float, high: float): float
Answers the value, from low to high, after any drag or arrow key
funcUi.list
func Ui.list(items: [string], selected: int, rows: int): int
Answers the chosen item's place, or -1 for none. Shows this many rows, and scrolls for the rest
funcUi.text_box
func Ui.text_box(words: string): string
Answers the text after any typing. Click it or Tab to it, then type, with Backspace, Delete, the arrows, Home and End
funcUi.caret_at
func Ui.caret_at(words: string, spot: float): int
The place in a text nearest to a spot this far into the box, counting from the box's view