forked from vlang/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui_widget.v
40 lines (34 loc) · 873 Bytes
/
ui_widget.v
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
34
35
36
37
38
39
40
module ui
pub fn get_depth(w &Widget) int {
return w.z_index
}
pub fn set_depth(mut w Widget, z_index int) {
w.z_index = z_index
// w.set_visible(z_index != ui.z_index_hidden)
}
pub fn (child &Widget) id() string {
return child.id
}
pub fn (w &Window) is_registred(widget &Widget) bool {
return widget.id in w.widgets
}
pub fn (l &Layout) has_child_id(widget_id string) bool {
// println("has_child_id children: ${l.get_children().len} => ${l.get_children().map(it.id)}")
for child in l.get_children() {
// println("has_child: <$child.id> == <$widget_id>")
if child.id == widget_id {
return true
}
if child is Layout {
// println("$child.id is layout")
l2 := child as Layout
if l2.has_child_id(widget_id) {
return true
}
}
}
return false
}
pub fn (l &Layout) has_child(widget &Widget) bool {
return l.has_child_id(widget.id)
}