-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathtool_coordinates.v
More file actions
51 lines (45 loc) · 1.03 KB
/
tool_coordinates.v
File metadata and controls
51 lines (45 loc) · 1.03 KB
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
45
46
47
48
49
50
51
module ui
// allow to specify widgets with absolute coordinates (CanvasLayout and Window)
pub fn at(x int, y int, w Widget) Widget {
mut w2 := w
w2.x, w2.y = x, y
return w2
}
// on top_layer
pub fn on_top_at(x int, y int, w Widget) Widget {
mut w2 := w
w2.x, w2.y = x, y
w2.id = w2.id + id_append_top_layer // to detect
return w2
}
fn offset_start(mut w Widget) {
w.x += w.offset_x
w.y += w.offset_y
}
fn offset_end(mut w Widget) {
w.x -= w.offset_x
w.y -= w.offset_y
}
//**** offset ****
// set offset_x and offset_y for Widget
pub fn set_offset(mut w Widget, ox int, oy int) {
w.offset_x, w.offset_y = ox, oy
if mut w is Layout {
for mut child in w.get_children() {
set_offset(mut child, ox, oy)
}
}
// if mut w is Stack {
// for mut child in w.children {
// set_offset(mut child, ox, oy)
// }
//} else if mut w is Group {
// for mut child in w.children {
// set_offset(mut child, ox, oy)
// }
//} else if mut w is CanvasLayout {
// for mut child in w.children {
// set_offset(mut child, ox, oy)
// }
//}
}