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