Skip to main content

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    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7    Widget, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// Places “overlay” widgets on top of a single main child.
18    ///
19    /// <picture>
20    ///   <source srcset="overlay-dark.png" media="(prefers-color-scheme: dark)">
21    ///   <img alt="An example GtkOverlay" src="overlay.png">
22    /// </picture>
23    ///
24    /// The position of each overlay widget is determined by its
25    /// [`halign`][struct@crate::Widget#halign] and [`valign`][struct@crate::Widget#valign]
26    /// properties. E.g. a widget with both alignments set to [`Align::Start`][crate::Align::Start]
27    /// will be placed at the top left corner of the [`Overlay`][crate::Overlay] container,
28    /// whereas an overlay with halign set to [`Align::Center`][crate::Align::Center] and valign set
29    /// to [`Align::End`][crate::Align::End] will be placed a the bottom edge of the [`Overlay`][crate::Overlay],
30    /// horizontally centered. The position can be adjusted by setting the margin
31    /// properties of the child to non-zero values.
32    ///
33    /// More complicated placement of overlays is possible by connecting
34    /// to the [`get-child-position`][struct@crate::Overlay#get-child-position] signal.
35    ///
36    /// An overlay’s minimum and natural sizes are those of its main child.
37    /// The sizes of overlay children are not considered when measuring these
38    /// preferred sizes.
39    ///
40    /// # GtkOverlay as GtkBuildable
41    ///
42    /// The [`Overlay`][crate::Overlay] implementation of the [`Buildable`][crate::Buildable] interface
43    /// supports placing a child as an overlay by specifying “overlay” as
44    /// the “type” attribute of a `<child>` element.
45    ///
46    /// # CSS nodes
47    ///
48    /// [`Overlay`][crate::Overlay] has a single CSS node with the name “overlay”. Overlay children
49    /// whose alignments cause them to be positioned at an edge get the style classes
50    /// “.left”, “.right”, “.top”, and/or “.bottom” according to their position.
51    ///
52    /// ## Properties
53    ///
54    ///
55    /// #### `child`
56    ///  The main child widget.
57    ///
58    /// Readable | Writeable
59    /// <details><summary><h4>Widget</h4></summary>
60    ///
61    ///
62    /// #### `can-focus`
63    ///  Whether the widget or any of its descendents can accept
64    /// the input focus.
65    ///
66    /// This property is meant to be set by widget implementations,
67    /// typically in their instance init function.
68    ///
69    /// Readable | Writeable
70    ///
71    ///
72    /// #### `can-target`
73    ///  Whether the widget can receive pointer events.
74    ///
75    /// Readable | Writeable
76    ///
77    ///
78    /// #### `css-classes`
79    ///  A list of css classes applied to this widget.
80    ///
81    /// Readable | Writeable
82    ///
83    ///
84    /// #### `css-name`
85    ///  The name of this widget in the CSS tree.
86    ///
87    /// This property is meant to be set by widget implementations,
88    /// typically in their instance init function.
89    ///
90    /// Readable | Writeable | Construct Only
91    ///
92    ///
93    /// #### `cursor`
94    ///  The cursor used by @widget.
95    ///
96    /// Readable | Writeable
97    ///
98    ///
99    /// #### `focus-on-click`
100    ///  Whether the widget should grab focus when it is clicked with the mouse.
101    ///
102    /// This property is only relevant for widgets that can take focus.
103    ///
104    /// Readable | Writeable
105    ///
106    ///
107    /// #### `focusable`
108    ///  Whether this widget itself will accept the input focus.
109    ///
110    /// Readable | Writeable
111    ///
112    ///
113    /// #### `halign`
114    ///  How to distribute horizontal space if widget gets extra space.
115    ///
116    /// Readable | Writeable
117    ///
118    ///
119    /// #### `has-default`
120    ///  Whether the widget is the default widget.
121    ///
122    /// Readable
123    ///
124    ///
125    /// #### `has-focus`
126    ///  Whether the widget has the input focus.
127    ///
128    /// Readable
129    ///
130    ///
131    /// #### `has-tooltip`
132    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
133    /// signal on @widget.
134    ///
135    /// A true value indicates that @widget can have a tooltip, in this case
136    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
137    /// determine whether it will provide a tooltip or not.
138    ///
139    /// Readable | Writeable
140    ///
141    ///
142    /// #### `height-request`
143    ///  Overrides for height request of the widget.
144    ///
145    /// If this is -1, the natural request will be used.
146    ///
147    /// Readable | Writeable
148    ///
149    ///
150    /// #### `hexpand`
151    ///  Whether to expand horizontally.
152    ///
153    /// Readable | Writeable
154    ///
155    ///
156    /// #### `hexpand-set`
157    ///  Whether to use the `hexpand` property.
158    ///
159    /// Readable | Writeable
160    ///
161    ///
162    /// #### `layout-manager`
163    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
164    /// the preferred size of the widget, and allocate its children.
165    ///
166    /// This property is meant to be set by widget implementations,
167    /// typically in their instance init function.
168    ///
169    /// Readable | Writeable
170    ///
171    ///
172    /// #### `limit-events`
173    ///  Makes this widget act like a modal dialog, with respect to
174    /// event delivery.
175    ///
176    /// Global event controllers will not handle events with targets
177    /// inside the widget, unless they are set up to ignore propagation
178    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
179    ///
180    /// Readable | Writeable
181    ///
182    ///
183    /// #### `margin-bottom`
184    ///  Margin on bottom side of widget.
185    ///
186    /// This property adds margin outside of the widget's normal size
187    /// request, the margin will be added in addition to the size from
188    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
189    ///
190    /// Readable | Writeable
191    ///
192    ///
193    /// #### `margin-end`
194    ///  Margin on end of widget, horizontally.
195    ///
196    /// This property supports left-to-right and right-to-left text
197    /// directions.
198    ///
199    /// This property adds margin outside of the widget's normal size
200    /// request, the margin will be added in addition to the size from
201    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
202    ///
203    /// Readable | Writeable
204    ///
205    ///
206    /// #### `margin-start`
207    ///  Margin on start of widget, horizontally.
208    ///
209    /// This property supports left-to-right and right-to-left text
210    /// directions.
211    ///
212    /// This property adds margin outside of the widget's normal size
213    /// request, the margin will be added in addition to the size from
214    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
215    ///
216    /// Readable | Writeable
217    ///
218    ///
219    /// #### `margin-top`
220    ///  Margin on top side of widget.
221    ///
222    /// This property adds margin outside of the widget's normal size
223    /// request, the margin will be added in addition to the size from
224    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
225    ///
226    /// Readable | Writeable
227    ///
228    ///
229    /// #### `name`
230    ///  The name of the widget.
231    ///
232    /// Readable | Writeable
233    ///
234    ///
235    /// #### `opacity`
236    ///  The requested opacity of the widget.
237    ///
238    /// Readable | Writeable
239    ///
240    ///
241    /// #### `overflow`
242    ///  How content outside the widget's content area is treated.
243    ///
244    /// This property is meant to be set by widget implementations,
245    /// typically in their instance init function.
246    ///
247    /// Readable | Writeable
248    ///
249    ///
250    /// #### `parent`
251    ///  The parent widget of this widget.
252    ///
253    /// Readable
254    ///
255    ///
256    /// #### `receives-default`
257    ///  Whether the widget will receive the default action when it is focused.
258    ///
259    /// Readable | Writeable
260    ///
261    ///
262    /// #### `root`
263    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
264    ///
265    /// This will be `NULL` if the widget is not contained in a root widget.
266    ///
267    /// Readable
268    ///
269    ///
270    /// #### `scale-factor`
271    ///  The scale factor of the widget.
272    ///
273    /// Readable
274    ///
275    ///
276    /// #### `sensitive`
277    ///  Whether the widget responds to input.
278    ///
279    /// Readable | Writeable
280    ///
281    ///
282    /// #### `tooltip-markup`
283    ///  Sets the text of tooltip to be the given string, which is marked up
284    /// with Pango markup.
285    ///
286    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
287    ///
288    /// This is a convenience property which will take care of getting the
289    /// tooltip shown if the given string is not `NULL`:
290    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
291    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
292    /// the default signal handler.
293    ///
294    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
295    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
296    ///
297    /// Readable | Writeable
298    ///
299    ///
300    /// #### `tooltip-text`
301    ///  Sets the text of tooltip to be the given string.
302    ///
303    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
304    ///
305    /// This is a convenience property which will take care of getting the
306    /// tooltip shown if the given string is not `NULL`:
307    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
308    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
309    /// the default signal handler.
310    ///
311    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
312    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
313    ///
314    /// Readable | Writeable
315    ///
316    ///
317    /// #### `valign`
318    ///  How to distribute vertical space if widget gets extra space.
319    ///
320    /// Readable | Writeable
321    ///
322    ///
323    /// #### `vexpand`
324    ///  Whether to expand vertically.
325    ///
326    /// Readable | Writeable
327    ///
328    ///
329    /// #### `vexpand-set`
330    ///  Whether to use the `vexpand` property.
331    ///
332    /// Readable | Writeable
333    ///
334    ///
335    /// #### `visible`
336    ///  Whether the widget is visible.
337    ///
338    /// Readable | Writeable
339    ///
340    ///
341    /// #### `width-request`
342    ///  Overrides for width request of the widget.
343    ///
344    /// If this is -1, the natural request will be used.
345    ///
346    /// Readable | Writeable
347    /// </details>
348    /// <details><summary><h4>Accessible</h4></summary>
349    ///
350    ///
351    /// #### `accessible-role`
352    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
353    ///
354    /// The accessible role cannot be changed once set.
355    ///
356    /// Readable | Writeable
357    /// </details>
358    ///
359    /// ## Signals
360    ///
361    ///
362    /// #### `get-child-position`
363    ///  Emitted to determine the position and size of any overlay
364    /// child widgets.
365    ///
366    /// A handler for this signal should fill @allocation with
367    /// the desired position and size for @widget, relative to
368    /// the 'main' child of @overlay.
369    ///
370    /// The default handler for this signal uses the @widget's
371    /// halign and valign properties to determine the position
372    /// and gives the widget its natural size (except that an
373    /// alignment of [`Align::Fill`][crate::Align::Fill] will cause the overlay to
374    /// be full-width/height). If the main child is a
375    /// [`ScrolledWindow`][crate::ScrolledWindow], the overlays are placed relative
376    /// to its contents.
377    ///
378    ///
379    /// <details><summary><h4>Widget</h4></summary>
380    ///
381    ///
382    /// #### `destroy`
383    ///  Signals that all holders of a reference to the widget should release
384    /// the reference that they hold.
385    ///
386    /// May result in finalization of the widget if all references are released.
387    ///
388    /// This signal is not suitable for saving widget state.
389    ///
390    ///
391    ///
392    ///
393    /// #### `direction-changed`
394    ///  Emitted when the text direction of a widget changes.
395    ///
396    ///
397    ///
398    ///
399    /// #### `hide`
400    ///  Emitted when @widget is hidden.
401    ///
402    ///
403    ///
404    ///
405    /// #### `keynav-failed`
406    ///  Emitted if keyboard navigation fails.
407    ///
408    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
409    ///
410    ///
411    ///
412    ///
413    /// #### `map`
414    ///  Emitted when @widget is going to be mapped.
415    ///
416    /// A widget is mapped when the widget is visible (which is controlled with
417    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
418    /// are also visible.
419    ///
420    /// The `::map` signal can be used to determine whether a widget will be drawn,
421    /// for instance it can resume an animation that was stopped during the
422    /// emission of [`unmap`][struct@crate::Widget#unmap].
423    ///
424    ///
425    ///
426    ///
427    /// #### `mnemonic-activate`
428    ///  Emitted when a widget is activated via a mnemonic.
429    ///
430    /// The default handler for this signal activates @widget if @group_cycling
431    /// is false, or just makes @widget grab focus if @group_cycling is true.
432    ///
433    ///
434    ///
435    ///
436    /// #### `move-focus`
437    ///  Emitted when the focus is moved.
438    ///
439    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
440    ///
441    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
442    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
443    ///
444    /// Action
445    ///
446    ///
447    /// #### `query-tooltip`
448    ///  Emitted when the widget’s tooltip is about to be shown.
449    ///
450    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
451    /// is true and the hover timeout has expired with the cursor hovering
452    /// above @widget; or emitted when @widget got focus in keyboard mode.
453    ///
454    /// Using the given coordinates, the signal handler should determine
455    /// whether a tooltip should be shown for @widget. If this is the case
456    /// true should be returned, false otherwise. Note that if @keyboard_mode
457    /// is true, the values of @x and @y are undefined and should not be used.
458    ///
459    /// The signal handler is free to manipulate @tooltip with the therefore
460    /// destined function calls.
461    ///
462    ///
463    ///
464    ///
465    /// #### `realize`
466    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
467    ///
468    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
469    /// or the widget has been mapped (that is, it is going to be drawn).
470    ///
471    ///
472    ///
473    ///
474    /// #### `show`
475    ///  Emitted when @widget is shown.
476    ///
477    ///
478    ///
479    ///
480    /// #### `state-flags-changed`
481    ///  Emitted when the widget state changes.
482    ///
483    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
484    ///
485    ///
486    ///
487    ///
488    /// #### `unmap`
489    ///  Emitted when @widget is going to be unmapped.
490    ///
491    /// A widget is unmapped when either it or any of its parents up to the
492    /// toplevel widget have been set as hidden.
493    ///
494    /// As `::unmap` indicates that a widget will not be shown any longer,
495    /// it can be used to, for example, stop an animation on the widget.
496    ///
497    ///
498    ///
499    ///
500    /// #### `unrealize`
501    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
502    ///
503    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
504    /// or the widget has been unmapped (that is, it is going to be hidden).
505    ///
506    ///
507    /// </details>
508    ///
509    /// # Implements
510    ///
511    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
512    #[doc(alias = "GtkOverlay")]
513    pub struct Overlay(Object<ffi::GtkOverlay>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
514
515    match fn {
516        type_ => || ffi::gtk_overlay_get_type(),
517    }
518}
519
520impl Overlay {
521    /// Creates a new [`Overlay`][crate::Overlay].
522    ///
523    /// # Returns
524    ///
525    /// a new [`Overlay`][crate::Overlay] object.
526    #[doc(alias = "gtk_overlay_new")]
527    pub fn new() -> Overlay {
528        assert_initialized_main_thread!();
529        unsafe { Widget::from_glib_none(ffi::gtk_overlay_new()).unsafe_cast() }
530    }
531
532    // rustdoc-stripper-ignore-next
533    /// Creates a new builder-pattern struct instance to construct [`Overlay`] objects.
534    ///
535    /// This method returns an instance of [`OverlayBuilder`](crate::builders::OverlayBuilder) which can be used to create [`Overlay`] objects.
536    pub fn builder() -> OverlayBuilder {
537        OverlayBuilder::new()
538    }
539
540    /// Adds @widget to @self.
541    ///
542    /// The widget will be stacked on top of the main widget
543    /// added with [`set_child()`][Self::set_child()].
544    ///
545    /// The position at which @widget is placed is determined
546    /// from its [`halign`][struct@crate::Widget#halign] and
547    /// [`valign`][struct@crate::Widget#valign] properties.
548    /// ## `widget`
549    /// a [`Widget`][crate::Widget] to be added to the container
550    #[doc(alias = "gtk_overlay_add_overlay")]
551    pub fn add_overlay(&self, widget: &impl IsA<Widget>) {
552        unsafe {
553            ffi::gtk_overlay_add_overlay(self.to_glib_none().0, widget.as_ref().to_glib_none().0);
554        }
555    }
556
557    /// Gets the child widget of @self.
558    ///
559    /// # Returns
560    ///
561    /// the child widget of @self
562    #[doc(alias = "gtk_overlay_get_child")]
563    #[doc(alias = "get_child")]
564    pub fn child(&self) -> Option<Widget> {
565        unsafe { from_glib_none(ffi::gtk_overlay_get_child(self.to_glib_none().0)) }
566    }
567
568    /// Gets whether @widget should be clipped within the parent.
569    /// ## `widget`
570    /// an overlay child of [`Overlay`][crate::Overlay]
571    ///
572    /// # Returns
573    ///
574    /// whether the widget is clipped within the parent.
575    #[doc(alias = "gtk_overlay_get_clip_overlay")]
576    #[doc(alias = "get_clip_overlay")]
577    pub fn is_clip_overlay(&self, widget: &impl IsA<Widget>) -> bool {
578        unsafe {
579            from_glib(ffi::gtk_overlay_get_clip_overlay(
580                self.to_glib_none().0,
581                widget.as_ref().to_glib_none().0,
582            ))
583        }
584    }
585
586    /// Gets whether @widget's size is included in the measurement of
587    /// @self.
588    /// ## `widget`
589    /// an overlay child of [`Overlay`][crate::Overlay]
590    ///
591    /// # Returns
592    ///
593    /// whether the widget is measured
594    #[doc(alias = "gtk_overlay_get_measure_overlay")]
595    #[doc(alias = "get_measure_overlay")]
596    pub fn is_measure_overlay(&self, widget: &impl IsA<Widget>) -> bool {
597        unsafe {
598            from_glib(ffi::gtk_overlay_get_measure_overlay(
599                self.to_glib_none().0,
600                widget.as_ref().to_glib_none().0,
601            ))
602        }
603    }
604
605    /// Removes an overlay that was added with gtk_overlay_add_overlay().
606    /// ## `widget`
607    /// a [`Widget`][crate::Widget] to be removed
608    #[doc(alias = "gtk_overlay_remove_overlay")]
609    pub fn remove_overlay(&self, widget: &impl IsA<Widget>) {
610        unsafe {
611            ffi::gtk_overlay_remove_overlay(
612                self.to_glib_none().0,
613                widget.as_ref().to_glib_none().0,
614            );
615        }
616    }
617
618    /// Sets the child widget of @self.
619    /// ## `child`
620    /// the child widget
621    #[doc(alias = "gtk_overlay_set_child")]
622    #[doc(alias = "child")]
623    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
624        unsafe {
625            ffi::gtk_overlay_set_child(
626                self.to_glib_none().0,
627                child.map(|p| p.as_ref()).to_glib_none().0,
628            );
629        }
630    }
631
632    /// Sets whether @widget should be clipped within the parent.
633    /// ## `widget`
634    /// an overlay child of [`Overlay`][crate::Overlay]
635    /// ## `clip_overlay`
636    /// whether the child should be clipped
637    #[doc(alias = "gtk_overlay_set_clip_overlay")]
638    pub fn set_clip_overlay(&self, widget: &impl IsA<Widget>, clip_overlay: bool) {
639        unsafe {
640            ffi::gtk_overlay_set_clip_overlay(
641                self.to_glib_none().0,
642                widget.as_ref().to_glib_none().0,
643                clip_overlay.into_glib(),
644            );
645        }
646    }
647
648    /// Sets whether @widget is included in the measured size of @self.
649    ///
650    /// The overlay will request the size of the largest child that has
651    /// this property set to [`true`]. Children who are not included may
652    /// be drawn outside of @self's allocation if they are too large.
653    /// ## `widget`
654    /// an overlay child of [`Overlay`][crate::Overlay]
655    /// ## `measure`
656    /// whether the child should be measured
657    #[doc(alias = "gtk_overlay_set_measure_overlay")]
658    pub fn set_measure_overlay(&self, widget: &impl IsA<Widget>, measure: bool) {
659        unsafe {
660            ffi::gtk_overlay_set_measure_overlay(
661                self.to_glib_none().0,
662                widget.as_ref().to_glib_none().0,
663                measure.into_glib(),
664            );
665        }
666    }
667
668    #[doc(alias = "child")]
669    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
670        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Overlay) + 'static>(
671            this: *mut ffi::GtkOverlay,
672            _param_spec: glib::ffi::gpointer,
673            f: glib::ffi::gpointer,
674        ) {
675            unsafe {
676                let f: &F = &*(f as *const F);
677                f(&from_glib_borrow(this))
678            }
679        }
680        unsafe {
681            let f: Box_<F> = Box_::new(f);
682            connect_raw(
683                self.as_ptr() as *mut _,
684                c"notify::child".as_ptr() as *const _,
685                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
686                    notify_child_trampoline::<F> as *const (),
687                )),
688                Box_::into_raw(f),
689            )
690        }
691    }
692}
693
694impl Default for Overlay {
695    fn default() -> Self {
696        Self::new()
697    }
698}
699
700// rustdoc-stripper-ignore-next
701/// A [builder-pattern] type to construct [`Overlay`] objects.
702///
703/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
704#[must_use = "The builder must be built to be used"]
705pub struct OverlayBuilder {
706    builder: glib::object::ObjectBuilder<'static, Overlay>,
707}
708
709impl OverlayBuilder {
710    fn new() -> Self {
711        Self {
712            builder: glib::object::Object::builder(),
713        }
714    }
715
716    /// The main child widget.
717    pub fn child(self, child: &impl IsA<Widget>) -> Self {
718        Self {
719            builder: self.builder.property("child", child.clone().upcast()),
720        }
721    }
722
723    /// Whether the widget or any of its descendents can accept
724    /// the input focus.
725    ///
726    /// This property is meant to be set by widget implementations,
727    /// typically in their instance init function.
728    pub fn can_focus(self, can_focus: bool) -> Self {
729        Self {
730            builder: self.builder.property("can-focus", can_focus),
731        }
732    }
733
734    /// Whether the widget can receive pointer events.
735    pub fn can_target(self, can_target: bool) -> Self {
736        Self {
737            builder: self.builder.property("can-target", can_target),
738        }
739    }
740
741    /// A list of css classes applied to this widget.
742    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
743        Self {
744            builder: self.builder.property("css-classes", css_classes.into()),
745        }
746    }
747
748    /// The name of this widget in the CSS tree.
749    ///
750    /// This property is meant to be set by widget implementations,
751    /// typically in their instance init function.
752    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
753        Self {
754            builder: self.builder.property("css-name", css_name.into()),
755        }
756    }
757
758    /// The cursor used by @widget.
759    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
760        Self {
761            builder: self.builder.property("cursor", cursor.clone()),
762        }
763    }
764
765    /// Whether the widget should grab focus when it is clicked with the mouse.
766    ///
767    /// This property is only relevant for widgets that can take focus.
768    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
769        Self {
770            builder: self.builder.property("focus-on-click", focus_on_click),
771        }
772    }
773
774    /// Whether this widget itself will accept the input focus.
775    pub fn focusable(self, focusable: bool) -> Self {
776        Self {
777            builder: self.builder.property("focusable", focusable),
778        }
779    }
780
781    /// How to distribute horizontal space if widget gets extra space.
782    pub fn halign(self, halign: Align) -> Self {
783        Self {
784            builder: self.builder.property("halign", halign),
785        }
786    }
787
788    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
789    /// signal on @widget.
790    ///
791    /// A true value indicates that @widget can have a tooltip, in this case
792    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
793    /// determine whether it will provide a tooltip or not.
794    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
795        Self {
796            builder: self.builder.property("has-tooltip", has_tooltip),
797        }
798    }
799
800    /// Overrides for height request of the widget.
801    ///
802    /// If this is -1, the natural request will be used.
803    pub fn height_request(self, height_request: i32) -> Self {
804        Self {
805            builder: self.builder.property("height-request", height_request),
806        }
807    }
808
809    /// Whether to expand horizontally.
810    pub fn hexpand(self, hexpand: bool) -> Self {
811        Self {
812            builder: self.builder.property("hexpand", hexpand),
813        }
814    }
815
816    /// Whether to use the `hexpand` property.
817    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
818        Self {
819            builder: self.builder.property("hexpand-set", hexpand_set),
820        }
821    }
822
823    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
824    /// the preferred size of the widget, and allocate its children.
825    ///
826    /// This property is meant to be set by widget implementations,
827    /// typically in their instance init function.
828    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
829        Self {
830            builder: self
831                .builder
832                .property("layout-manager", layout_manager.clone().upcast()),
833        }
834    }
835
836    /// Makes this widget act like a modal dialog, with respect to
837    /// event delivery.
838    ///
839    /// Global event controllers will not handle events with targets
840    /// inside the widget, unless they are set up to ignore propagation
841    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
842    #[cfg(feature = "v4_18")]
843    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
844    pub fn limit_events(self, limit_events: bool) -> Self {
845        Self {
846            builder: self.builder.property("limit-events", limit_events),
847        }
848    }
849
850    /// Margin on bottom side of widget.
851    ///
852    /// This property adds margin outside of the widget's normal size
853    /// request, the margin will be added in addition to the size from
854    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
855    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
856        Self {
857            builder: self.builder.property("margin-bottom", margin_bottom),
858        }
859    }
860
861    /// Margin on end of widget, horizontally.
862    ///
863    /// This property supports left-to-right and right-to-left text
864    /// directions.
865    ///
866    /// This property adds margin outside of the widget's normal size
867    /// request, the margin will be added in addition to the size from
868    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
869    pub fn margin_end(self, margin_end: i32) -> Self {
870        Self {
871            builder: self.builder.property("margin-end", margin_end),
872        }
873    }
874
875    /// Margin on start of widget, horizontally.
876    ///
877    /// This property supports left-to-right and right-to-left text
878    /// directions.
879    ///
880    /// This property adds margin outside of the widget's normal size
881    /// request, the margin will be added in addition to the size from
882    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
883    pub fn margin_start(self, margin_start: i32) -> Self {
884        Self {
885            builder: self.builder.property("margin-start", margin_start),
886        }
887    }
888
889    /// Margin on top side of widget.
890    ///
891    /// This property adds margin outside of the widget's normal size
892    /// request, the margin will be added in addition to the size from
893    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
894    pub fn margin_top(self, margin_top: i32) -> Self {
895        Self {
896            builder: self.builder.property("margin-top", margin_top),
897        }
898    }
899
900    /// The name of the widget.
901    pub fn name(self, name: impl Into<glib::GString>) -> Self {
902        Self {
903            builder: self.builder.property("name", name.into()),
904        }
905    }
906
907    /// The requested opacity of the widget.
908    pub fn opacity(self, opacity: f64) -> Self {
909        Self {
910            builder: self.builder.property("opacity", opacity),
911        }
912    }
913
914    /// How content outside the widget's content area is treated.
915    ///
916    /// This property is meant to be set by widget implementations,
917    /// typically in their instance init function.
918    pub fn overflow(self, overflow: Overflow) -> Self {
919        Self {
920            builder: self.builder.property("overflow", overflow),
921        }
922    }
923
924    /// Whether the widget will receive the default action when it is focused.
925    pub fn receives_default(self, receives_default: bool) -> Self {
926        Self {
927            builder: self.builder.property("receives-default", receives_default),
928        }
929    }
930
931    /// Whether the widget responds to input.
932    pub fn sensitive(self, sensitive: bool) -> Self {
933        Self {
934            builder: self.builder.property("sensitive", sensitive),
935        }
936    }
937
938    /// Sets the text of tooltip to be the given string, which is marked up
939    /// with Pango markup.
940    ///
941    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
942    ///
943    /// This is a convenience property which will take care of getting the
944    /// tooltip shown if the given string is not `NULL`:
945    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
946    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
947    /// the default signal handler.
948    ///
949    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
950    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
951    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
952        Self {
953            builder: self
954                .builder
955                .property("tooltip-markup", tooltip_markup.into()),
956        }
957    }
958
959    /// Sets the text of tooltip to be the given string.
960    ///
961    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
962    ///
963    /// This is a convenience property which will take care of getting the
964    /// tooltip shown if the given string is not `NULL`:
965    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
966    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
967    /// the default signal handler.
968    ///
969    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
970    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
971    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
972        Self {
973            builder: self.builder.property("tooltip-text", tooltip_text.into()),
974        }
975    }
976
977    /// How to distribute vertical space if widget gets extra space.
978    pub fn valign(self, valign: Align) -> Self {
979        Self {
980            builder: self.builder.property("valign", valign),
981        }
982    }
983
984    /// Whether to expand vertically.
985    pub fn vexpand(self, vexpand: bool) -> Self {
986        Self {
987            builder: self.builder.property("vexpand", vexpand),
988        }
989    }
990
991    /// Whether to use the `vexpand` property.
992    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
993        Self {
994            builder: self.builder.property("vexpand-set", vexpand_set),
995        }
996    }
997
998    /// Whether the widget is visible.
999    pub fn visible(self, visible: bool) -> Self {
1000        Self {
1001            builder: self.builder.property("visible", visible),
1002        }
1003    }
1004
1005    /// Overrides for width request of the widget.
1006    ///
1007    /// If this is -1, the natural request will be used.
1008    pub fn width_request(self, width_request: i32) -> Self {
1009        Self {
1010            builder: self.builder.property("width-request", width_request),
1011        }
1012    }
1013
1014    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1015    ///
1016    /// The accessible role cannot be changed once set.
1017    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1018        Self {
1019            builder: self.builder.property("accessible-role", accessible_role),
1020        }
1021    }
1022
1023    // rustdoc-stripper-ignore-next
1024    /// Build the [`Overlay`].
1025    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1026    pub fn build(self) -> Overlay {
1027        assert_initialized_main_thread!();
1028        self.builder.build()
1029    }
1030}