gtk4/auto/
overlay_layout_child.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, LayoutChild};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// [`LayoutChild`][crate::LayoutChild] subclass for children in a [`OverlayLayout`][crate::OverlayLayout].
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `clip-overlay`
20    ///  Whether the child should be clipped to fit the parent's size.
21    ///
22    /// Readable | Writeable
23    ///
24    ///
25    /// #### `measure`
26    ///  Whether the child size should contribute to the [`OverlayLayout`][crate::OverlayLayout]'s
27    /// measurement.
28    ///
29    /// Readable | Writeable
30    /// <details><summary><h4>LayoutChild</h4></summary>
31    ///
32    ///
33    /// #### `child-widget`
34    ///  The widget that is associated to the [`LayoutChild`][crate::LayoutChild] instance.
35    ///
36    /// Readable | Writeable | Construct Only
37    ///
38    ///
39    /// #### `layout-manager`
40    ///  The layout manager that created the [`LayoutChild`][crate::LayoutChild] instance.
41    ///
42    /// Readable | Writeable | Construct Only
43    /// </details>
44    ///
45    /// # Implements
46    ///
47    /// [`LayoutChildExt`][trait@crate::prelude::LayoutChildExt], [`trait@glib::ObjectExt`]
48    #[doc(alias = "GtkOverlayLayoutChild")]
49    pub struct OverlayLayoutChild(Object<ffi::GtkOverlayLayoutChild, ffi::GtkOverlayLayoutChildClass>) @extends LayoutChild;
50
51    match fn {
52        type_ => || ffi::gtk_overlay_layout_child_get_type(),
53    }
54}
55
56impl OverlayLayoutChild {
57    /// Retrieves whether the child is clipped.
58    ///
59    /// # Returns
60    ///
61    /// whether the child is clipped
62    #[doc(alias = "gtk_overlay_layout_child_get_clip_overlay")]
63    #[doc(alias = "get_clip_overlay")]
64    #[doc(alias = "clip-overlay")]
65    pub fn is_clip_overlay(&self) -> bool {
66        unsafe {
67            from_glib(ffi::gtk_overlay_layout_child_get_clip_overlay(
68                self.to_glib_none().0,
69            ))
70        }
71    }
72
73    /// Retrieves whether the child is measured.
74    ///
75    /// # Returns
76    ///
77    /// whether the child is measured
78    #[doc(alias = "gtk_overlay_layout_child_get_measure")]
79    #[doc(alias = "get_measure")]
80    #[doc(alias = "measure")]
81    pub fn is_measure(&self) -> bool {
82        unsafe {
83            from_glib(ffi::gtk_overlay_layout_child_get_measure(
84                self.to_glib_none().0,
85            ))
86        }
87    }
88
89    /// Sets whether to clip this child.
90    /// ## `clip_overlay`
91    /// whether to clip this child
92    #[doc(alias = "gtk_overlay_layout_child_set_clip_overlay")]
93    #[doc(alias = "clip-overlay")]
94    pub fn set_clip_overlay(&self, clip_overlay: bool) {
95        unsafe {
96            ffi::gtk_overlay_layout_child_set_clip_overlay(
97                self.to_glib_none().0,
98                clip_overlay.into_glib(),
99            );
100        }
101    }
102
103    /// Sets whether to measure this child.
104    /// ## `measure`
105    /// whether to measure this child
106    #[doc(alias = "gtk_overlay_layout_child_set_measure")]
107    #[doc(alias = "measure")]
108    pub fn set_measure(&self, measure: bool) {
109        unsafe {
110            ffi::gtk_overlay_layout_child_set_measure(self.to_glib_none().0, measure.into_glib());
111        }
112    }
113
114    #[doc(alias = "clip-overlay")]
115    pub fn connect_clip_overlay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
116        unsafe extern "C" fn notify_clip_overlay_trampoline<
117            F: Fn(&OverlayLayoutChild) + 'static,
118        >(
119            this: *mut ffi::GtkOverlayLayoutChild,
120            _param_spec: glib::ffi::gpointer,
121            f: glib::ffi::gpointer,
122        ) {
123            let f: &F = &*(f as *const F);
124            f(&from_glib_borrow(this))
125        }
126        unsafe {
127            let f: Box_<F> = Box_::new(f);
128            connect_raw(
129                self.as_ptr() as *mut _,
130                b"notify::clip-overlay\0".as_ptr() as *const _,
131                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
132                    notify_clip_overlay_trampoline::<F> as *const (),
133                )),
134                Box_::into_raw(f),
135            )
136        }
137    }
138
139    #[doc(alias = "measure")]
140    pub fn connect_measure_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
141        unsafe extern "C" fn notify_measure_trampoline<F: Fn(&OverlayLayoutChild) + 'static>(
142            this: *mut ffi::GtkOverlayLayoutChild,
143            _param_spec: glib::ffi::gpointer,
144            f: glib::ffi::gpointer,
145        ) {
146            let f: &F = &*(f as *const F);
147            f(&from_glib_borrow(this))
148        }
149        unsafe {
150            let f: Box_<F> = Box_::new(f);
151            connect_raw(
152                self.as_ptr() as *mut _,
153                b"notify::measure\0".as_ptr() as *const _,
154                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
155                    notify_measure_trampoline::<F> as *const (),
156                )),
157                Box_::into_raw(f),
158            )
159        }
160    }
161}