#import "session" test_session: Session; TestSession :: () -> Session { if !SessionValid(test_session) { test_session = SessionOpen() } return test_session } #import "control_props" #import "geometry" #import "selectable" #import "selectable_props" #import "selectable_widget" #import "style" #import "style_sheet" #import "tree" #import "tree_draw" #import "tree_input" #import "widget_kind" using WidgetKind; using StyleField; using FrameStatus; phase: s32; #program_export Frame :: () -> s32 { props: SelectableProps props.key = cast(u64)7 props.id = 7 props.class_name = 9 props.bounds = Rectangle.{10.0, 20.0, 100.0, 36.0} props.label = "Alpha" if phase == 2 { props.selected = true } if phase == 3 { props.disabled = true } if phase == 0 { rules: StyleRules rules.count = 1 rule: StyleRule rule.selector = StyleDefaultSelector() rule.selector.kind = StyleKindSelectable() rule.selector.class_name = 9 rule.style.fields = cast(u32)StyleBackground | cast(u32)StyleForeground rule.style.background = cast(u32)0x123456ff rule.style.foreground = cast(u32)0xaabbccff rules.items[0] = rule InstallStyleRules(rules) } BeginFrame(TestSession(), cast(u64)1, Rectangle.{0.0, 0.0, 140.0, 80.0}) result: SelectableToggleResult = Selectable(TestSession(), props) if EndFrame(TestSession()) != cast(FrameStatus)FrameOk || TreeCount(TestSession()) != 2 || TreeNodeAt(TestSession(), 1).kind != WidgetKindSelectable || TreeNodeAt(TestSession(), 1).semantic_label != "Alpha" || TreeNodeAt(TestSession(), 1).selected != result.selected { return -10 } if phase == 0 { if result.selected || result.changed { return -1 } TreePointerUpdate(TestSession(), PointerFrame.{50.0, 38.0, true, true, false}) TreePointerUpdate(TestSession(), PointerFrame.{50.0, 38.0, false, false, true}) } else if phase == 1 { if !result.selected || !result.changed { return -2 } TreePointerUpdate(TestSession(), PointerFrame.{50.0, 38.0, true, true, false}) TreePointerUpdate(TestSession(), PointerFrame.{50.0, 38.0, false, false, true}) } else if phase == 2 { if result.selected || !result.changed { return -3 } } else { if result.selected || result.changed || TreeHitAt(TestSession(), 50.0, 38.0) != -1 { return -4 } } old: s32 = phase phase += 1 return old }