aboutsummaryrefslogtreecommitdiff
path: root/kscurses/ui/parent.jai
blob: af459de3401c29fa12ebce47f79c5b6c3eb84d7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
UI_Parent :: struct {
	#as using base : UI_Elem;
	active_element : *UI_Elem;
}

__last_set : *UI_Elem;

set_active_recursive :: (ui_elem : *UI_Elem) {
	assert(!__last_set); __last_set = ui_elem;
	assert(ui_elem.cursor_state == .OUTSIDE); ui_elem.cursor_state = .ON;

	current := ui_elem;
	while 1 {
		parent := current.parent;
		if !parent break;
		assert(!parent.active_element);
		parent.active_element = current;
		current = xx parent;
	}
}
unset_active_recursive :: (ui_elem : *UI_Elem) {
	assert(__last_set == ui_elem); __last_set = null;
	assert(ui_elem.cursor_state == .ON); ui_elem.cursor_state = .OUTSIDE;

	current := ui_elem;
	while 1 {
		parent := current.parent;
		if !parent break;
		assert(parent.active_element == current);
		parent.active_element = null;
		current = xx parent;
	}
}