Add retained TreeView activation and expansion events
This commit is contained in:
1 parent
696d62ea8c
commit
8b703a33c7
5 files changed
+292
-26
No files matched your search
@@ -22,26 +22,16 @@ KANBAN_BINDS := $(subst tree_view_host,kanban_host,$(BINDS)) \
|
||||
|
||||
TABLE_BINDS := $(subst tree_view_host,table_view_host,$(BINDS))
|
||||
|
||||
.PHONY: check check-table check-table-native clean
|
||||
.PHONY: check check-tree check-tree-native check-table check-table-native clean
|
||||
|
||||
check: check-table
|
||||
check: check-table check-tree
|
||||
$(ZIRAN) check --project
|
||||
$(ZIRAN) check --project src/table_view_laws.zi
|
||||
$(ZIRAN) check --project src/tree_view_laws.zi
|
||||
$(ZIRAN) bundle --project $(BINDS) --entry tree_view_behavior:main \
|
||||
-o $(BUILD)/tree-view.zx tests/tree_view_behavior.zi
|
||||
test "$$($(ZIRAN) run --project $(BUILD)/tree-view.zx)" = 0
|
||||
|
||||
$(ZIRAN) bundle --project $(KANBAN_BINDS) --entry kanban_behavior:main \
|
||||
-o $(BUILD)/kanban.zx tests/kanban_behavior.zi
|
||||
test "$$($(ZIRAN) run --project $(BUILD)/kanban.zx)" = 0
|
||||
@if command -v go >/dev/null; then \
|
||||
rm -rf $(BUILD)/tree-view-go && \
|
||||
$(ZIRAN) build --project --target=go --pkg main --exe $(BINDS) \
|
||||
--entry tree_view_behavior:main -o $(BUILD)/tree-view-go \
|
||||
tests/tree_view_behavior.zi && \
|
||||
cd $(BUILD)/tree-view-go && env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
GO111MODULE=off go run *.go ; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD)
|
||||
@@ -75,3 +65,23 @@ check-table: check-table-native
|
||||
cd $(BUILD)/table-render-go && env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
GO111MODULE=off go run *.go ; \
|
||||
fi
|
||||
|
||||
check-tree: check-tree-native
|
||||
$(ZIRAN) bundle --project $(BINDS) --entry tree_view_behavior:main \
|
||||
-o $(BUILD)/tree-view.zx tests/tree_view_behavior.zi
|
||||
test "$$($(ZIRAN) run --project $(BUILD)/tree-view.zx)" = 0
|
||||
@if command -v go >/dev/null; then \
|
||||
rm -rf $(BUILD)/tree-view-go && \
|
||||
$(ZIRAN) build --project --target=go --pkg main --exe $(BINDS) \
|
||||
--entry tree_view_behavior:main -o $(BUILD)/tree-view-go \
|
||||
tests/tree_view_behavior.zi && \
|
||||
cd $(BUILD)/tree-view-go && env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
GO111MODULE=off go run *.go ; \
|
||||
fi
|
||||
|
||||
check-tree-native:
|
||||
$(ZIRAN) build --project --target=c --exe $(BINDS) --entry tree_view_behavior:main -o $(BUILD)/tree-behavior-c tests/tree_view_behavior.zi
|
||||
$(BUILD)/tree-behavior-c/tree_view_behavior
|
||||
$(ZIRAN) ir --project $(BINDS) --entry tree_view_behavior:main -o $(BUILD)/tree-behavior-ir tests/tree_view_behavior.zi
|
||||
$(ZIRAN) build --project --target=c --exe --entry tree_view_behavior:main -o $(BUILD)/tree-behavior-saved-c $(BUILD)/tree-behavior-ir/tree_view_behavior.zir
|
||||
$(BUILD)/tree-behavior-saved-c/tree_view_behavior
|
||||
@@ -67,6 +67,34 @@ from row and column indices, so the caller must reorder/remap selection,
|
||||
focus and anchor together when sorting, filtering or replacing rows.
|
||||
TableView never sorts or retains borrowed application data.
|
||||
|
||||
`Trees.TreeView(session, props, items)` takes a borrowed visible preorder slice of
|
||||
`TreeItem` values. Keep unique positive item IDs and a stable view key across
|
||||
frames; IDs survive reordering. Nonpositive IDs retain legacy index-based
|
||||
retained identity and selection, but never report event identities.
|
||||
|
||||
`TreeViewResult.activated_id` reports each accepted row click, including a
|
||||
repeat click on the selected row. `toggled_id` requests expansion/collapse.
|
||||
Both are `s32`, reset to `0` each call, and are independent of `changed`, which
|
||||
still means only `selected_id != props.selected_id`. A clipped disclosure-marker
|
||||
click reports only `toggled_id`: it does not select or activate the row. Disabled
|
||||
views and nonselectable items accept neither event. Set `TreeItem.leaf = true`
|
||||
to hide disclosure and suppress toggle requests; its default `false` preserves
|
||||
existing callers, including callers with unloaded children. Leaf rows remain
|
||||
selectable and their whole-row click still reports activation.
|
||||
|
||||
Set `TreeViewProps.focused` and pass one `navigation: TreeViewNavigation`
|
||||
request per call. Home/End/Up/Down retain their selection behavior. Right (enum
|
||||
value 6) on a collapsed nonleaf requests a toggle; on an expanded nonleaf it
|
||||
selects the first selectable direct visible child (depth exactly parent + 1),
|
||||
without skipping into grandchildren. Left (value 5) on an expanded nonleaf
|
||||
requests a toggle; otherwise it selects the nearest preceding shallower row,
|
||||
if that structural parent is selectable. Missing selection, missing targets,
|
||||
unfocused/disabled views, and nonselectable current rows produce no Left/Right
|
||||
action. Leaf Right does nothing, even if `expanded` is true. Keyboard navigation
|
||||
reveals its selected target, never reports activation, and never mutates items.
|
||||
The caller updates `expanded`, builds the visible slice, and decides leaf,
|
||||
loading, filesystem and activation policy. No children are inferred or loaded.
|
||||
|
||||
Kanban cells share the vanilla renderer. Keep one `Kanban.KanbanCell` per board and
|
||||
derive its `Kanban.KanbanConfig` from `Kanban.KanbanDefaults(key, lane_count)`. The cell owns
|
||||
its horizontal offset, each column's scrolling and drag state. Call `BeginKanban`,
|
||||
@@ -83,7 +111,7 @@ a Jobs card cannot authorize an application. Those rules stay with the caller.
|
||||
## Develop
|
||||
|
||||
`make check` checks the package and runs the behavior tests as portable
|
||||
bundles, plus the table behavior and rendered interaction tests as native C
|
||||
bundles, plus the tree and table behavior and rendered interaction tests as native C
|
||||
from source and saved checked IR, and in Go when `go` is installed. It uses the `ziran` launcher and
|
||||
the Ziran and Kryon commits pinned in `ziran.lock`. To test against local
|
||||
checkouts, keep this in an ignored `ziran.local.toml`:
|
||||
@@ -95,7 +123,8 @@ kryon = "../../kryon"
|
||||
```
|
||||
|
||||
|
||||
Run `build-queue -- make check-table` for the focused table tests or
|
||||
Run `build-queue -- make -j1 check-tree` for the focused tree tests,
|
||||
`build-queue -- make check-table` for the focused table tests or
|
||||
`build-queue -- make check` for the package suite. The rendered tests use
|
||||
an in-process raster host that checks clipping and paint operations; they do
|
||||
not open desktop windows.
|
||||
+63
-4
@@ -222,6 +222,11 @@ TreeViewRowKey :: (item: TreeItem, index: s32) -> u64 {
|
||||
return cast(u64)4294967296 + cast(u64)cast(u32)(index + 1)
|
||||
}
|
||||
|
||||
// Disjoint from positive row IDs, synthetic row keys, and scrollbar keys.
|
||||
TreeViewMarkerKey :: (item: TreeItem, index: s32) -> u64 {
|
||||
return cast(u64)8589934592 + TreeViewRowKey(item, index)
|
||||
}
|
||||
|
||||
#program_export
|
||||
TreeViewFace :: (kind: s32, name: s32, class_name: s32,
|
||||
state: s32) -> StyleFrame {
|
||||
@@ -310,6 +315,30 @@ TreeViewNavigationIndex :: (items: []TreeItem, selected_id: s32,
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
if navigation == cast(TreeViewNavigation)TreeViewNavigationLeft ||
|
||||
navigation == cast(TreeViewNavigation)TreeViewNavigationRight {
|
||||
if current < 0 || !items[current].selectable { return -1 }
|
||||
if navigation == cast(TreeViewNavigation)TreeViewNavigationLeft {
|
||||
if items[current].expanded && !items[current].leaf { return -1 }
|
||||
candidate: s32 = current - 1
|
||||
while candidate >= 0 {
|
||||
if items[candidate].depth < items[current].depth {
|
||||
if items[candidate].selectable { return candidate }
|
||||
return -1
|
||||
}
|
||||
candidate -= 1
|
||||
}
|
||||
} else if items[current].expanded && !items[current].leaf {
|
||||
candidate: s32 = current + 1
|
||||
while candidate < cast(s32)items.count &&
|
||||
items[candidate].depth > items[current].depth {
|
||||
if items[candidate].depth == items[current].depth + 1 &&
|
||||
items[candidate].selectable { return candidate }
|
||||
candidate += 1
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
direction: s32 = 1
|
||||
candidate: s32 = 0
|
||||
if navigation == cast(TreeViewNavigation)TreeViewNavigationEnd {
|
||||
@@ -411,6 +440,19 @@ TreeView :: (session: Session, props: TreeViewProps, items: []TreeItem) -> TreeV
|
||||
}
|
||||
}
|
||||
if props.focused && !props.disabled {
|
||||
index: s32 = 0
|
||||
while index < cast(s32)items.count {
|
||||
item: TreeItem = items[index]
|
||||
if item.id == result.selected_id {
|
||||
if item.id > 0 && item.selectable && !item.leaf &&
|
||||
((props.navigation == cast(TreeViewNavigation)TreeViewNavigationRight && !item.expanded) ||
|
||||
(props.navigation == cast(TreeViewNavigation)TreeViewNavigationLeft && item.expanded)) {
|
||||
result.toggled_id = item.id
|
||||
}
|
||||
break
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
selected_index: s32 = TreeViewNavigationIndex(items,
|
||||
result.selected_id, props.navigation)
|
||||
if selected_index >= 0 {
|
||||
@@ -443,19 +485,24 @@ TreeView :: (session: Session, props: TreeViewProps, items: []TreeItem) -> TreeV
|
||||
if clipped.height > 0.0 && clipped.width > 0.0 {
|
||||
item_key: u64 = TreeViewRowKey(item, index)
|
||||
previous: s32 = -1
|
||||
previous_marker: s32 = -1
|
||||
if TreeIsBuilding(session) {
|
||||
previous = TreePrevious(session, result.node, item_key,
|
||||
WidgetKindSelectable)
|
||||
previous_marker = TreePrevious(session, result.node,
|
||||
TreeViewMarkerKey(item, index), WidgetKindSelectable)
|
||||
}
|
||||
activated: bool = TreeTakeActivationAt(session, previous)
|
||||
if activated && !props.disabled && item.selectable {
|
||||
result.changed = result.selected_id != item.id
|
||||
result.selected_id = item.id
|
||||
if item.id > 0 { result.activated_id = item.id }
|
||||
}
|
||||
selected: bool = result.selected_id == item.id
|
||||
state: s32 = ResolveState(cast(s32)ButtonStateAuto,
|
||||
props.disabled || !item.selectable, false,
|
||||
TreePressedAt(session, previous), TreeHoveredAt(session, previous),
|
||||
TreePressedAt(session, previous) || TreePressedAt(session, previous_marker),
|
||||
TreeHoveredAt(session, previous) || TreeHoveredAt(session, previous_marker),
|
||||
false, selected)
|
||||
face: StyleFrame = TreeViewFace(StyleKindTreeViewItem(),
|
||||
item.id, props.class_name, state)
|
||||
@@ -489,9 +536,21 @@ TreeView :: (session: Session, props: TreeViewProps, items: []TreeItem) -> TreeV
|
||||
face.value.foreground, item_opacity))
|
||||
marker_clip: Rectangle = RectangleIntersection(marker, bounds)
|
||||
label_clip: Rectangle = RectangleIntersection(label, bounds)
|
||||
PaintClippedLabel(session, node, TreeViewMarkerText(item.expanded),
|
||||
paint.marker_x, paint.marker_y, font, text_color,
|
||||
marker_clip)
|
||||
if !item.leaf && TreeIsBuilding(session) && marker_clip.width > 0.0 && marker_clip.height > 0.0 {
|
||||
marker_key: u64 = TreeViewMarkerKey(item, index)
|
||||
if TreeTakeActivationAt(session, previous_marker) &&
|
||||
!props.disabled && item.selectable && item.id > 0 {
|
||||
result.toggled_id = item.id
|
||||
}
|
||||
marker_node: s32 = TreeSubmitCurrent(session, marker_key,
|
||||
WidgetKindSelectable, marker_clip)
|
||||
TreeSetInteractive(session, marker_node,
|
||||
props.disabled || !item.selectable, false, item.id)
|
||||
}
|
||||
if !item.leaf {
|
||||
PaintClippedLabel(session, node, TreeViewMarkerText(item.expanded),
|
||||
paint.marker_x, paint.marker_y, font, text_color, marker_clip)
|
||||
}
|
||||
PaintClippedLabel(session, node, item.label, paint.text_x,
|
||||
paint.text_y, font, text_color, label_clip)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ TreeItem :: struct {
|
||||
id: s32
|
||||
expanded: bool
|
||||
selectable: bool
|
||||
// False preserves disclosure behavior; true hides the marker and disables toggles.
|
||||
leaf: bool
|
||||
}
|
||||
|
||||
TreeViewNavigation :: enum {
|
||||
@@ -14,6 +16,8 @@ TreeViewNavigation :: enum {
|
||||
TreeViewNavigationEnd :: 2
|
||||
TreeViewNavigationUp :: 3
|
||||
TreeViewNavigationDown :: 4
|
||||
TreeViewNavigationLeft :: 5
|
||||
TreeViewNavigationRight :: 6
|
||||
}
|
||||
|
||||
// Items are a borrowed slice passed to TreeView, not a pointer in this record.
|
||||
@@ -38,4 +42,7 @@ TreeViewResult :: struct {
|
||||
selected_id: s32
|
||||
scroll_offset: s32
|
||||
changed: bool
|
||||
// Per-call positive item identities; zero means no event.
|
||||
activated_id: s32
|
||||
toggled_id: s32
|
||||
}
|
||||
+168
-7
@@ -60,15 +60,15 @@ Frame :: () -> s32 {
|
||||
}
|
||||
TreeStart(TestSession(), cast(u64)1, Rectangle.{0.0, 0.0, 160.0, 100.0})
|
||||
result: TreeViewResult = TreeView(TestSession(), props, items[0:3])
|
||||
if !TreeFinish(TestSession()) || TreeCount(TestSession()) != 7 || result.node != 1 ||
|
||||
if !TreeFinish(TestSession()) || TreeCount(TestSession()) != 10 || result.node != 1 ||
|
||||
TreeNodeAt(TestSession(), 1).semantic_kind != cast(SemanticKind)SemanticTree ||
|
||||
TreeNodeAt(TestSession(), 3).semantic_kind != cast(SemanticKind)SemanticTreeItem ||
|
||||
TreeNodeAt(TestSession(), 3).semantic_label != "Second" ||
|
||||
TreeNodeAt(TestSession(), 6).kind != WidgetKindSlider { return -10 }
|
||||
TreeNodeAt(TestSession(), 4).semantic_kind != cast(SemanticKind)SemanticTreeItem ||
|
||||
TreeNodeAt(TestSession(), 4).semantic_label != "Second" ||
|
||||
TreeNodeAt(TestSession(), 9).kind != WidgetKindSlider { return -10 }
|
||||
if phase == 0 {
|
||||
if result.selected_id != 1 || result.changed ||
|
||||
result.scroll_offset != 0 ||
|
||||
TreeNodeAt(TestSession(), 4).bounds.height != 8.0 ||
|
||||
TreeNodeAt(TestSession(), 6).bounds.height != 8.0 ||
|
||||
TreeHitAt(TestSession(), 20.0, 59.0) != -1 { return -1 }
|
||||
TreePointerUpdate(TestSession(), PointerFrame.{20.0, 35.0, true, true, false})
|
||||
TreePointerUpdate(TestSession(), PointerFrame.{20.0, 35.0, false, false, true})
|
||||
@@ -84,8 +84,8 @@ Frame :: () -> s32 {
|
||||
TreeHitAt(TestSession(), 20.0, 25.0) != -1 { return -3 }
|
||||
} else if phase == 3 {
|
||||
if result.selected_id != 2 || result.scroll_offset != 0 ||
|
||||
TreeNodeAt(TestSession(), 6).bounds.y != 10.0 ||
|
||||
TreeHitAt(TestSession(), 126.0, 20.0) != 6 { return -4 }
|
||||
TreeNodeAt(TestSession(), 9).bounds.y != 10.0 ||
|
||||
TreeHitAt(TestSession(), 126.0, 20.0) != 9 { return -4 }
|
||||
TreePointerUpdate(TestSession(), PointerFrame.{126.0, 20.0, true, true, false})
|
||||
TreePointerUpdate(TestSession(), PointerFrame.{126.0, 40.0, true, false, false})
|
||||
} else if phase == 4 {
|
||||
@@ -136,5 +136,166 @@ main :: () -> s32 {
|
||||
index += 1
|
||||
}
|
||||
if TreeViewFillCount() < 6 { return 2 }
|
||||
return TreeEvents()
|
||||
}
|
||||
|
||||
// Every event assertion runs the actual retained widget and raster host.
|
||||
EventFrame :: (props: TreeViewProps, items: []TreeItem) -> TreeViewResult {
|
||||
TreeStart(TestSession(), cast(u64)1, Rectangle.{0.0, 0.0, 160.0, 100.0})
|
||||
result := TreeView(TestSession(), props, items)
|
||||
if !TreeFinish(TestSession()) { result.node = -1 }
|
||||
PaintFlush(TestSession())
|
||||
return result
|
||||
}
|
||||
|
||||
EventClick :: (x: float32, y: float32) {
|
||||
TreePointerUpdate(TestSession(), PointerFrame.{x, y, true, true, false})
|
||||
TreePointerUpdate(TestSession(), PointerFrame.{x, y, false, false, true})
|
||||
}
|
||||
|
||||
EventIs :: (r: TreeViewResult, selected_id: s32, activated: s32,
|
||||
toggled: s32, changed: bool) -> bool {
|
||||
return r.node >= 0 && r.selected_id == selected_id &&
|
||||
r.activated_id == activated && r.toggled_id == toggled &&
|
||||
r.changed == changed && !TreeViewHostFailed()
|
||||
}
|
||||
|
||||
TreeEvents :: () -> s32 {
|
||||
items: [3]TreeItem
|
||||
items[0] = TreeItem.{"Parent", 0, 101, false, true}
|
||||
items[1] = TreeItem.{"Child", 1, 202, false, true}
|
||||
items[2] = TreeItem.{"Grandchild", 2, 303, false, true}
|
||||
p: TreeViewProps
|
||||
p.key = cast(u64)200
|
||||
p.bounds = Rectangle.{10.0, 10.0, 120.0, 48.0}
|
||||
p.row_height = 20
|
||||
p.selected_id = 202
|
||||
r := EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 20 }
|
||||
// Marker wins over the whole-row hit, without selecting the parent.
|
||||
if TreeHitAt(TestSession(), 20.0, 15.0) != 3 { return 21 }
|
||||
EventClick(20.0, 15.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 101, false) { return 22 }
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 23 }
|
||||
EventClick(100.0, 35.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 202, 0, false) { return 24 }
|
||||
EventClick(100.0, 15.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 101, 101, 0, true) { return 25 }
|
||||
// Scrolled marker/row regions are clipped on both viewport edges.
|
||||
p.scroll_offset = 12
|
||||
r = EventFrame(p, items[:])
|
||||
if TreeNodeAt(TestSession(), 3).bounds.height != 8.0 ||
|
||||
TreeHitAt(TestSession(), 20.0, 9.0) != -1 ||
|
||||
TreeHitAt(TestSession(), 60.0, 59.0) != -1 { return 26 }
|
||||
EventClick(20.0, 11.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 101, false) { return 27 }
|
||||
EventClick(100.0, 11.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 101, 101, 0, true) { return 28 }
|
||||
EventClick(20.0, 9.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 29 }
|
||||
p.disabled = true
|
||||
r = EventFrame(p, items[:])
|
||||
EventClick(20.0, 11.0)
|
||||
p.focused = true
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationRight
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 30 }
|
||||
p.disabled = false
|
||||
p.focused = false
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 31 }
|
||||
p.focused = true
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 202, false) { return 32 }
|
||||
items[1].expanded = true
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 303, 0, 0, true) || r.scroll_offset != 12 { return 33 }
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationLeft
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 202, false) { return 34 }
|
||||
items[1].expanded = false
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 101, 0, 0, true) || r.scroll_offset != 0 { return 35 }
|
||||
items[0].selectable = false
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 36 }
|
||||
items[1].selectable = false
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationRight
|
||||
r = EventFrame(p, items[:])
|
||||
EventClick(40.0, 25.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 37 }
|
||||
// A pending row release follows its stable ID across reordering.
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationNone
|
||||
items[0].selectable = true
|
||||
items[1].selectable = true
|
||||
r = EventFrame(p, items[:])
|
||||
EventClick(100.0, 11.0)
|
||||
swap := items[0]
|
||||
items[0] = items[1]
|
||||
items[1] = swap
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 101, 101, 0, true) { return 38 }
|
||||
// Nonpositive IDs retain legacy selection, but never become event IDs.
|
||||
items[0].id = -7
|
||||
r = EventFrame(p, items[:])
|
||||
EventClick(100.0, 11.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, -7, 0, 0, true) { return 39 }
|
||||
EventClick(40.0, 11.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 0, false) { return 40 }
|
||||
// Marker identity also follows a row across reordering.
|
||||
items[0] = TreeItem.{"Parent", 0, 101, true, true}
|
||||
items[1] = TreeItem.{"Child", 1, 202, false, true}
|
||||
items[2] = TreeItem.{"Grandchild", 2, 303, false, true}
|
||||
p.selected_id = 202
|
||||
r = EventFrame(p, items[:])
|
||||
EventClick(20.0, 11.0)
|
||||
swap = items[0]
|
||||
items[0] = items[1]
|
||||
items[1] = swap
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 202, 0, 101, false) { return 44 }
|
||||
items[0] = TreeItem.{"Parent", 0, 101, true, true}
|
||||
items[1] = TreeItem.{"Child", 1, 202, true, false}
|
||||
p.selected_id = 101
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationRight
|
||||
r = EventFrame(p, items[:])
|
||||
// A grandchild is not a substitute for an ineligible direct child.
|
||||
if !EventIs(r, 101, 0, 0, false) { return 45 }
|
||||
p.selected_id = 303
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationLeft
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 303, 0, 0, false) { return 46 }
|
||||
p.selected_id = 999
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 999, 0, 0, false) { return 47 }
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationRight
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 999, 0, 0, false) { return 48 }
|
||||
items[1].selectable = true
|
||||
items[0] = TreeItem.{"Leaf", 0, 101, true, true}
|
||||
items[0].leaf = true
|
||||
p.selected_id = 101
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationRight
|
||||
labels_before := TreeViewLabelCount()
|
||||
r = EventFrame(p, items[:])
|
||||
if TreeViewLabelCount() != labels_before + 5 { return 49 }
|
||||
if !EventIs(r, 101, 0, 0, false) ||
|
||||
TreeHitAt(TestSession(), 20.0, 11.0) != 2 { return 41 }
|
||||
EventClick(20.0, 11.0)
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 101, 101, 0, false) { return 42 }
|
||||
p.navigation = cast(TreeViewNavigation)TreeViewNavigationLeft
|
||||
r = EventFrame(p, items[:])
|
||||
if !EventIs(r, 101, 0, 0, false) { return 43 }
|
||||
return 0
|
||||
}
|
||||
Reference in new issue
Block a user