101 lines
3.4 KiB
Ziran
101 lines
3.4 KiB
Ziran
#import "session"
|
|
#import "text_input_platform_host"
|
|
test_session: Session;
|
|
TestSession :: () -> Session {
|
|
if !SessionValid(test_session) { test_session = SessionOpen() }
|
|
return test_session
|
|
}
|
|
|
|
#import "control_props"
|
|
#import "geometry"
|
|
#import "progress"
|
|
#import "progress_props"
|
|
#import "progress_style"
|
|
#import "progress_widget"
|
|
#import "style"
|
|
#import "style_sheet"
|
|
#import "tree"
|
|
#import "tree_draw"
|
|
|
|
using ButtonTone;
|
|
using StyleField;
|
|
using FrameStatus;
|
|
|
|
#program_export
|
|
Answer :: () -> s32 {
|
|
props: ProgressProps
|
|
props.bounds = Rectangle.{10.0, 20.0, 100.0, 20.0}
|
|
props.min = 0
|
|
props.max = 100
|
|
props.value = 25
|
|
props.label = "50%"
|
|
props.class_name = 7
|
|
defaults: ProgressFaces
|
|
defaults.scale = 1.0
|
|
defaults.fallback_font = 16
|
|
rules: StyleRules
|
|
rules.count = 320
|
|
track: StyleRule
|
|
track.selector = StyleDefaultSelector()
|
|
track.selector.kind = StyleKindProgress()
|
|
track.selector.class_name = 7
|
|
track.selector.role = ProgressTrackRole()
|
|
track.selector.tone = cast(s32)ButtonToneNeutral
|
|
track.style.fields = cast(u32)StyleBackground | cast(u32)StyleBorder |
|
|
cast(u32)StyleBorderWidth | cast(u32)StyleRadius
|
|
track.style.background = cast(u32)0x11223344
|
|
track.style.border = cast(u32)0x99aabbcc
|
|
track.style.border_width = 2.0
|
|
track.style.radius = 5.0
|
|
rules.items[0] = track
|
|
filled: StyleRule
|
|
filled.selector = StyleDefaultSelector()
|
|
filled.selector.kind = StyleKindProgress()
|
|
filled.selector.class_name = 7
|
|
filled.selector.role = ProgressFillRole()
|
|
filled.selector.tone = cast(s32)ButtonToneAccent
|
|
filled.style.fields = cast(u32)StyleBackground
|
|
filled.style.background = cast(u32)0x55667788
|
|
rules.items[1] = filled
|
|
label: StyleRule
|
|
label.selector = StyleDefaultSelector()
|
|
label.selector.kind = StyleKindProgress()
|
|
label.selector.class_name = 7
|
|
label.selector.role = ProgressLabelRole()
|
|
label.selector.tone = cast(s32)ButtonToneNeutral
|
|
label.style.fields = cast(u32)StyleForeground | cast(u32)StyleFontSize |
|
|
cast(u32)StyleOpacity | cast(u32)StyleTypeface
|
|
label.style.foreground = cast(u32)0x10203080
|
|
label.style.font_size = 14.0
|
|
label.style.opacity = 0.5
|
|
label.style.typeface = "body"
|
|
rules.items[2] = label
|
|
ignored: StyleRule = track
|
|
ignored.selector.class_name = 99
|
|
ignored.layer = 100
|
|
ignored.style.background = cast(u32)0xdeadbeef
|
|
rules.items[3] = ignored
|
|
InstallStyleRules(rules)
|
|
faces: ProgressFaces = ProgressFacesFor(props.class_name, defaults)
|
|
if faces.track.value.background != cast(u32)0x11223344 ||
|
|
faces.fill.value.background != cast(u32)0x55667788 ||
|
|
faces.label.value.font_size != 14.0 { return 0 }
|
|
props.key = cast(u64)17
|
|
BeginFrame(TestSession(), cast(u64)10, Rectangle.{0.0, 0.0, 200.0, 100.0})
|
|
Progress(TestSession(), props)
|
|
if EndFrame(TestSession()) != cast(FrameStatus)FrameOk || TreeCount(TestSession()) != 2 { return 0 }
|
|
props.value = 0
|
|
props.label = ""
|
|
rules.count = 0
|
|
defaults.track.value.background = cast(u32)0x11223344
|
|
defaults.track.value.radius = 5.0
|
|
prepared: PreparedProgress = PrepareProgress(props, defaults)
|
|
if prepared.font != 16 || prepared.paint.layout.fill_bounds.width != 0.0 {
|
|
return 0
|
|
}
|
|
InstallStyleRules(rules)
|
|
PaintProgressProps(TestSession(), props,
|
|
ProgressFacesFor(props.class_name, defaults))
|
|
return 42
|
|
}
|