86 lines
3.7 KiB
Ziran
86 lines
3.7 KiB
Ziran
#import "theme"
|
|
|
|
using ThemePolicy;
|
|
using ThemeColorRole;
|
|
using ThemeMetricRole;
|
|
|
|
#program_export
|
|
Answer :: () -> s32 {
|
|
if ResolveDark(.ThemePolicyLight, true) ||
|
|
!ResolveDark(.ThemePolicyDark, false) ||
|
|
!ResolveDark(.ThemePolicySystem, true) ||
|
|
ResolveDark(.ThemePolicySystem, false) { return 1 }
|
|
|
|
light := DefaultTheme(false)
|
|
dark := DefaultTheme(true)
|
|
if light.dark || !dark.dark { return 2 }
|
|
if light.colors.background != cast(u32)0xffffffff ||
|
|
dark.colors.background != cast(u32)0x121212ff ||
|
|
light.colors.focus == dark.colors.focus ||
|
|
light.series.items[0] == dark.series.items[0] { return 3 }
|
|
if ThemeColorValue(light, .ThemeColorSurfaceMuted) != light.colors.surface_muted ||
|
|
ThemeColorValue(dark, .ThemeColorControlThumbOn) != dark.colors.control_thumb_on ||
|
|
ThemeColorValue(light, .ThemeColorScrim) != light.colors.scrim { return 4 }
|
|
if ThemeSeriesValue(light, 2) != light.series.items[2] ||
|
|
ThemeSeriesValue(dark, 5) != dark.series.items[5] { return 5 }
|
|
if ThemeMetricValue(light, .ThemeMetricFocusGap) != 3.0 ||
|
|
ThemeMetricValue(dark, .ThemeMetricControlHeightSmall) != 30.0 ||
|
|
ThemeMetricValue(dark, .ThemeMetricDisabledOpacity) != 0.55 { return 6 }
|
|
|
|
if !InstallDefaultTheme(false) || CurrentTheme().dark ||
|
|
CurrentBackground() != light.colors.background ||
|
|
CurrentSelectionText() != light.colors.selection_text ||
|
|
CurrentThemeColor(.ThemeColorHoverLayer) != light.colors.hover_layer { return 7 }
|
|
|
|
custom: ThemeTokens = CurrentTheme()
|
|
custom.metrics.control_height_medium = 40.0
|
|
custom.metrics.radius_medium = 11.0
|
|
custom.fonts.body = "Custom Body"
|
|
custom.motion.hover_ms = 224.0
|
|
custom.motion.multiplier = 2.5
|
|
custom.motion.saved_multiplier = 2.5
|
|
if !InstallTheme(custom) { return 8 }
|
|
if !SetThemeMode(true) || !CurrentTheme().dark { return 9 }
|
|
current := CurrentTheme()
|
|
if current.metrics.control_height_medium != 40.0 ||
|
|
current.metrics.radius_medium != 11.0 ||
|
|
current.fonts.body != "Custom Body" ||
|
|
current.motion.hover_ms != 224.0 ||
|
|
current.colors.background != dark.colors.background { return 10 }
|
|
|
|
accent: ThemeTokens = WithAccent(current, cast(u32)0xd1403aff,
|
|
cast(u32)0xffffffff, cast(u32)0xa72d28ff, cast(u32)0xd1403a26)
|
|
if accent.metrics.control_height_medium != 40.0 ||
|
|
accent.colors.accent != cast(u32)0xd1403aff ||
|
|
accent.colors.control_glyph != OnColor(cast(u32)0xd1403aff) ||
|
|
accent.colors.control_thumb_on != OnColor(cast(u32)0xd1403aff) ||
|
|
accent.colors.selection_text != cast(u32)0xa72d28ff { return 11 }
|
|
if !InstallTheme(accent) { return 12 }
|
|
if !SetReducedMotion(true) ||
|
|
CurrentTheme().motion.multiplier != 0.0 ||
|
|
CurrentTheme().motion.saved_multiplier != 2.5 { return 13 }
|
|
if MotionDuration(1, false, 1.0) != 224.0 { return 14 }
|
|
if !SetReducedMotion(false) ||
|
|
CurrentTheme().motion.multiplier != 2.5 { return 15 }
|
|
if MotionDuration(1, false, 2.5) != 560.0 ||
|
|
MotionDuration(1, true, 2.5) != 0.0 { return 16 }
|
|
|
|
if OnColor(cast(u32)0x000000ff) != cast(u32)0xffffffff ||
|
|
OnColor(cast(u32)0xffffffff) != cast(u32)0x0b0b0bff { return 17 }
|
|
if StateLayer(cast(u32)0xffffffff, cast(u32)0x000000ff, cast(u32)8) !=
|
|
cast(u32)0xeaeaeaff { return 18 }
|
|
if StateLayer(cast(u32)0, cast(u32)0x006b5fff, cast(u32)12) !=
|
|
cast(u32)0x006b5f1e { return 19 }
|
|
for percent: cast(u32)0..100 {
|
|
sample := StateLayer(cast(u32)0x12345680, cast(u32)0xaabbccff, percent)
|
|
if (sample & cast(u32)255) != cast(u32)128 { return 20 }
|
|
}
|
|
return 42
|
|
}
|
|
|
|
#program_export
|
|
main :: () -> s32 {
|
|
if Answer() != 42 { return 1 }
|
|
return 0
|
|
}
|