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