The Aero widget style derives its glass tints from whichever palette is active, so a 13th palette entry was redundant. Remove THEME_AERO (and its ini mirrors, locale label and picker slot); the style now defaults to Sky. Saved theme ids beyond the shrunken count normalize through the existing out-of-range fallback.
144 lines
4.6 KiB
Plaintext
144 lines
4.6 KiB
Plaintext
#import "kryon.h"
|
|
|
|
app "Kryon Aero Theme" {
|
|
size 900 680
|
|
fps 60
|
|
font examples
|
|
theme THEME_SKY light
|
|
}
|
|
|
|
state {
|
|
theme_mode: int = THEME_MODE_SYSTEM
|
|
theme_id: int = THEME_SKY
|
|
mode_index: int = 0
|
|
slider_value: int = 64
|
|
toggle_value: int = 1
|
|
check_value: int = 1
|
|
progress_value: int = 62
|
|
spin_value: int = 4
|
|
combo_index: int = 1
|
|
text_value: [128] char = "Aero glass text field"
|
|
text_cursor: int = 21
|
|
text_focused: int = 0
|
|
tab_scroll: int = 0
|
|
}
|
|
|
|
ClampInt :: (value: int, min_value: int, max_value: int) -> int {
|
|
if value < min_value {
|
|
return min_value
|
|
}
|
|
if value > max_value {
|
|
return max_value
|
|
}
|
|
return value
|
|
}
|
|
|
|
ThemeDarkMode :: () -> int {
|
|
if theme_mode == THEME_MODE_DARK {
|
|
return 1
|
|
}
|
|
if theme_mode == THEME_MODE_LIGHT {
|
|
return 0
|
|
}
|
|
return SystemThemePrefersDark() ? 1 : 0
|
|
}
|
|
|
|
ApplyThemeState :: () {
|
|
theme_mode = ClampInt(theme_mode, THEME_MODE_SYSTEM, THEME_MODE_DARK)
|
|
theme_id = ClampInt(theme_id, 0, THEME_COUNT - 1)
|
|
SetThemeSource(THEME_SOURCE_APP)
|
|
SetThemeMode((ThemeMode)theme_mode)
|
|
SetThemeStyle(THEME_STYLE_AERO)
|
|
SetCurrentTheme(theme_id, ThemeDarkMode())
|
|
}
|
|
|
|
screen AeroExample(viewport: Rectangle) {
|
|
ApplyThemeState()
|
|
Background(GetThemeBackground())
|
|
|
|
x_margin: int = ScaleUIPx(36)
|
|
options: [3] const char * = {"Glass", "Frost", "Clear"}
|
|
tabs: [3] UITab = {
|
|
{"General", {0}, 0, 0, {0}, 0, 0},
|
|
{"Appearance", {0}, 0, 0, {0}, 0, 0},
|
|
{"Advanced", {0}, 0, 0, {0}, 0, 0}
|
|
}
|
|
|
|
TitleBar("Aero Theme Showcase", ScaleUIPx(44))
|
|
|
|
y: int = ScaleUIPx(80)
|
|
Text("Windows Vista/7 glass, rendered from plain primitives on every backend.",
|
|
x_margin, y, UI_TEXT_16, GetThemeIcon())
|
|
y += ScaleUIPx(44)
|
|
|
|
TabBar((TabBarProps){{x_margin, y, viewport.width - x_margin * 2, ScaleUIPx(40)},
|
|
tabs, 3, 0, 0, 0, 0, &tab_scroll, 0, nil})
|
|
y += ScaleUIPx(64)
|
|
|
|
Button((ButtonProps){
|
|
.bounds = {x_margin, y, ScaleUIPx(170), ScaleUIPx(44)},
|
|
.label = "Primary",
|
|
.style = UI_BUTTON_STYLE_PRIMARY,
|
|
.id = 401,
|
|
})
|
|
Button((ButtonProps){
|
|
.bounds = {x_margin + ScaleUIPx(190), y, ScaleUIPx(170), ScaleUIPx(44)},
|
|
.label = "Danger",
|
|
.style = UI_BUTTON_STYLE_DANGER,
|
|
.id = 402,
|
|
})
|
|
Button((ButtonProps){
|
|
.bounds = {x_margin + ScaleUIPx(380), y, ScaleUIPx(170), ScaleUIPx(44)},
|
|
.label = "Secondary",
|
|
.style = UI_BUTTON_STYLE_SECONDARY,
|
|
.id = 403,
|
|
})
|
|
y += ScaleUIPx(68)
|
|
|
|
field_style := (UITextInputStyle){
|
|
DarkenUIColor(GetThemeBackground(), 6),
|
|
DarkenUIColor(GetThemeBackground(), 38),
|
|
GetThemeButtonHover(),
|
|
GetThemeText(),
|
|
GetThemeText(),
|
|
0.08f,
|
|
ScaleUIPx(12),
|
|
ScaleUIPx(8)
|
|
}
|
|
|
|
TextField((TextFieldProps){{x_margin, y, ScaleUIPx(360), ScaleUIPx(44)},
|
|
text_value, sizeof(text_value),
|
|
&text_cursor, &text_focused, 80, UI_TEXT_16, 404,
|
|
field_style, nil, nil, nil})
|
|
Dropdown(405, x_margin + ScaleUIPx(390), y, ScaleUIPx(360), ScaleUIPx(44),
|
|
options, 3, &combo_index)
|
|
y += ScaleUIPx(72)
|
|
|
|
Slider(406, x_margin, y, ScaleUIPx(360), "Gloss", 0, 100, &slider_value, "%", nil)
|
|
Toggle(407, x_margin + ScaleUIPx(390), y, ScaleUIPx(170), ScaleUIPx(44),
|
|
&toggle_value, "Off", "On")
|
|
Checkbox(408, x_margin + ScaleUIPx(590), y + ScaleUIPx(12), "Frost", &check_value)
|
|
y += ScaleUIPx(72)
|
|
|
|
Progress((ProgressBarProps){{x_margin, y, ScaleUIPx(360), ScaleUIPx(22)},
|
|
0, 100, progress_value, "Syncing"})
|
|
Radio((RadioButtonProps){{x_margin + ScaleUIPx(390), y - ScaleUIPx(8),
|
|
ScaleUIPx(170), ScaleUIPx(36)},
|
|
"Frosted", 409, 1, 0})
|
|
Radio((RadioButtonProps){{x_margin + ScaleUIPx(390), y + ScaleUIPx(32),
|
|
ScaleUIPx(170), ScaleUIPx(36)},
|
|
"Clear", 410, 0, 0})
|
|
y += ScaleUIPx(64)
|
|
|
|
Spinbox((SpinboxProps){{x_margin, y, ScaleUIPx(220), ScaleUIPx(44)},
|
|
411, 0, 20, 1, &spin_value, 0, nil, 0})
|
|
y += ScaleUIPx(76)
|
|
|
|
mode_options: [2] const char * = {"Light", "Dark"}
|
|
Text("Mode applies live; the widget style stays Aero.", x_margin, y, UI_TEXT_12, GetThemeIcon())
|
|
if Dropdown(412, x_margin + ScaleUIPx(400), y - ScaleUIPx(8), ScaleUIPx(160),
|
|
ScaleUIPx(40), mode_options, 2, &mode_index) {
|
|
theme_mode = mode_index == 0 ? THEME_MODE_LIGHT : THEME_MODE_DARK
|
|
}
|
|
}
|