-
Notifications
You must be signed in to change notification settings - Fork 10
/
zindex.v
44 lines (40 loc) · 1.25 KB
/
zindex.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
41
42
43
44
module mui
fn raw_map_string_into_map(raw_list string) map[string]int {
mut list:=map[string]int{}
list_split:=raw_list.split("#")
for w in 0..raw_list.len {
item_split:=list_split[w].split("|")
list[item_split[0]]=item_split[1].int()
}
return list
}
@[unsafe]
fn sort_widgets_with_zindex_fn(a &map[string]WindowData, b &map[string]WindowData) int {
unsafe {
mut static frame_list_raw := "" // maps not supported by static, but string supports "frame|14#frame2|25" => {"frame":14, "frame2":25}
mut frame_list := raw_map_string_into_map(frame_list_raw)
if a["type"].str=="frame" {
frame_list[a["id"].str]=a["z_ind"].num
}
a_zindex:=if a["in"].str=="" {
a["z_ind"].num
} else {
frame_list[a["in"].str]+a["z-index"].num+1
}
b_zindex:=if b["in"].str=="" {
b["z_ind"].num
} else {
frame_list[b["in"].str]+b["z-index"].num+1
}
if a_zindex > b_zindex {
return 1
}
if a_zindex < b_zindex {
return -1
}
return 0
}
}
pub fn (mut app Window) sort_widgets_with_zindex(){
app.objects.sort_with_compare(sort_widgets_with_zindex_fn)
}