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