Skip to content

Commit

Permalink
gsk: Generate PathMeasure
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Aug 27, 2023
1 parent db6658f commit 2e3f126
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 6 deletions.
5 changes: 5 additions & 0 deletions gsk4/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions gsk4/src/auto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
73 changes: 73 additions & 0 deletions gsk4/src/auto/path_measure.rs
Original file line number Diff line number Diff line change
@@ -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<ffi::GskPathMeasure>);

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<PathPoint> {
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) }
}
}
12 changes: 6 additions & 6 deletions gsk4/src/auto/path_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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")]
Expand Down

0 comments on commit 2e3f126

Please sign in to comment.