diff --git a/gsk4/Gir.toml b/gsk4/Gir.toml index d9ec678e9030..d21a861c1e4e 100644 --- a/gsk4/Gir.toml +++ b/gsk4/Gir.toml @@ -189,6 +189,11 @@ boxed_inline = true name = "get_curvature" manual = true # handle nullable point return value +[[object]] +name = "Gsk.PathMeasure" +status = "generate" +version = "4.14" + [[object]] name = "Gsk.Renderer" status = "generate" diff --git a/gsk4/src/auto/mod.rs b/gsk4/src/auto/mod.rs index ecad39fd8c13..cb7a994c7a65 100644 --- a/gsk4/src/auto/mod.rs +++ b/gsk4/src/auto/mod.rs @@ -148,6 +148,13 @@ mod path_builder; #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))] pub use self::path_builder::PathBuilder; +#[cfg(feature = "v4_14")] +#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))] +mod path_measure; +#[cfg(feature = "v4_14")] +#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))] +pub use self::path_measure::PathMeasure; + #[cfg(feature = "v4_14")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))] mod path_point; diff --git a/gsk4/src/auto/path_measure.rs b/gsk4/src/auto/path_measure.rs new file mode 100644 index 000000000000..0dd308328f23 --- /dev/null +++ b/gsk4/src/auto/path_measure.rs @@ -0,0 +1,73 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{Path, PathPoint}; +use glib::translate::*; + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct PathMeasure(Shared); + + match fn { + ref => |ptr| ffi::gsk_path_measure_ref(ptr), + unref => |ptr| ffi::gsk_path_measure_unref(ptr), + type_ => || ffi::gsk_path_measure_get_type(), + } +} + +impl PathMeasure { + #[doc(alias = "gsk_path_measure_new")] + pub fn new(path: &Path) -> PathMeasure { + assert_initialized_main_thread!(); + unsafe { from_glib_full(ffi::gsk_path_measure_new(path.to_glib_none().0)) } + } + + #[doc(alias = "gsk_path_measure_new_with_tolerance")] + #[doc(alias = "new_with_tolerance")] + pub fn with_tolerance(path: &Path, tolerance: f32) -> PathMeasure { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gsk_path_measure_new_with_tolerance( + path.to_glib_none().0, + tolerance, + )) + } + } + + #[doc(alias = "gsk_path_measure_get_length")] + #[doc(alias = "get_length")] + pub fn length(&self) -> f32 { + unsafe { ffi::gsk_path_measure_get_length(self.to_glib_none().0) } + } + + #[doc(alias = "gsk_path_measure_get_path")] + #[doc(alias = "get_path")] + pub fn path(&self) -> Path { + unsafe { from_glib_none(ffi::gsk_path_measure_get_path(self.to_glib_none().0)) } + } + + #[doc(alias = "gsk_path_measure_get_point")] + #[doc(alias = "get_point")] + pub fn point(&self, distance: f32) -> Option { + unsafe { + let mut result = PathPoint::uninitialized(); + let ret = from_glib(ffi::gsk_path_measure_get_point( + self.to_glib_none().0, + distance, + result.to_glib_none_mut().0, + )); + if ret { + Some(result) + } else { + None + } + } + } + + #[doc(alias = "gsk_path_measure_get_tolerance")] + #[doc(alias = "get_tolerance")] + pub fn tolerance(&self) -> f32 { + unsafe { ffi::gsk_path_measure_get_tolerance(self.to_glib_none().0) } + } +} diff --git a/gsk4/src/auto/path_point.rs b/gsk4/src/auto/path_point.rs index 942057bf3362..ef440b9f6b81 100644 --- a/gsk4/src/auto/path_point.rs +++ b/gsk4/src/auto/path_point.rs @@ -2,7 +2,7 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use crate::{Path, PathDirection}; +use crate::{Path, PathDirection, PathMeasure}; use glib::translate::*; glib::wrapper! { @@ -31,11 +31,11 @@ impl PathPoint { } } - //#[doc(alias = "gsk_path_point_get_distance")] - //#[doc(alias = "get_distance")] - //pub fn distance(&self, measure: /*Ignored*/&PathMeasure) -> f32 { - // unsafe { TODO: call ffi:gsk_path_point_get_distance() } - //} + #[doc(alias = "gsk_path_point_get_distance")] + #[doc(alias = "get_distance")] + pub fn distance(&self, measure: &PathMeasure) -> f32 { + unsafe { ffi::gsk_path_point_get_distance(self.to_glib_none().0, measure.to_glib_none().0) } + } #[doc(alias = "gsk_path_point_get_position")] #[doc(alias = "get_position")]