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