gtk/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 gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::translate::*;
9use glib::StaticType;
10use glib::ToValue;
11use glib::Value;
12use gtk_sys;
13use std::fmt;
14use Align;
15use Bin;
16use Buildable;
17use Container;
18use ResizeMode;
19use Widget;
20
21glib_wrapper! {
22    pub struct Overlay(Object<gtk_sys::GtkOverlay, gtk_sys::GtkOverlayClass, OverlayClass>) @extends Bin, Container, Widget, @implements Buildable;
23
24    match fn {
25        get_type => || gtk_sys::gtk_overlay_get_type(),
26    }
27}
28
29impl Overlay {
30    pub fn new() -> Overlay {
31        assert_initialized_main_thread!();
32        unsafe { Widget::from_glib_none(gtk_sys::gtk_overlay_new()).unsafe_cast() }
33    }
34}
35
36impl Default for Overlay {
37    fn default() -> Self {
38        Self::new()
39    }
40}
41
42pub struct OverlayBuilder {
43    border_width: Option<u32>,
44    child: Option<Widget>,
45    resize_mode: Option<ResizeMode>,
46    app_paintable: Option<bool>,
47    can_default: Option<bool>,
48    can_focus: Option<bool>,
49    events: Option<gdk::EventMask>,
50    expand: Option<bool>,
51    #[cfg(any(feature = "v3_20", feature = "dox"))]
52    focus_on_click: Option<bool>,
53    halign: Option<Align>,
54    has_default: Option<bool>,
55    has_focus: Option<bool>,
56    has_tooltip: Option<bool>,
57    height_request: Option<i32>,
58    hexpand: Option<bool>,
59    hexpand_set: Option<bool>,
60    is_focus: Option<bool>,
61    margin: Option<i32>,
62    margin_bottom: Option<i32>,
63    margin_end: Option<i32>,
64    margin_start: Option<i32>,
65    margin_top: Option<i32>,
66    name: Option<String>,
67    no_show_all: Option<bool>,
68    opacity: Option<f64>,
69    parent: Option<Container>,
70    receives_default: Option<bool>,
71    sensitive: Option<bool>,
72    //style: /*Unknown type*/,
73    tooltip_markup: Option<String>,
74    tooltip_text: Option<String>,
75    valign: Option<Align>,
76    vexpand: Option<bool>,
77    vexpand_set: Option<bool>,
78    visible: Option<bool>,
79    width_request: Option<i32>,
80}
81
82impl OverlayBuilder {
83    pub fn new() -> Self {
84        Self {
85            border_width: None,
86            child: None,
87            resize_mode: None,
88            app_paintable: None,
89            can_default: None,
90            can_focus: None,
91            events: None,
92            expand: None,
93            #[cfg(any(feature = "v3_20", feature = "dox"))]
94            focus_on_click: None,
95            halign: None,
96            has_default: None,
97            has_focus: None,
98            has_tooltip: None,
99            height_request: None,
100            hexpand: None,
101            hexpand_set: None,
102            is_focus: None,
103            margin: None,
104            margin_bottom: None,
105            margin_end: None,
106            margin_start: None,
107            margin_top: None,
108            name: None,
109            no_show_all: None,
110            opacity: None,
111            parent: None,
112            receives_default: None,
113            sensitive: None,
114            tooltip_markup: None,
115            tooltip_text: None,
116            valign: None,
117            vexpand: None,
118            vexpand_set: None,
119            visible: None,
120            width_request: None,
121        }
122    }
123
124    pub fn build(self) -> Overlay {
125        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
126        if let Some(ref border_width) = self.border_width {
127            properties.push(("border-width", border_width));
128        }
129        if let Some(ref child) = self.child {
130            properties.push(("child", child));
131        }
132        if let Some(ref resize_mode) = self.resize_mode {
133            properties.push(("resize-mode", resize_mode));
134        }
135        if let Some(ref app_paintable) = self.app_paintable {
136            properties.push(("app-paintable", app_paintable));
137        }
138        if let Some(ref can_default) = self.can_default {
139            properties.push(("can-default", can_default));
140        }
141        if let Some(ref can_focus) = self.can_focus {
142            properties.push(("can-focus", can_focus));
143        }
144        if let Some(ref events) = self.events {
145            properties.push(("events", events));
146        }
147        if let Some(ref expand) = self.expand {
148            properties.push(("expand", expand));
149        }
150        #[cfg(any(feature = "v3_20", feature = "dox"))]
151        {
152            if let Some(ref focus_on_click) = self.focus_on_click {
153                properties.push(("focus-on-click", focus_on_click));
154            }
155        }
156        if let Some(ref halign) = self.halign {
157            properties.push(("halign", halign));
158        }
159        if let Some(ref has_default) = self.has_default {
160            properties.push(("has-default", has_default));
161        }
162        if let Some(ref has_focus) = self.has_focus {
163            properties.push(("has-focus", has_focus));
164        }
165        if let Some(ref has_tooltip) = self.has_tooltip {
166            properties.push(("has-tooltip", has_tooltip));
167        }
168        if let Some(ref height_request) = self.height_request {
169            properties.push(("height-request", height_request));
170        }
171        if let Some(ref hexpand) = self.hexpand {
172            properties.push(("hexpand", hexpand));
173        }
174        if let Some(ref hexpand_set) = self.hexpand_set {
175            properties.push(("hexpand-set", hexpand_set));
176        }
177        if let Some(ref is_focus) = self.is_focus {
178            properties.push(("is-focus", is_focus));
179        }
180        if let Some(ref margin) = self.margin {
181            properties.push(("margin", margin));
182        }
183        if let Some(ref margin_bottom) = self.margin_bottom {
184            properties.push(("margin-bottom", margin_bottom));
185        }
186        if let Some(ref margin_end) = self.margin_end {
187            properties.push(("margin-end", margin_end));
188        }
189        if let Some(ref margin_start) = self.margin_start {
190            properties.push(("margin-start", margin_start));
191        }
192        if let Some(ref margin_top) = self.margin_top {
193            properties.push(("margin-top", margin_top));
194        }
195        if let Some(ref name) = self.name {
196            properties.push(("name", name));
197        }
198        if let Some(ref no_show_all) = self.no_show_all {
199            properties.push(("no-show-all", no_show_all));
200        }
201        if let Some(ref opacity) = self.opacity {
202            properties.push(("opacity", opacity));
203        }
204        if let Some(ref parent) = self.parent {
205            properties.push(("parent", parent));
206        }
207        if let Some(ref receives_default) = self.receives_default {
208            properties.push(("receives-default", receives_default));
209        }
210        if let Some(ref sensitive) = self.sensitive {
211            properties.push(("sensitive", sensitive));
212        }
213        if let Some(ref tooltip_markup) = self.tooltip_markup {
214            properties.push(("tooltip-markup", tooltip_markup));
215        }
216        if let Some(ref tooltip_text) = self.tooltip_text {
217            properties.push(("tooltip-text", tooltip_text));
218        }
219        if let Some(ref valign) = self.valign {
220            properties.push(("valign", valign));
221        }
222        if let Some(ref vexpand) = self.vexpand {
223            properties.push(("vexpand", vexpand));
224        }
225        if let Some(ref vexpand_set) = self.vexpand_set {
226            properties.push(("vexpand-set", vexpand_set));
227        }
228        if let Some(ref visible) = self.visible {
229            properties.push(("visible", visible));
230        }
231        if let Some(ref width_request) = self.width_request {
232            properties.push(("width-request", width_request));
233        }
234        glib::Object::new(Overlay::static_type(), &properties)
235            .expect("object new")
236            .downcast()
237            .expect("downcast")
238    }
239
240    pub fn border_width(mut self, border_width: u32) -> Self {
241        self.border_width = Some(border_width);
242        self
243    }
244
245    pub fn child(mut self, child: &Widget) -> Self {
246        self.child = Some(child.clone());
247        self
248    }
249
250    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
251        self.resize_mode = Some(resize_mode);
252        self
253    }
254
255    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
256        self.app_paintable = Some(app_paintable);
257        self
258    }
259
260    pub fn can_default(mut self, can_default: bool) -> Self {
261        self.can_default = Some(can_default);
262        self
263    }
264
265    pub fn can_focus(mut self, can_focus: bool) -> Self {
266        self.can_focus = Some(can_focus);
267        self
268    }
269
270    pub fn events(mut self, events: gdk::EventMask) -> Self {
271        self.events = Some(events);
272        self
273    }
274
275    pub fn expand(mut self, expand: bool) -> Self {
276        self.expand = Some(expand);
277        self
278    }
279
280    #[cfg(any(feature = "v3_20", feature = "dox"))]
281    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
282        self.focus_on_click = Some(focus_on_click);
283        self
284    }
285
286    pub fn halign(mut self, halign: Align) -> Self {
287        self.halign = Some(halign);
288        self
289    }
290
291    pub fn has_default(mut self, has_default: bool) -> Self {
292        self.has_default = Some(has_default);
293        self
294    }
295
296    pub fn has_focus(mut self, has_focus: bool) -> Self {
297        self.has_focus = Some(has_focus);
298        self
299    }
300
301    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
302        self.has_tooltip = Some(has_tooltip);
303        self
304    }
305
306    pub fn height_request(mut self, height_request: i32) -> Self {
307        self.height_request = Some(height_request);
308        self
309    }
310
311    pub fn hexpand(mut self, hexpand: bool) -> Self {
312        self.hexpand = Some(hexpand);
313        self
314    }
315
316    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
317        self.hexpand_set = Some(hexpand_set);
318        self
319    }
320
321    pub fn is_focus(mut self, is_focus: bool) -> Self {
322        self.is_focus = Some(is_focus);
323        self
324    }
325
326    pub fn margin(mut self, margin: i32) -> Self {
327        self.margin = Some(margin);
328        self
329    }
330
331    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
332        self.margin_bottom = Some(margin_bottom);
333        self
334    }
335
336    pub fn margin_end(mut self, margin_end: i32) -> Self {
337        self.margin_end = Some(margin_end);
338        self
339    }
340
341    pub fn margin_start(mut self, margin_start: i32) -> Self {
342        self.margin_start = Some(margin_start);
343        self
344    }
345
346    pub fn margin_top(mut self, margin_top: i32) -> Self {
347        self.margin_top = Some(margin_top);
348        self
349    }
350
351    pub fn name(mut self, name: &str) -> Self {
352        self.name = Some(name.to_string());
353        self
354    }
355
356    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
357        self.no_show_all = Some(no_show_all);
358        self
359    }
360
361    pub fn opacity(mut self, opacity: f64) -> Self {
362        self.opacity = Some(opacity);
363        self
364    }
365
366    pub fn parent(mut self, parent: &Container) -> Self {
367        self.parent = Some(parent.clone());
368        self
369    }
370
371    pub fn receives_default(mut self, receives_default: bool) -> Self {
372        self.receives_default = Some(receives_default);
373        self
374    }
375
376    pub fn sensitive(mut self, sensitive: bool) -> Self {
377        self.sensitive = Some(sensitive);
378        self
379    }
380
381    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
382        self.tooltip_markup = Some(tooltip_markup.to_string());
383        self
384    }
385
386    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
387        self.tooltip_text = Some(tooltip_text.to_string());
388        self
389    }
390
391    pub fn valign(mut self, valign: Align) -> Self {
392        self.valign = Some(valign);
393        self
394    }
395
396    pub fn vexpand(mut self, vexpand: bool) -> Self {
397        self.vexpand = Some(vexpand);
398        self
399    }
400
401    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
402        self.vexpand_set = Some(vexpand_set);
403        self
404    }
405
406    pub fn visible(mut self, visible: bool) -> Self {
407        self.visible = Some(visible);
408        self
409    }
410
411    pub fn width_request(mut self, width_request: i32) -> Self {
412        self.width_request = Some(width_request);
413        self
414    }
415}
416
417pub const NONE_OVERLAY: Option<&Overlay> = None;
418
419pub trait OverlayExt: 'static {
420    fn add_overlay<P: IsA<Widget>>(&self, widget: &P);
421
422    #[cfg(any(feature = "v3_18", feature = "dox"))]
423    fn get_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P) -> bool;
424
425    #[cfg(any(feature = "v3_18", feature = "dox"))]
426    fn reorder_overlay<P: IsA<Widget>>(&self, child: &P, position: i32);
427
428    #[cfg(any(feature = "v3_18", feature = "dox"))]
429    fn set_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P, pass_through: bool);
430
431    fn get_child_index<T: IsA<Widget>>(&self, item: &T) -> i32;
432
433    fn set_child_index<T: IsA<Widget>>(&self, item: &T, index: i32);
434
435    //fn connect_get_child_position<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId;
436}
437
438impl<O: IsA<Overlay>> OverlayExt for O {
439    fn add_overlay<P: IsA<Widget>>(&self, widget: &P) {
440        unsafe {
441            gtk_sys::gtk_overlay_add_overlay(
442                self.as_ref().to_glib_none().0,
443                widget.as_ref().to_glib_none().0,
444            );
445        }
446    }
447
448    #[cfg(any(feature = "v3_18", feature = "dox"))]
449    fn get_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P) -> bool {
450        unsafe {
451            from_glib(gtk_sys::gtk_overlay_get_overlay_pass_through(
452                self.as_ref().to_glib_none().0,
453                widget.as_ref().to_glib_none().0,
454            ))
455        }
456    }
457
458    #[cfg(any(feature = "v3_18", feature = "dox"))]
459    fn reorder_overlay<P: IsA<Widget>>(&self, child: &P, position: i32) {
460        unsafe {
461            gtk_sys::gtk_overlay_reorder_overlay(
462                self.as_ref().to_glib_none().0,
463                child.as_ref().to_glib_none().0,
464                position,
465            );
466        }
467    }
468
469    #[cfg(any(feature = "v3_18", feature = "dox"))]
470    fn set_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P, pass_through: bool) {
471        unsafe {
472            gtk_sys::gtk_overlay_set_overlay_pass_through(
473                self.as_ref().to_glib_none().0,
474                widget.as_ref().to_glib_none().0,
475                pass_through.to_glib(),
476            );
477        }
478    }
479
480    fn get_child_index<T: IsA<Widget>>(&self, item: &T) -> i32 {
481        unsafe {
482            let mut value = Value::from_type(<i32 as StaticType>::static_type());
483            gtk_sys::gtk_container_child_get_property(
484                self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
485                item.to_glib_none().0 as *mut _,
486                b"index\0".as_ptr() as *const _,
487                value.to_glib_none_mut().0,
488            );
489            value.get().unwrap()
490        }
491    }
492
493    fn set_child_index<T: IsA<Widget>>(&self, item: &T, index: i32) {
494        unsafe {
495            gtk_sys::gtk_container_child_set_property(
496                self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
497                item.to_glib_none().0 as *mut _,
498                b"index\0".as_ptr() as *const _,
499                Value::from(&index).to_glib_none().0,
500            );
501        }
502    }
503
504    //fn connect_get_child_position<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
505    //    Out allocation: Gdk.Rectangle
506    //}
507}
508
509impl fmt::Display for Overlay {
510    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
511        write!(f, "Overlay")
512    }
513}