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 /// 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 let f: &F = &*(f as *const F);
676 f(&from_glib_borrow(this))
677 }
678 unsafe {
679 let f: Box_<F> = Box_::new(f);
680 connect_raw(
681 self.as_ptr() as *mut _,
682 c"notify::child".as_ptr() as *const _,
683 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
684 notify_child_trampoline::<F> as *const (),
685 )),
686 Box_::into_raw(f),
687 )
688 }
689 }
690}
691
692impl Default for Overlay {
693 fn default() -> Self {
694 Self::new()
695 }
696}
697
698// rustdoc-stripper-ignore-next
699/// A [builder-pattern] type to construct [`Overlay`] objects.
700///
701/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
702#[must_use = "The builder must be built to be used"]
703pub struct OverlayBuilder {
704 builder: glib::object::ObjectBuilder<'static, Overlay>,
705}
706
707impl OverlayBuilder {
708 fn new() -> Self {
709 Self {
710 builder: glib::object::Object::builder(),
711 }
712 }
713
714 /// The main child widget.
715 pub fn child(self, child: &impl IsA<Widget>) -> Self {
716 Self {
717 builder: self.builder.property("child", child.clone().upcast()),
718 }
719 }
720
721 /// Whether the widget or any of its descendents can accept
722 /// the input focus.
723 ///
724 /// This property is meant to be set by widget implementations,
725 /// typically in their instance init function.
726 pub fn can_focus(self, can_focus: bool) -> Self {
727 Self {
728 builder: self.builder.property("can-focus", can_focus),
729 }
730 }
731
732 /// Whether the widget can receive pointer events.
733 pub fn can_target(self, can_target: bool) -> Self {
734 Self {
735 builder: self.builder.property("can-target", can_target),
736 }
737 }
738
739 /// A list of css classes applied to this widget.
740 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
741 Self {
742 builder: self.builder.property("css-classes", css_classes.into()),
743 }
744 }
745
746 /// The name of this widget in the CSS tree.
747 ///
748 /// This property is meant to be set by widget implementations,
749 /// typically in their instance init function.
750 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
751 Self {
752 builder: self.builder.property("css-name", css_name.into()),
753 }
754 }
755
756 /// The cursor used by @widget.
757 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
758 Self {
759 builder: self.builder.property("cursor", cursor.clone()),
760 }
761 }
762
763 /// Whether the widget should grab focus when it is clicked with the mouse.
764 ///
765 /// This property is only relevant for widgets that can take focus.
766 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
767 Self {
768 builder: self.builder.property("focus-on-click", focus_on_click),
769 }
770 }
771
772 /// Whether this widget itself will accept the input focus.
773 pub fn focusable(self, focusable: bool) -> Self {
774 Self {
775 builder: self.builder.property("focusable", focusable),
776 }
777 }
778
779 /// How to distribute horizontal space if widget gets extra space.
780 pub fn halign(self, halign: Align) -> Self {
781 Self {
782 builder: self.builder.property("halign", halign),
783 }
784 }
785
786 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
787 /// signal on @widget.
788 ///
789 /// A true value indicates that @widget can have a tooltip, in this case
790 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
791 /// determine whether it will provide a tooltip or not.
792 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
793 Self {
794 builder: self.builder.property("has-tooltip", has_tooltip),
795 }
796 }
797
798 /// Overrides for height request of the widget.
799 ///
800 /// If this is -1, the natural request will be used.
801 pub fn height_request(self, height_request: i32) -> Self {
802 Self {
803 builder: self.builder.property("height-request", height_request),
804 }
805 }
806
807 /// Whether to expand horizontally.
808 pub fn hexpand(self, hexpand: bool) -> Self {
809 Self {
810 builder: self.builder.property("hexpand", hexpand),
811 }
812 }
813
814 /// Whether to use the `hexpand` property.
815 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
816 Self {
817 builder: self.builder.property("hexpand-set", hexpand_set),
818 }
819 }
820
821 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
822 /// the preferred size of the widget, and allocate its children.
823 ///
824 /// This property is meant to be set by widget implementations,
825 /// typically in their instance init function.
826 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
827 Self {
828 builder: self
829 .builder
830 .property("layout-manager", layout_manager.clone().upcast()),
831 }
832 }
833
834 /// Makes this widget act like a modal dialog, with respect to
835 /// event delivery.
836 ///
837 /// Global event controllers will not handle events with targets
838 /// inside the widget, unless they are set up to ignore propagation
839 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
840 #[cfg(feature = "v4_18")]
841 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
842 pub fn limit_events(self, limit_events: bool) -> Self {
843 Self {
844 builder: self.builder.property("limit-events", limit_events),
845 }
846 }
847
848 /// Margin on bottom side of widget.
849 ///
850 /// This property adds margin outside of the widget's normal size
851 /// request, the margin will be added in addition to the size from
852 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
853 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
854 Self {
855 builder: self.builder.property("margin-bottom", margin_bottom),
856 }
857 }
858
859 /// Margin on end of widget, horizontally.
860 ///
861 /// This property supports left-to-right and right-to-left text
862 /// directions.
863 ///
864 /// This property adds margin outside of the widget's normal size
865 /// request, the margin will be added in addition to the size from
866 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
867 pub fn margin_end(self, margin_end: i32) -> Self {
868 Self {
869 builder: self.builder.property("margin-end", margin_end),
870 }
871 }
872
873 /// Margin on start of widget, horizontally.
874 ///
875 /// This property supports left-to-right and right-to-left text
876 /// directions.
877 ///
878 /// This property adds margin outside of the widget's normal size
879 /// request, the margin will be added in addition to the size from
880 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
881 pub fn margin_start(self, margin_start: i32) -> Self {
882 Self {
883 builder: self.builder.property("margin-start", margin_start),
884 }
885 }
886
887 /// Margin on top side of widget.
888 ///
889 /// This property adds margin outside of the widget's normal size
890 /// request, the margin will be added in addition to the size from
891 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
892 pub fn margin_top(self, margin_top: i32) -> Self {
893 Self {
894 builder: self.builder.property("margin-top", margin_top),
895 }
896 }
897
898 /// The name of the widget.
899 pub fn name(self, name: impl Into<glib::GString>) -> Self {
900 Self {
901 builder: self.builder.property("name", name.into()),
902 }
903 }
904
905 /// The requested opacity of the widget.
906 pub fn opacity(self, opacity: f64) -> Self {
907 Self {
908 builder: self.builder.property("opacity", opacity),
909 }
910 }
911
912 /// How content outside the widget's content area is treated.
913 ///
914 /// This property is meant to be set by widget implementations,
915 /// typically in their instance init function.
916 pub fn overflow(self, overflow: Overflow) -> Self {
917 Self {
918 builder: self.builder.property("overflow", overflow),
919 }
920 }
921
922 /// Whether the widget will receive the default action when it is focused.
923 pub fn receives_default(self, receives_default: bool) -> Self {
924 Self {
925 builder: self.builder.property("receives-default", receives_default),
926 }
927 }
928
929 /// Whether the widget responds to input.
930 pub fn sensitive(self, sensitive: bool) -> Self {
931 Self {
932 builder: self.builder.property("sensitive", sensitive),
933 }
934 }
935
936 /// Sets the text of tooltip to be the given string, which is marked up
937 /// with Pango markup.
938 ///
939 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
940 ///
941 /// This is a convenience property which will take care of getting the
942 /// tooltip shown if the given string is not `NULL`:
943 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
944 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
945 /// the default signal handler.
946 ///
947 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
948 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
949 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
950 Self {
951 builder: self
952 .builder
953 .property("tooltip-markup", tooltip_markup.into()),
954 }
955 }
956
957 /// Sets the text of tooltip to be the given string.
958 ///
959 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
960 ///
961 /// This is a convenience property which will take care of getting the
962 /// tooltip shown if the given string is not `NULL`:
963 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
964 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
965 /// the default signal handler.
966 ///
967 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
968 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
969 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
970 Self {
971 builder: self.builder.property("tooltip-text", tooltip_text.into()),
972 }
973 }
974
975 /// How to distribute vertical space if widget gets extra space.
976 pub fn valign(self, valign: Align) -> Self {
977 Self {
978 builder: self.builder.property("valign", valign),
979 }
980 }
981
982 /// Whether to expand vertically.
983 pub fn vexpand(self, vexpand: bool) -> Self {
984 Self {
985 builder: self.builder.property("vexpand", vexpand),
986 }
987 }
988
989 /// Whether to use the `vexpand` property.
990 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
991 Self {
992 builder: self.builder.property("vexpand-set", vexpand_set),
993 }
994 }
995
996 /// Whether the widget is visible.
997 pub fn visible(self, visible: bool) -> Self {
998 Self {
999 builder: self.builder.property("visible", visible),
1000 }
1001 }
1002
1003 /// Overrides for width request of the widget.
1004 ///
1005 /// If this is -1, the natural request will be used.
1006 pub fn width_request(self, width_request: i32) -> Self {
1007 Self {
1008 builder: self.builder.property("width-request", width_request),
1009 }
1010 }
1011
1012 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1013 ///
1014 /// The accessible role cannot be changed once set.
1015 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1016 Self {
1017 builder: self.builder.property("accessible-role", accessible_role),
1018 }
1019 }
1020
1021 // rustdoc-stripper-ignore-next
1022 /// Build the [`Overlay`].
1023 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1024 pub fn build(self) -> Overlay {
1025 assert_initialized_main_thread!();
1026 self.builder.build()
1027 }
1028}