Skip to main content

gtk4/auto/
allocation_details.rs

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
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Collects extra parameters that can be passed to [`WidgetExt::allocate_detailed()`][crate::prelude::WidgetExt::allocate_detailed()].
10    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11    pub struct AllocationDetails(Boxed<ffi::GtkAllocationDetails>);
12
13    match fn {
14        copy => |ptr| ffi::gtk_allocation_details_copy(ptr),
15        free => |ptr| ffi::gtk_allocation_details_free(ptr),
16        type_ => || ffi::gtk_allocation_details_get_type(),
17    }
18}
19
20impl AllocationDetails {
21    /// Creates a new [`AllocationDetails`][crate::AllocationDetails].
22    ///
23    /// # Returns
24    ///
25    /// a new [`AllocationDetails`][crate::AllocationDetails]
26    #[doc(alias = "gtk_allocation_details_new")]
27    pub fn new() -> AllocationDetails {
28        assert_initialized_main_thread!();
29        unsafe { from_glib_full(ffi::gtk_allocation_details_new()) }
30    }
31
32    /// Gets the baseline that was set via [`set_baseline()`][Self::set_baseline()]
33    ///
34    /// # Returns
35    ///
36    /// the baseline or -1 if unset
37    #[doc(alias = "gtk_allocation_details_get_baseline")]
38    #[doc(alias = "get_baseline")]
39    pub fn baseline(&self) -> i32 {
40        unsafe { ffi::gtk_allocation_details_get_baseline(self.to_glib_none().0) }
41    }
42
43    /// Gets the transform that was set via [`set_transform()`][Self::set_transform()]
44    ///
45    /// # Returns
46    ///
47    /// the transform
48    #[doc(alias = "gtk_allocation_details_get_transform")]
49    #[doc(alias = "get_transform")]
50    pub fn transform(&self) -> Option<gsk::Transform> {
51        unsafe {
52            from_glib_full(ffi::gtk_allocation_details_get_transform(
53                self.to_glib_none().0,
54            ))
55        }
56    }
57
58    /// Sets or unsets the baseline to use.
59    ///
60    /// A baseline of -1 unsets the baseline.
61    ///
62    /// By default, the baseline is unset.
63    /// ## `baseline`
64    /// the baseline
65    #[doc(alias = "gtk_allocation_details_set_baseline")]
66    pub fn set_baseline(&mut self, baseline: i32) {
67        unsafe {
68            ffi::gtk_allocation_details_set_baseline(self.to_glib_none_mut().0, baseline);
69        }
70    }
71
72    /// Sets the transform that will be applied to the parent's coordinate space
73    /// before allocating the size.
74    ///
75    /// By default, the identity transform is used.
76    /// ## `transform`
77    /// The transform to use
78    #[doc(alias = "gtk_allocation_details_set_transform")]
79    pub fn set_transform(&mut self, transform: Option<&gsk::Transform>) {
80        unsafe {
81            ffi::gtk_allocation_details_set_transform(
82                self.to_glib_none_mut().0,
83                transform.to_glib_none().0,
84            );
85        }
86    }
87}
88
89#[cfg(feature = "v4_26")]
90#[cfg_attr(docsrs, doc(cfg(feature = "v4_26")))]
91impl Default for AllocationDetails {
92    fn default() -> Self {
93        Self::new()
94    }
95}