[go: up one dir, main page]

gtk4/auto/
overlay.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::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7    Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    #[doc(alias = "GtkOverlay")]
18    pub struct Overlay(Object<ffi::GtkOverlay>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
19
20    match fn {
21        type_ => || ffi::gtk_overlay_get_type(),
22    }
23}
24
25impl Overlay {
26    #[doc(alias = "gtk_overlay_new")]
27    pub fn new() -> Overlay {
28        assert_initialized_main_thread!();
29        unsafe { Widget::from_glib_none(ffi::gtk_overlay_new()).unsafe_cast() }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`Overlay`] objects.
34    ///
35    /// This method returns an instance of [`OverlayBuilder`](crate::builders::OverlayBuilder) which can be used to create [`Overlay`] objects.
36    pub fn builder() -> OverlayBuilder {
37        OverlayBuilder::new()
38    }
39
40    #[doc(alias = "gtk_overlay_add_overlay")]
41    pub fn add_overlay(&self, widget: &impl IsA<Widget>) {
42        unsafe {
43            ffi::gtk_overlay_add_overlay(self.to_glib_none().0, widget.as_ref().to_glib_none().0);
44        }
45    }
46
47    #[doc(alias = "gtk_overlay_get_child")]
48    #[doc(alias = "get_child")]
49    pub fn child(&self) -> Option<Widget> {
50        unsafe { from_glib_none(ffi::gtk_overlay_get_child(self.to_glib_none().0)) }
51    }
52
53    #[doc(alias = "gtk_overlay_get_clip_overlay")]
54    #[doc(alias = "get_clip_overlay")]
55    pub fn is_clip_overlay(&self, widget: &impl IsA<Widget>) -> bool {
56        unsafe {
57            from_glib(ffi::gtk_overlay_get_clip_overlay(
58                self.to_glib_none().0,
59                widget.as_ref().to_glib_none().0,
60            ))
61        }
62    }
63
64    #[doc(alias = "gtk_overlay_get_measure_overlay")]
65    #[doc(alias = "get_measure_overlay")]
66    pub fn is_measure_overlay(&self, widget: &impl IsA<Widget>) -> bool {
67        unsafe {
68            from_glib(ffi::gtk_overlay_get_measure_overlay(
69                self.to_glib_none().0,
70                widget.as_ref().to_glib_none().0,
71            ))
72        }
73    }
74
75    #[doc(alias = "gtk_overlay_remove_overlay")]
76    pub fn remove_overlay(&self, widget: &impl IsA<Widget>) {
77        unsafe {
78            ffi::gtk_overlay_remove_overlay(
79                self.to_glib_none().0,
80                widget.as_ref().to_glib_none().0,
81            );
82        }
83    }
84
85    #[doc(alias = "gtk_overlay_set_child")]
86    #[doc(alias = "child")]
87    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
88        unsafe {
89            ffi::gtk_overlay_set_child(
90                self.to_glib_none().0,
91                child.map(|p| p.as_ref()).to_glib_none().0,
92            );
93        }
94    }
95
96    #[doc(alias = "gtk_overlay_set_clip_overlay")]
97    pub fn set_clip_overlay(&self, widget: &impl IsA<Widget>, clip_overlay: bool) {
98        unsafe {
99            ffi::gtk_overlay_set_clip_overlay(
100                self.to_glib_none().0,
101                widget.as_ref().to_glib_none().0,
102                clip_overlay.into_glib(),
103            );
104        }
105    }
106
107    #[doc(alias = "gtk_overlay_set_measure_overlay")]
108    pub fn set_measure_overlay(&self, widget: &impl IsA<Widget>, measure: bool) {
109        unsafe {
110            ffi::gtk_overlay_set_measure_overlay(
111                self.to_glib_none().0,
112                widget.as_ref().to_glib_none().0,
113                measure.into_glib(),
114            );
115        }
116    }
117
118    #[doc(alias = "child")]
119    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
120        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Overlay) + 'static>(
121            this: *mut ffi::GtkOverlay,
122            _param_spec: glib::ffi::gpointer,
123            f: glib::ffi::gpointer,
124        ) {
125            let f: &F = &*(f as *const F);
126            f(&from_glib_borrow(this))
127        }
128        unsafe {
129            let f: Box_<F> = Box_::new(f);
130            connect_raw(
131                self.as_ptr() as *mut _,
132                c"notify::child".as_ptr() as *const _,
133                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
134                    notify_child_trampoline::<F> as *const (),
135                )),
136                Box_::into_raw(f),
137            )
138        }
139    }
140}
141
142impl Default for Overlay {
143    fn default() -> Self {
144        Self::new()
145    }
146}
147
148// rustdoc-stripper-ignore-next
149/// A [builder-pattern] type to construct [`Overlay`] objects.
150///
151/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
152#[must_use = "The builder must be built to be used"]
153pub struct OverlayBuilder {
154    builder: glib::object::ObjectBuilder<'static, Overlay>,
155}
156
157impl OverlayBuilder {
158    fn new() -> Self {
159        Self {
160            builder: glib::object::Object::builder(),
161        }
162    }
163
164    pub fn child(self, child: &impl IsA<Widget>) -> Self {
165        Self {
166            builder: self.builder.property("child", child.clone().upcast()),
167        }
168    }
169
170    pub fn can_focus(self, can_focus: bool) -> Self {
171        Self {
172            builder: self.builder.property("can-focus", can_focus),
173        }
174    }
175
176    pub fn can_target(self, can_target: bool) -> Self {
177        Self {
178            builder: self.builder.property("can-target", can_target),
179        }
180    }
181
182    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
183        Self {
184            builder: self.builder.property("css-classes", css_classes.into()),
185        }
186    }
187
188    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
189        Self {
190            builder: self.builder.property("css-name", css_name.into()),
191        }
192    }
193
194    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
195        Self {
196            builder: self.builder.property("cursor", cursor.clone()),
197        }
198    }
199
200    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
201        Self {
202            builder: self.builder.property("focus-on-click", focus_on_click),
203        }
204    }
205
206    pub fn focusable(self, focusable: bool) -> Self {
207        Self {
208            builder: self.builder.property("focusable", focusable),
209        }
210    }
211
212    pub fn halign(self, halign: Align) -> Self {
213        Self {
214            builder: self.builder.property("halign", halign),
215        }
216    }
217
218    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
219        Self {
220            builder: self.builder.property("has-tooltip", has_tooltip),
221        }
222    }
223
224    pub fn height_request(self, height_request: i32) -> Self {
225        Self {
226            builder: self.builder.property("height-request", height_request),
227        }
228    }
229
230    pub fn hexpand(self, hexpand: bool) -> Self {
231        Self {
232            builder: self.builder.property("hexpand", hexpand),
233        }
234    }
235
236    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
237        Self {
238            builder: self.builder.property("hexpand-set", hexpand_set),
239        }
240    }
241
242    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
243        Self {
244            builder: self
245                .builder
246                .property("layout-manager", layout_manager.clone().upcast()),
247        }
248    }
249
250    #[cfg(feature = "v4_18")]
251    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
252    pub fn limit_events(self, limit_events: bool) -> Self {
253        Self {
254            builder: self.builder.property("limit-events", limit_events),
255        }
256    }
257
258    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
259        Self {
260            builder: self.builder.property("margin-bottom", margin_bottom),
261        }
262    }
263
264    pub fn margin_end(self, margin_end: i32) -> Self {
265        Self {
266            builder: self.builder.property("margin-end", margin_end),
267        }
268    }
269
270    pub fn margin_start(self, margin_start: i32) -> Self {
271        Self {
272            builder: self.builder.property("margin-start", margin_start),
273        }
274    }
275
276    pub fn margin_top(self, margin_top: i32) -> Self {
277        Self {
278            builder: self.builder.property("margin-top", margin_top),
279        }
280    }
281
282    pub fn name(self, name: impl Into<glib::GString>) -> Self {
283        Self {
284            builder: self.builder.property("name", name.into()),
285        }
286    }
287
288    pub fn opacity(self, opacity: f64) -> Self {
289        Self {
290            builder: self.builder.property("opacity", opacity),
291        }
292    }
293
294    pub fn overflow(self, overflow: Overflow) -> Self {
295        Self {
296            builder: self.builder.property("overflow", overflow),
297        }
298    }
299
300    pub fn receives_default(self, receives_default: bool) -> Self {
301        Self {
302            builder: self.builder.property("receives-default", receives_default),
303        }
304    }
305
306    pub fn sensitive(self, sensitive: bool) -> Self {
307        Self {
308            builder: self.builder.property("sensitive", sensitive),
309        }
310    }
311
312    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
313        Self {
314            builder: self
315                .builder
316                .property("tooltip-markup", tooltip_markup.into()),
317        }
318    }
319
320    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
321        Self {
322            builder: self.builder.property("tooltip-text", tooltip_text.into()),
323        }
324    }
325
326    pub fn valign(self, valign: Align) -> Self {
327        Self {
328            builder: self.builder.property("valign", valign),
329        }
330    }
331
332    pub fn vexpand(self, vexpand: bool) -> Self {
333        Self {
334            builder: self.builder.property("vexpand", vexpand),
335        }
336    }
337
338    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
339        Self {
340            builder: self.builder.property("vexpand-set", vexpand_set),
341        }
342    }
343
344    pub fn visible(self, visible: bool) -> Self {
345        Self {
346            builder: self.builder.property("visible", visible),
347        }
348    }
349
350    pub fn width_request(self, width_request: i32) -> Self {
351        Self {
352            builder: self.builder.property("width-request", width_request),
353        }
354    }
355
356    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
357        Self {
358            builder: self.builder.property("accessible-role", accessible_role),
359        }
360    }
361
362    // rustdoc-stripper-ignore-next
363    /// Build the [`Overlay`].
364    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
365    pub fn build(self) -> Overlay {
366        assert_initialized_main_thread!();
367        self.builder.build()
368    }
369}