Skip to content

Commit eec9bcb

Browse files
gsk: Generate PathMeasure
1 parent 6288f51 commit eec9bcb

File tree

6 files changed

+97
-6
lines changed

6 files changed

+97
-6
lines changed

gsk4/Gir.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ status = "generate"
181181
name = "add_cairo_path"
182182
manual = true # use as_ptr for cairo::Path
183183

184+
[[object]]
185+
name = "Gsk.PathMeasure"
186+
status = "generate"
187+
version = "4.14"
188+
184189
[[object]]
185190
name = "Gsk.PathPoint"
186191
status = "generate"

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

88
glib::wrapper! {
@@ -31,11 +31,11 @@ impl PathPoint {
3131
}
3232
}
3333

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

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

gsk4/sys/Gir.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ cfg_condition = "feature = \"broadway\""
2626
pattern = "(new|get_type)"
2727
cfg_condition = "feature = \"broadway\""
2828

29+
[[object]]
30+
name = "Gsk.PathMeasure"
31+
status = "generate"
32+
version = "4.14"
2933

3034
[[object]]
3135
name = "Gsk.VulkanRenderer"

gsk4/sys/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,8 @@ extern "C" {
12501250
//=========================================================================
12511251
// GskPathMeasure
12521252
//=========================================================================
1253+
#[cfg(feature = "v4_14")]
1254+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
12531255
pub fn gsk_path_measure_get_type() -> GType;
12541256
#[cfg(feature = "v4_14")]
12551257
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]

0 commit comments

Comments
 (0)