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
55
56
57
58
59
60
61
62
63
64
65
66
67
use crate::{Canvas, Data, Point, Rect};
pub mod annotate {
use crate::prelude::*;
use crate::{Canvas, Data, Point, Rect};
use skia_bindings::{
SkAnnotateLinkToDestination, SkAnnotateNamedDestination, SkAnnotateRectWithURL,
};
pub fn rect_with_url(canvas: &mut Canvas, rect: impl AsRef<Rect>, data: &Data) {
unsafe {
SkAnnotateRectWithURL(
canvas.native_mut(),
rect.as_ref().native(),
data.native_mut_force(),
)
}
}
pub fn named_destination(canvas: &mut Canvas, point: impl Into<Point>, data: &Data) {
unsafe {
SkAnnotateNamedDestination(
canvas.native_mut(),
point.into().native(),
data.native_mut_force(),
)
}
}
pub fn link_to_destination(canvas: &mut Canvas, rect: impl AsRef<Rect>, data: &Data) {
unsafe {
SkAnnotateLinkToDestination(
canvas.native_mut(),
rect.as_ref().native(),
data.native_mut_force(),
)
}
}
}
impl Canvas {
pub fn annotate_rect_with_url(&mut self, rect: impl AsRef<Rect>, data: &Data) -> &mut Self {
annotate::rect_with_url(self, rect, data);
self
}
pub fn annotate_named_destination(
&mut self,
point: impl Into<Point>,
data: &Data,
) -> &mut Self {
annotate::named_destination(self, point, data);
self
}
pub fn annotate_link_to_destination(
&mut self,
rect: impl AsRef<Rect>,
data: &Data,
) -> &mut Self {
annotate::link_to_destination(self, rect, data);
self
}
}