|
| 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 | +} |
0 commit comments