65 lines
1.1 KiB
Plaintext
65 lines
1.1 KiB
Plaintext
// Safe application-level UI model. Rendering is provided by the proprietary Agila runtime.
|
|
module agila
|
|
|
|
pub struct Color {
|
|
pub:
|
|
r u8
|
|
g u8
|
|
b u8
|
|
a u8 = 255
|
|
}
|
|
|
|
pub fn rgb(hex u32) Color {
|
|
return Color{
|
|
r: u8((hex >> 16) & 0xff)
|
|
g: u8((hex >> 8) & 0xff)
|
|
b: u8(hex & 0xff)
|
|
}
|
|
}
|
|
|
|
pub struct Theme {
|
|
pub:
|
|
background Color
|
|
surface Color
|
|
text Color
|
|
accent Color
|
|
}
|
|
|
|
pub fn default_theme() Theme {
|
|
return Theme{
|
|
background: rgb(0x08080e)
|
|
surface: rgb(0x171827)
|
|
text: rgb(0xf5f1ff)
|
|
accent: rgb(0xc084fc)
|
|
}
|
|
}
|
|
|
|
pub interface Widget {
|
|
describe() string
|
|
}
|
|
|
|
pub struct Text {
|
|
pub:
|
|
value string
|
|
}
|
|
|
|
pub fn (t Text) describe() string { return 'Text(${t.value})' }
|
|
|
|
pub struct Button {
|
|
pub:
|
|
label string
|
|
}
|
|
|
|
pub fn (b Button) describe() string { return 'Button(${b.label})' }
|
|
|
|
pub struct Column {
|
|
pub:
|
|
children []Widget
|
|
}
|
|
|
|
pub fn (c Column) describe() string { return 'Column(${c.children.len} children)' }
|
|
|
|
pub fn preview(widget Widget) {
|
|
println('[Agila SDK sandbox UI] ${widget.describe()}')
|
|
}
|