-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathinterface_clipping.v
More file actions
54 lines (50 loc) · 1.02 KB
/
interface_clipping.v
File metadata and controls
54 lines (50 loc) · 1.02 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
52
53
54
module ui
pub interface ClippingWidget {
mut:
clipping bool
width int
height int
x int
y int
}
type ClippingState = Rect
fn clipping_start(c ClippingWidget, mut d DrawDevice) !ClippingState {
if c.clipping {
mut x, mut y := c.x, c.y
if c is ScrollableWidget {
if has_scrollview(c) {
x, y = c.scrollview.orig_xy()
}
}
existing := d.get_clipping()
impose := Rect{
x: x
y: y
w: c.width
h: c.height
}
intersection := existing.intersection(impose)
if intersection.is_empty() {
return error('widget is occluded and can not be drawn')
}
$if clipping_start ? {
if c is ScrollableWidget {
println('clipping start ${c.id} ${intersection} ${existing} ${impose}')
}
}
d.set_clipping(intersection)
return existing
} else {
return ClippingState{}
}
}
fn clipping_end(c ClippingWidget, mut d DrawDevice, s ClippingState) {
if c.clipping {
$if clipping_end ? {
if c is ScrollableWidget {
println('clipping end ${c.id} ${s}')
}
}
d.set_clipping(s)
}
}