Skip to content

Commit 96436d3

Browse files
gsk: Generate PathMeasure
1 parent 853668b commit 96436d3

File tree

4 files changed

+87
-6
lines changed

4 files changed

+87
-6
lines changed

gsk4/Gir.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ generate = [
3838
"Gsk.OutsetShadowNode",
3939
"Gsk.PathDirection",
4040
"Gsk.PathForeachFlags",
41+
"Gsk.PathMeasure",
4142
"Gsk.PathOperation",
4243
"Gsk.RadialGradientNode",
4344
"Gsk.RepeatingLinearGradientNode",

gsk4/src/auto/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ mod path_builder;
148148
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
149149
pub use self::path_builder::PathBuilder;
150150

151+
#[cfg(feature = "v4_14")]
152+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
153+
mod path_measure;
154+
#[cfg(feature = "v4_14")]
155+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
156+
pub use self::path_measure::PathMeasure;
157+
151158
#[cfg(feature = "v4_14")]
152159
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
153160
mod path_point;

gsk4/src/auto/path_measure.rs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
3+
// DO NOT EDIT
4+
5+
use crate::{Path, PathPoint};
6+
use glib::translate::*;
7+
8+
glib::wrapper! {
9+
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
10+
pub struct PathMeasure(Shared<ffi::GskPathMeasure>);
11+
12+
match fn {
13+
ref => |ptr| ffi::gsk_path_measure_ref(ptr),
14+
unref => |ptr| ffi::gsk_path_measure_unref(ptr),
15+
type_ => || ffi::gsk_path_measure_get_type(),
16+
}
17+
}
18+
19+
impl PathMeasure {
20+
#[doc(alias = "gsk_path_measure_new")]
21+
pub fn new(path: &Path) -> PathMeasure {
22+
assert_initialized_main_thread!();
23+
unsafe { from_glib_full(ffi::gsk_path_measure_new(path.to_glib_none().0)) }
24+
}
25+
26+
#[doc(alias = "gsk_path_measure_new_with_tolerance")]
27+
#[doc(alias = "new_with_tolerance")]
28+
pub fn with_tolerance(path: &Path, tolerance: f32) -> PathMeasure {
29+
assert_initialized_main_thread!();
30+
unsafe {
31+
from_glib_full(ffi::gsk_path_measure_new_with_tolerance(
32+
path.to_glib_none().0,
33+
tolerance,
34+
))
35+
}
36+
}
37+
38+
#[doc(alias = "gsk_path_measure_get_length")]
39+
#[doc(alias = "get_length")]
40+
pub fn length(&self) -> f32 {
41+
unsafe { ffi::gsk_path_measure_get_length(self.to_glib_none().0) }
42+
}
43+
44+
#[doc(alias = "gsk_path_measure_get_path")]
45+
#[doc(alias = "get_path")]
46+
pub fn path(&self) -> Path {
47+
unsafe { from_glib_none(ffi::gsk_path_measure_get_path(self.to_glib_none().0)) }
48+
}
49+
50+
#[doc(alias = "gsk_path_measure_get_point")]
51+
#[doc(alias = "get_point")]
52+
pub fn point(&self, distance: f32) -> Option<PathPoint> {
53+
unsafe {
54+
let mut result = PathPoint::uninitialized();
55+
let ret = from_glib(ffi::gsk_path_measure_get_point(
56+
self.to_glib_none().0,
57+
distance,
58+
result.to_glib_none_mut().0,
59+
));
60+
if ret {
61+
Some(result)
62+
} else {
63+
None
64+
}
65+
}
66+
}
67+
68+
#[doc(alias = "gsk_path_measure_get_tolerance")]
69+
#[doc(alias = "get_tolerance")]
70+
pub fn tolerance(&self) -> f32 {
71+
unsafe { ffi::gsk_path_measure_get_tolerance(self.to_glib_none().0) }
72+
}
73+
}

gsk4/src/auto/path_point.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

5-
use crate::{Path, PathDirection};
5+
use crate::{Path, PathDirection, PathMeasure};
66
use glib::translate::*;
77
use std::cmp;
88

@@ -32,11 +32,11 @@ impl PathPoint {
3232
}
3333
}
3434

35-
//#[doc(alias = "gsk_path_point_get_distance")]
36-
//#[doc(alias = "get_distance")]
37-
//pub fn distance(&self, measure: /*Ignored*/&PathMeasure) -> f32 {
38-
// unsafe { TODO: call ffi:gsk_path_point_get_distance() }
39-
//}
35+
#[doc(alias = "gsk_path_point_get_distance")]
36+
#[doc(alias = "get_distance")]
37+
pub fn distance(&self, measure: &PathMeasure) -> f32 {
38+
unsafe { ffi::gsk_path_point_get_distance(self.to_glib_none().0, measure.to_glib_none().0) }
39+
}
4040

4141
#[doc(alias = "gsk_path_point_get_position")]
4242
#[doc(alias = "get_position")]

0 commit comments

Comments
 (0)