gtk4/auto/gl_area.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#![allow(deprecated)]
5
6#[cfg(feature = "v4_10")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
8use crate::Accessible;
9use crate::{
10 AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow, Widget, ffi,
11};
12use glib::{
13 object::ObjectType as _,
14 prelude::*,
15 signal::{SignalHandlerId, connect_raw},
16 translate::*,
17};
18use std::boxed::Box as Box_;
19
20#[cfg(feature = "v4_10")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
22glib::wrapper! {
23 /// error);
24 /// if (error != NULL)
25 /// {
26 /// gtk_gl_area_set_error (area, error);
27 /// g_error_free (error);
28 /// return;
29 /// }
30 /// }
31 /// ```text
32 ///
33 /// If you need to change the options for creating the [`gdk::GLContext`][crate::gdk::GLContext]
34 /// you should use the [`create-context`][struct@crate::GLArea#create-context] signal.
35 ///
36 /// ## Properties
37 ///
38 ///
39 /// #### `allowed-apis`
40 /// The allowed APIs.
41 ///
42 /// Readable | Writable
43 ///
44 ///
45 /// #### `api`
46 /// The API currently in use.
47 ///
48 /// Readable
49 ///
50 ///
51 /// #### `auto-render`
52 /// If set to [`true`] the ::render signal will be emitted every time
53 /// the widget draws.
54 ///
55 /// This is the default and is useful if drawing the widget is faster.
56 ///
57 /// If set to [`false`] the data from previous rendering is kept around and will
58 /// be used for drawing the widget the next time, unless the window is resized.
59 /// In order to force a rendering [`GLAreaExt::queue_render()`][crate::prelude::GLAreaExt::queue_render()] must be called.
60 /// This mode is useful when the scene changes seldom, but takes a long time
61 /// to redraw.
62 ///
63 /// Readable | Writable
64 ///
65 ///
66 /// #### `context`
67 /// The [`gdk::GLContext`][crate::gdk::GLContext] used by the [`GLArea`][crate::GLArea] widget.
68 ///
69 /// The [`GLArea`][crate::GLArea] widget is responsible for creating the [`gdk::GLContext`][crate::gdk::GLContext]
70 /// instance. If you need to render with other kinds of buffers (stencil,
71 /// depth, etc), use render buffers.
72 ///
73 /// Readable
74 ///
75 ///
76 /// #### `has-depth-buffer`
77 /// If set to [`true`] the widget will allocate and enable a depth buffer for the
78 /// target framebuffer.
79 ///
80 /// Setting this property will enable GL's depth testing as a side effect. If
81 /// you don't need depth testing, you should call `glDisable(GL_DEPTH_TEST)`
82 /// in your `GtkGLArea::render` handler.
83 ///
84 /// Readable | Writable
85 ///
86 ///
87 /// #### `has-stencil-buffer`
88 /// If set to [`true`] the widget will allocate and enable a stencil buffer for the
89 /// target framebuffer.
90 ///
91 /// Readable | Writable
92 ///
93 ///
94 /// #### `use-es`
95 /// If set to [`true`] the widget will try to create a [`gdk::GLContext`][crate::gdk::GLContext] using
96 /// OpenGL ES instead of OpenGL.
97 ///
98 /// Readable | Writable
99 /// <details><summary><h4>Widget</h4></summary>
100 ///
101 ///
102 /// #### `can-focus`
103 /// Whether the widget or any of its descendents can accept
104 /// the input focus.
105 ///
106 /// This property is meant to be set by widget implementations,
107 /// typically in their instance init function.
108 ///
109 /// Readable | Writable
110 ///
111 ///
112 /// #### `can-target`
113 /// Whether the widget can receive pointer events.
114 ///
115 /// Readable | Writable
116 ///
117 ///
118 /// #### `css-classes`
119 /// A list of css classes applied to this widget.
120 ///
121 /// Readable | Writable
122 ///
123 ///
124 /// #### `css-name`
125 /// The name of this widget in the CSS tree.
126 ///
127 /// This property is meant to be set by widget implementations,
128 /// typically in their instance init function.
129 ///
130 /// Readable | Writable | Construct Only
131 ///
132 ///
133 /// #### `cursor`
134 /// The cursor used by @widget.
135 ///
136 /// Readable | Writable
137 ///
138 ///
139 /// #### `focus-on-click`
140 /// Whether the widget should grab focus when it is clicked with the mouse.
141 ///
142 /// This property is only relevant for widgets that can take focus.
143 ///
144 /// Readable | Writable
145 ///
146 ///
147 /// #### `focusable`
148 /// Whether this widget itself will accept the input focus.
149 ///
150 /// Readable | Writable
151 ///
152 ///
153 /// #### `halign`
154 /// How to distribute horizontal space if widget gets extra space.
155 ///
156 /// Readable | Writable
157 ///
158 ///
159 /// #### `has-default`
160 /// Whether the widget is the default widget.
161 ///
162 /// Readable
163 ///
164 ///
165 /// #### `has-focus`
166 /// Whether the widget has the input focus.
167 ///
168 /// Readable
169 ///
170 ///
171 /// #### `has-tooltip`
172 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
173 /// signal on @widget.
174 ///
175 /// A true value indicates that @widget can have a tooltip, in this case
176 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
177 /// determine whether it will provide a tooltip or not.
178 ///
179 /// Readable | Writable
180 ///
181 ///
182 /// #### `height-request`
183 /// Overrides for height request of the widget.
184 ///
185 /// If this is -1, the natural request will be used.
186 ///
187 /// Readable | Writable
188 ///
189 ///
190 /// #### `hexpand`
191 /// Whether to expand horizontally.
192 ///
193 /// Readable | Writable
194 ///
195 ///
196 /// #### `hexpand-set`
197 /// Whether to use the `hexpand` property.
198 ///
199 /// Readable | Writable
200 ///
201 ///
202 /// #### `layout-manager`
203 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
204 /// the preferred size of the widget, and allocate its children.
205 ///
206 /// This property is meant to be set by widget implementations,
207 /// typically in their instance init function.
208 ///
209 /// Readable | Writable
210 ///
211 ///
212 /// #### `limit-events`
213 /// Makes this widget act like a modal dialog, with respect to
214 /// event delivery.
215 ///
216 /// Global event controllers will not handle events with targets
217 /// inside the widget, unless they are set up to ignore propagation
218 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
219 ///
220 /// Readable | Writable
221 ///
222 ///
223 /// #### `margin-bottom`
224 /// Margin on bottom 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 /// #### `margin-end`
234 /// Margin on end of widget, horizontally.
235 ///
236 /// This property supports left-to-right and right-to-left text
237 /// directions.
238 ///
239 /// This property adds margin outside of the widget's normal size
240 /// request, the margin will be added in addition to the size from
241 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
242 ///
243 /// Readable | Writable
244 ///
245 ///
246 /// #### `margin-start`
247 /// Margin on start of widget, horizontally.
248 ///
249 /// This property supports left-to-right and right-to-left text
250 /// directions.
251 ///
252 /// This property adds margin outside of the widget's normal size
253 /// request, the margin will be added in addition to the size from
254 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
255 ///
256 /// Readable | Writable
257 ///
258 ///
259 /// #### `margin-top`
260 /// Margin on top side of widget.
261 ///
262 /// This property adds margin outside of the widget's normal size
263 /// request, the margin will be added in addition to the size from
264 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
265 ///
266 /// Readable | Writable
267 ///
268 ///
269 /// #### `name`
270 /// The name of the widget.
271 ///
272 /// Readable | Writable
273 ///
274 ///
275 /// #### `opacity`
276 /// The requested opacity of the widget.
277 ///
278 /// Readable | Writable
279 ///
280 ///
281 /// #### `overflow`
282 /// How content outside the widget's content area is treated.
283 ///
284 /// This property is meant to be set by widget implementations,
285 /// typically in their instance init function.
286 ///
287 /// Readable | Writable
288 ///
289 ///
290 /// #### `parent`
291 /// The parent widget of this widget.
292 ///
293 /// Readable
294 ///
295 ///
296 /// #### `receives-default`
297 /// Whether the widget will receive the default action when it is focused.
298 ///
299 /// Readable | Writable
300 ///
301 ///
302 /// #### `root`
303 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
304 ///
305 /// This will be `NULL` if the widget is not contained in a root widget.
306 ///
307 /// Readable
308 ///
309 ///
310 /// #### `scale-factor`
311 /// The scale factor of the widget.
312 ///
313 /// Readable
314 ///
315 ///
316 /// #### `sensitive`
317 /// Whether the widget responds to input.
318 ///
319 /// Readable | Writable
320 ///
321 ///
322 /// #### `tooltip-markup`
323 /// Sets the text of tooltip to be the given string, which is marked up
324 /// with Pango markup.
325 ///
326 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
327 ///
328 /// This is a convenience property which will take care of getting the
329 /// tooltip shown if the given string is not `NULL`:
330 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
331 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
332 /// the default signal handler.
333 ///
334 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
335 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
336 ///
337 /// Readable | Writable
338 ///
339 ///
340 /// #### `tooltip-text`
341 /// Sets the text of tooltip to be the given string.
342 ///
343 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
344 ///
345 /// This is a convenience property which will take care of getting the
346 /// tooltip shown if the given string is not `NULL`:
347 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
348 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
349 /// the default signal handler.
350 ///
351 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
352 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
353 ///
354 /// Readable | Writable
355 ///
356 ///
357 /// #### `valign`
358 /// How to distribute vertical space if widget gets extra space.
359 ///
360 /// Readable | Writable
361 ///
362 ///
363 /// #### `vexpand`
364 /// Whether to expand vertically.
365 ///
366 /// Readable | Writable
367 ///
368 ///
369 /// #### `vexpand-set`
370 /// Whether to use the `vexpand` property.
371 ///
372 /// Readable | Writable
373 ///
374 ///
375 /// #### `visible`
376 /// Whether the widget is visible.
377 ///
378 /// Readable | Writable
379 ///
380 ///
381 /// #### `width-request`
382 /// Overrides for width request of the widget.
383 ///
384 /// If this is -1, the natural request will be used.
385 ///
386 /// Readable | Writable
387 /// </details>
388 /// <details><summary><h4>Accessible</h4></summary>
389 ///
390 ///
391 /// #### `accessible-role`
392 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
393 ///
394 /// The accessible role cannot be changed once set.
395 ///
396 /// Readable | Writable
397 /// </details>
398 ///
399 /// ## Signals
400 ///
401 ///
402 /// #### `create-context`
403 /// Emitted when the widget is being realized.
404 ///
405 /// This allows you to override how the GL context is created.
406 /// This is useful when you want to reuse an existing GL context,
407 /// or if you want to try creating different kinds of GL options.
408 ///
409 /// If context creation fails then the signal handler can use
410 /// [`GLAreaExt::set_error()`][crate::prelude::GLAreaExt::set_error()] to register a more detailed error
411 /// of how the construction failed.
412 ///
413 ///
414 ///
415 ///
416 /// #### `render`
417 /// Emitted every time the contents of the [`GLArea`][crate::GLArea] should be redrawn.
418 ///
419 /// The @context is bound to the @area prior to emitting this function,
420 /// and the buffers are painted to the window once the emission terminates.
421 ///
422 ///
423 ///
424 ///
425 /// #### `resize`
426 /// Emitted once when the widget is realized, and then each time the widget
427 /// is changed while realized.
428 ///
429 /// This is useful in order to keep GL state up to date with the widget size,
430 /// like for instance camera properties which may depend on the width/height
431 /// ratio.
432 ///
433 /// The GL context for the area is guaranteed to be current when this signal
434 /// is emitted.
435 ///
436 /// The default handler sets up the GL viewport.
437 ///
438 ///
439 /// <details><summary><h4>Widget</h4></summary>
440 ///
441 ///
442 /// #### `destroy`
443 /// Signals that all holders of a reference to the widget should release
444 /// the reference that they hold.
445 ///
446 /// May result in finalization of the widget if all references are released.
447 ///
448 /// This signal is not suitable for saving widget state.
449 ///
450 ///
451 ///
452 ///
453 /// #### `direction-changed`
454 /// Emitted when the text direction of a widget changes.
455 ///
456 ///
457 ///
458 ///
459 /// #### `hide`
460 /// Emitted when @widget is hidden.
461 ///
462 ///
463 ///
464 ///
465 /// #### `keynav-failed`
466 /// Emitted if keyboard navigation fails.
467 ///
468 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
469 ///
470 ///
471 ///
472 ///
473 /// #### `map`
474 /// Emitted when @widget is going to be mapped.
475 ///
476 /// A widget is mapped when the widget is visible (which is controlled with
477 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
478 /// are also visible.
479 ///
480 /// The `::map` signal can be used to determine whether a widget will be drawn,
481 /// for instance it can resume an animation that was stopped during the
482 /// emission of [`unmap`][struct@crate::Widget#unmap].
483 ///
484 ///
485 ///
486 ///
487 /// #### `mnemonic-activate`
488 /// Emitted when a widget is activated via a mnemonic.
489 ///
490 /// The default handler for this signal activates @widget if @group_cycling
491 /// is false, or just makes @widget grab focus if @group_cycling is true.
492 ///
493 ///
494 ///
495 ///
496 /// #### `move-focus`
497 /// to move backward.
498 ///
499 /// Action
500 ///
501 ///
502 /// #### `query-tooltip`
503 /// s tooltip is about to be shown.
504 ///
505 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
506 /// is true and the hover timeout has expired with the cursor hovering
507 /// above @widget; or emitted when @widget got focus in keyboard mode.
508 ///
509 /// Using the given coordinates, the signal handler should determine
510 /// whether a tooltip should be shown for @widget. If this is the case
511 /// true should be returned, false otherwise. Note that if @keyboard_mode
512 /// is true, the values of @x and @y are undefined and should not be used.
513 ///
514 /// The signal handler is free to manipulate @tooltip with the therefore
515 /// destined function calls.
516 ///
517 ///
518 ///
519 ///
520 /// #### `realize`
521 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
522 ///
523 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
524 /// or the widget has been mapped (that is, it is going to be drawn).
525 ///
526 ///
527 ///
528 ///
529 /// #### `show`
530 /// Emitted when @widget is shown.
531 ///
532 ///
533 ///
534 ///
535 /// #### `state-flags-changed`
536 /// Emitted when the widget state changes.
537 ///
538 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
539 ///
540 ///
541 ///
542 ///
543 /// #### `unmap`
544 /// Emitted when @widget is going to be unmapped.
545 ///
546 /// A widget is unmapped when either it or any of its parents up to the
547 /// toplevel widget have been set as hidden.
548 ///
549 /// As `::unmap` indicates that a widget will not be shown any longer,
550 /// it can be used to, for example, stop an animation on the widget.
551 ///
552 ///
553 ///
554 ///
555 /// #### `unrealize`
556 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
557 ///
558 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
559 /// or the widget has been unmapped (that is, it is going to be hidden).
560 ///
561 ///
562 /// </details>
563 ///
564 /// # Implements
565 ///
566 /// [`GLAreaExt`][trait@crate::prelude::GLAreaExt], [`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]
567 #[doc(alias = "GtkGLArea")]
568 pub struct GLArea(Object<ffi::GtkGLArea, ffi::GtkGLAreaClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
569
570 match fn {
571 type_ => || ffi::gtk_gl_area_get_type(),
572 }
573}
574
575#[cfg(not(feature = "v4_10"))]
576glib::wrapper! {
577 #[doc(alias = "GtkGLArea")]
578 pub struct GLArea(Object<ffi::GtkGLArea, ffi::GtkGLAreaClass>) @extends Widget, @implements Buildable, ConstraintTarget;
579
580 match fn {
581 type_ => || ffi::gtk_gl_area_get_type(),
582 }
583}
584
585impl GLArea {
586 pub const NONE: Option<&'static GLArea> = None;
587
588 /// Creates a new [`GLArea`][crate::GLArea] widget.
589 ///
590 /// # Returns
591 ///
592 /// a new [`GLArea`][crate::GLArea]
593 #[doc(alias = "gtk_gl_area_new")]
594 pub fn new() -> GLArea {
595 assert_initialized_main_thread!();
596 unsafe { Widget::from_glib_none(ffi::gtk_gl_area_new()).unsafe_cast() }
597 }
598
599 // rustdoc-stripper-ignore-next
600 /// Creates a new builder-pattern struct instance to construct [`GLArea`] objects.
601 ///
602 /// This method returns an instance of [`GLAreaBuilder`](crate::builders::GLAreaBuilder) which can be used to create [`GLArea`] objects.
603 pub fn builder() -> GLAreaBuilder {
604 GLAreaBuilder::new()
605 }
606}
607
608impl Default for GLArea {
609 fn default() -> Self {
610 Self::new()
611 }
612}
613
614// rustdoc-stripper-ignore-next
615/// A [builder-pattern] type to construct [`GLArea`] objects.
616///
617/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
618#[must_use = "The builder must be built to be used"]
619pub struct GLAreaBuilder {
620 builder: glib::object::ObjectBuilder<'static, GLArea>,
621}
622
623impl GLAreaBuilder {
624 fn new() -> Self {
625 Self {
626 builder: glib::object::Object::builder(),
627 }
628 }
629
630 /// The allowed APIs.
631 #[cfg(feature = "v4_12")]
632 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
633 pub fn allowed_apis(self, allowed_apis: gdk::GLAPI) -> Self {
634 Self {
635 builder: self.builder.property("allowed-apis", allowed_apis),
636 }
637 }
638
639 /// If set to [`true`] the ::render signal will be emitted every time
640 /// the widget draws.
641 ///
642 /// This is the default and is useful if drawing the widget is faster.
643 ///
644 /// If set to [`false`] the data from previous rendering is kept around and will
645 /// be used for drawing the widget the next time, unless the window is resized.
646 /// In order to force a rendering [`GLAreaExt::queue_render()`][crate::prelude::GLAreaExt::queue_render()] must be called.
647 /// This mode is useful when the scene changes seldom, but takes a long time
648 /// to redraw.
649 pub fn auto_render(self, auto_render: bool) -> Self {
650 Self {
651 builder: self.builder.property("auto-render", auto_render),
652 }
653 }
654
655 /// If set to [`true`] the widget will allocate and enable a depth buffer for the
656 /// target framebuffer.
657 ///
658 /// Setting this property will enable GL's depth testing as a side effect. If
659 /// you don't need depth testing, you should call `glDisable(GL_DEPTH_TEST)`
660 /// in your `GtkGLArea::render` handler.
661 pub fn has_depth_buffer(self, has_depth_buffer: bool) -> Self {
662 Self {
663 builder: self.builder.property("has-depth-buffer", has_depth_buffer),
664 }
665 }
666
667 /// If set to [`true`] the widget will allocate and enable a stencil buffer for the
668 /// target framebuffer.
669 pub fn has_stencil_buffer(self, has_stencil_buffer: bool) -> Self {
670 Self {
671 builder: self
672 .builder
673 .property("has-stencil-buffer", has_stencil_buffer),
674 }
675 }
676
677 /// If set to [`true`] the widget will try to create a [`gdk::GLContext`][crate::gdk::GLContext] using
678 /// OpenGL ES instead of OpenGL.
679 /// Use [`allowed-apis`][struct@crate::GLArea#allowed-apis]
680 #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
681 pub fn use_es(self, use_es: bool) -> Self {
682 Self {
683 builder: self.builder.property("use-es", use_es),
684 }
685 }
686
687 /// Whether the widget or any of its descendents can accept
688 /// the input focus.
689 ///
690 /// This property is meant to be set by widget implementations,
691 /// typically in their instance init function.
692 pub fn can_focus(self, can_focus: bool) -> Self {
693 Self {
694 builder: self.builder.property("can-focus", can_focus),
695 }
696 }
697
698 /// Whether the widget can receive pointer events.
699 pub fn can_target(self, can_target: bool) -> Self {
700 Self {
701 builder: self.builder.property("can-target", can_target),
702 }
703 }
704
705 /// A list of css classes applied to this widget.
706 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
707 Self {
708 builder: self.builder.property("css-classes", css_classes.into()),
709 }
710 }
711
712 /// The name of this widget in the CSS tree.
713 ///
714 /// This property is meant to be set by widget implementations,
715 /// typically in their instance init function.
716 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
717 Self {
718 builder: self.builder.property("css-name", css_name.into()),
719 }
720 }
721
722 /// The cursor used by @widget.
723 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
724 Self {
725 builder: self.builder.property("cursor", cursor.clone()),
726 }
727 }
728
729 /// Whether the widget should grab focus when it is clicked with the mouse.
730 ///
731 /// This property is only relevant for widgets that can take focus.
732 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
733 Self {
734 builder: self.builder.property("focus-on-click", focus_on_click),
735 }
736 }
737
738 /// Whether this widget itself will accept the input focus.
739 pub fn focusable(self, focusable: bool) -> Self {
740 Self {
741 builder: self.builder.property("focusable", focusable),
742 }
743 }
744
745 /// How to distribute horizontal space if widget gets extra space.
746 pub fn halign(self, halign: Align) -> Self {
747 Self {
748 builder: self.builder.property("halign", halign),
749 }
750 }
751
752 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
753 /// signal on @widget.
754 ///
755 /// A true value indicates that @widget can have a tooltip, in this case
756 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
757 /// determine whether it will provide a tooltip or not.
758 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
759 Self {
760 builder: self.builder.property("has-tooltip", has_tooltip),
761 }
762 }
763
764 /// Overrides for height request of the widget.
765 ///
766 /// If this is -1, the natural request will be used.
767 pub fn height_request(self, height_request: i32) -> Self {
768 Self {
769 builder: self.builder.property("height-request", height_request),
770 }
771 }
772
773 /// Whether to expand horizontally.
774 pub fn hexpand(self, hexpand: bool) -> Self {
775 Self {
776 builder: self.builder.property("hexpand", hexpand),
777 }
778 }
779
780 /// Whether to use the `hexpand` property.
781 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
782 Self {
783 builder: self.builder.property("hexpand-set", hexpand_set),
784 }
785 }
786
787 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
788 /// the preferred size of the widget, and allocate its children.
789 ///
790 /// This property is meant to be set by widget implementations,
791 /// typically in their instance init function.
792 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
793 Self {
794 builder: self
795 .builder
796 .property("layout-manager", layout_manager.clone().upcast()),
797 }
798 }
799
800 /// Makes this widget act like a modal dialog, with respect to
801 /// event delivery.
802 ///
803 /// Global event controllers will not handle events with targets
804 /// inside the widget, unless they are set up to ignore propagation
805 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
806 #[cfg(feature = "v4_18")]
807 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
808 pub fn limit_events(self, limit_events: bool) -> Self {
809 Self {
810 builder: self.builder.property("limit-events", limit_events),
811 }
812 }
813
814 /// Margin on bottom side of widget.
815 ///
816 /// This property adds margin outside of the widget's normal size
817 /// request, the margin will be added in addition to the size from
818 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
819 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
820 Self {
821 builder: self.builder.property("margin-bottom", margin_bottom),
822 }
823 }
824
825 /// Margin on end of widget, horizontally.
826 ///
827 /// This property supports left-to-right and right-to-left text
828 /// directions.
829 ///
830 /// This property adds margin outside of the widget's normal size
831 /// request, the margin will be added in addition to the size from
832 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
833 pub fn margin_end(self, margin_end: i32) -> Self {
834 Self {
835 builder: self.builder.property("margin-end", margin_end),
836 }
837 }
838
839 /// Margin on start of widget, horizontally.
840 ///
841 /// This property supports left-to-right and right-to-left text
842 /// directions.
843 ///
844 /// This property adds margin outside of the widget's normal size
845 /// request, the margin will be added in addition to the size from
846 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
847 pub fn margin_start(self, margin_start: i32) -> Self {
848 Self {
849 builder: self.builder.property("margin-start", margin_start),
850 }
851 }
852
853 /// Margin on top side of widget.
854 ///
855 /// This property adds margin outside of the widget's normal size
856 /// request, the margin will be added in addition to the size from
857 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
858 pub fn margin_top(self, margin_top: i32) -> Self {
859 Self {
860 builder: self.builder.property("margin-top", margin_top),
861 }
862 }
863
864 /// The name of the widget.
865 pub fn name(self, name: impl Into<glib::GString>) -> Self {
866 Self {
867 builder: self.builder.property("name", name.into()),
868 }
869 }
870
871 /// The requested opacity of the widget.
872 pub fn opacity(self, opacity: f64) -> Self {
873 Self {
874 builder: self.builder.property("opacity", opacity),
875 }
876 }
877
878 /// How content outside the widget's content area is treated.
879 ///
880 /// This property is meant to be set by widget implementations,
881 /// typically in their instance init function.
882 pub fn overflow(self, overflow: Overflow) -> Self {
883 Self {
884 builder: self.builder.property("overflow", overflow),
885 }
886 }
887
888 /// Whether the widget will receive the default action when it is focused.
889 pub fn receives_default(self, receives_default: bool) -> Self {
890 Self {
891 builder: self.builder.property("receives-default", receives_default),
892 }
893 }
894
895 /// Whether the widget responds to input.
896 pub fn sensitive(self, sensitive: bool) -> Self {
897 Self {
898 builder: self.builder.property("sensitive", sensitive),
899 }
900 }
901
902 /// Sets the text of tooltip to be the given string, which is marked up
903 /// with Pango markup.
904 ///
905 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
906 ///
907 /// This is a convenience property which will take care of getting the
908 /// tooltip shown if the given string is not `NULL`:
909 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
910 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
911 /// the default signal handler.
912 ///
913 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
914 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
915 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
916 Self {
917 builder: self
918 .builder
919 .property("tooltip-markup", tooltip_markup.into()),
920 }
921 }
922
923 /// Sets the text of tooltip to be the given string.
924 ///
925 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
926 ///
927 /// This is a convenience property which will take care of getting the
928 /// tooltip shown if the given string is not `NULL`:
929 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
930 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
931 /// the default signal handler.
932 ///
933 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
934 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
935 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
936 Self {
937 builder: self.builder.property("tooltip-text", tooltip_text.into()),
938 }
939 }
940
941 /// How to distribute vertical space if widget gets extra space.
942 pub fn valign(self, valign: Align) -> Self {
943 Self {
944 builder: self.builder.property("valign", valign),
945 }
946 }
947
948 /// Whether to expand vertically.
949 pub fn vexpand(self, vexpand: bool) -> Self {
950 Self {
951 builder: self.builder.property("vexpand", vexpand),
952 }
953 }
954
955 /// Whether to use the `vexpand` property.
956 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
957 Self {
958 builder: self.builder.property("vexpand-set", vexpand_set),
959 }
960 }
961
962 /// Whether the widget is visible.
963 pub fn visible(self, visible: bool) -> Self {
964 Self {
965 builder: self.builder.property("visible", visible),
966 }
967 }
968
969 /// Overrides for width request of the widget.
970 ///
971 /// If this is -1, the natural request will be used.
972 pub fn width_request(self, width_request: i32) -> Self {
973 Self {
974 builder: self.builder.property("width-request", width_request),
975 }
976 }
977
978 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
979 ///
980 /// The accessible role cannot be changed once set.
981 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
982 Self {
983 builder: self.builder.property("accessible-role", accessible_role),
984 }
985 }
986
987 // rustdoc-stripper-ignore-next
988 /// Build the [`GLArea`].
989 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
990 pub fn build(self) -> GLArea {
991 assert_initialized_main_thread!();
992 self.builder.build()
993 }
994}
995
996/// Trait containing all [`struct@GLArea`] methods.
997///
998/// # Implementors
999///
1000/// [`GLArea`][struct@crate::GLArea]
1001pub trait GLAreaExt: IsA<GLArea> + 'static {
1002 /// Binds buffers to the framebuffer.
1003 ///
1004 /// Ensures that the @self framebuffer object is made the current draw
1005 /// and read target, and that all the required buffers for the @self
1006 /// are created and bound to the framebuffer.
1007 ///
1008 /// This function is automatically called before emitting the
1009 /// [`render`][struct@crate::GLArea#render] signal, and doesn't normally need to be
1010 /// called by application code.
1011 #[doc(alias = "gtk_gl_area_attach_buffers")]
1012 fn attach_buffers(&self) {
1013 unsafe {
1014 ffi::gtk_gl_area_attach_buffers(self.as_ref().to_glib_none().0);
1015 }
1016 }
1017
1018 /// Gets the allowed APIs.
1019 ///
1020 /// See [`set_allowed_apis()`][Self::set_allowed_apis()].
1021 ///
1022 /// # Returns
1023 ///
1024 /// the allowed APIs
1025 #[cfg(feature = "v4_12")]
1026 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1027 #[doc(alias = "gtk_gl_area_get_allowed_apis")]
1028 #[doc(alias = "get_allowed_apis")]
1029 #[doc(alias = "allowed-apis")]
1030 fn allowed_apis(&self) -> gdk::GLAPI {
1031 unsafe {
1032 from_glib(ffi::gtk_gl_area_get_allowed_apis(
1033 self.as_ref().to_glib_none().0,
1034 ))
1035 }
1036 }
1037
1038 /// Gets the API that is currently in use.
1039 ///
1040 /// If the GL area has not been realized yet, 0 is returned.
1041 ///
1042 /// # Returns
1043 ///
1044 /// the currently used API
1045 #[cfg(feature = "v4_12")]
1046 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1047 #[doc(alias = "gtk_gl_area_get_api")]
1048 #[doc(alias = "get_api")]
1049 fn api(&self) -> gdk::GLAPI {
1050 unsafe { from_glib(ffi::gtk_gl_area_get_api(self.as_ref().to_glib_none().0)) }
1051 }
1052
1053 /// Returns whether the area is in auto render mode or not.
1054 ///
1055 /// # Returns
1056 ///
1057 /// [`true`] if the @self is auto rendering, [`false`] otherwise
1058 #[doc(alias = "gtk_gl_area_get_auto_render")]
1059 #[doc(alias = "get_auto_render")]
1060 #[doc(alias = "auto-render")]
1061 fn is_auto_render(&self) -> bool {
1062 unsafe {
1063 from_glib(ffi::gtk_gl_area_get_auto_render(
1064 self.as_ref().to_glib_none().0,
1065 ))
1066 }
1067 }
1068
1069 /// Retrieves the [`gdk::GLContext`][crate::gdk::GLContext] used by @self.
1070 ///
1071 /// # Returns
1072 ///
1073 /// the [`gdk::GLContext`][crate::gdk::GLContext]
1074 #[doc(alias = "gtk_gl_area_get_context")]
1075 #[doc(alias = "get_context")]
1076 fn context(&self) -> Option<gdk::GLContext> {
1077 unsafe { from_glib_none(ffi::gtk_gl_area_get_context(self.as_ref().to_glib_none().0)) }
1078 }
1079
1080 /// Gets the current error set on the @self.
1081 ///
1082 /// # Returns
1083 ///
1084 /// the `GError`
1085 #[doc(alias = "gtk_gl_area_get_error")]
1086 #[doc(alias = "get_error")]
1087 fn error(&self) -> Option<glib::Error> {
1088 unsafe { from_glib_none(ffi::gtk_gl_area_get_error(self.as_ref().to_glib_none().0)) }
1089 }
1090
1091 /// Returns whether the area has a depth buffer.
1092 ///
1093 /// # Returns
1094 ///
1095 /// [`true`] if the @self has a depth buffer, [`false`] otherwise
1096 #[doc(alias = "gtk_gl_area_get_has_depth_buffer")]
1097 #[doc(alias = "get_has_depth_buffer")]
1098 #[doc(alias = "has-depth-buffer")]
1099 fn has_depth_buffer(&self) -> bool {
1100 unsafe {
1101 from_glib(ffi::gtk_gl_area_get_has_depth_buffer(
1102 self.as_ref().to_glib_none().0,
1103 ))
1104 }
1105 }
1106
1107 /// Returns whether the area has a stencil buffer.
1108 ///
1109 /// # Returns
1110 ///
1111 /// [`true`] if the @self has a stencil buffer, [`false`] otherwise
1112 #[doc(alias = "gtk_gl_area_get_has_stencil_buffer")]
1113 #[doc(alias = "get_has_stencil_buffer")]
1114 #[doc(alias = "has-stencil-buffer")]
1115 fn has_stencil_buffer(&self) -> bool {
1116 unsafe {
1117 from_glib(ffi::gtk_gl_area_get_has_stencil_buffer(
1118 self.as_ref().to_glib_none().0,
1119 ))
1120 }
1121 }
1122
1123 /// Retrieves the required version of OpenGL.
1124 ///
1125 /// See [`set_required_version()`][Self::set_required_version()].
1126 ///
1127 /// # Returns
1128 ///
1129 ///
1130 /// ## `major`
1131 /// return location for the required major version
1132 ///
1133 /// ## `minor`
1134 /// return location for the required minor version
1135 #[doc(alias = "gtk_gl_area_get_required_version")]
1136 #[doc(alias = "get_required_version")]
1137 fn required_version(&self) -> (i32, i32) {
1138 unsafe {
1139 let mut major = std::mem::MaybeUninit::uninit();
1140 let mut minor = std::mem::MaybeUninit::uninit();
1141 ffi::gtk_gl_area_get_required_version(
1142 self.as_ref().to_glib_none().0,
1143 major.as_mut_ptr(),
1144 minor.as_mut_ptr(),
1145 );
1146 (major.assume_init(), minor.assume_init())
1147 }
1148 }
1149
1150 /// Returns whether the [`GLArea`][crate::GLArea] should use OpenGL ES.
1151 ///
1152 /// See [`set_use_es()`][Self::set_use_es()].
1153 ///
1154 /// # Deprecated since 4.12
1155 ///
1156 /// Use [`api()`][Self::api()]
1157 ///
1158 /// # Returns
1159 ///
1160 /// [`true`] if the [`GLArea`][crate::GLArea] should create an OpenGL ES context
1161 /// and [`false`] otherwise
1162 #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
1163 #[allow(deprecated)]
1164 #[doc(alias = "gtk_gl_area_get_use_es")]
1165 #[doc(alias = "get_use_es")]
1166 #[doc(alias = "use-es")]
1167 fn uses_es(&self) -> bool {
1168 unsafe { from_glib(ffi::gtk_gl_area_get_use_es(self.as_ref().to_glib_none().0)) }
1169 }
1170
1171 /// Ensures that the [`gdk::GLContext`][crate::gdk::GLContext] used by @self is associated with
1172 /// the [`GLArea`][crate::GLArea].
1173 ///
1174 /// This function is automatically called before emitting the
1175 /// [`render`][struct@crate::GLArea#render] signal, and doesn't normally need
1176 /// to be called by application code.
1177 #[doc(alias = "gtk_gl_area_make_current")]
1178 fn make_current(&self) {
1179 unsafe {
1180 ffi::gtk_gl_area_make_current(self.as_ref().to_glib_none().0);
1181 }
1182 }
1183
1184 /// Marks the currently rendered data (if any) as invalid, and queues
1185 /// a redraw of the widget.
1186 ///
1187 /// This ensures that the [`render`][struct@crate::GLArea#render] signal
1188 /// is emitted during the draw.
1189 ///
1190 /// This is only needed when [`set_auto_render()`][Self::set_auto_render()] has
1191 /// been called with a [`false`] value. The default behaviour is to
1192 /// emit [`render`][struct@crate::GLArea#render] on each draw.
1193 #[doc(alias = "gtk_gl_area_queue_render")]
1194 fn queue_render(&self) {
1195 unsafe {
1196 ffi::gtk_gl_area_queue_render(self.as_ref().to_glib_none().0);
1197 }
1198 }
1199
1200 /// Sets the allowed APIs to create a context with.
1201 ///
1202 /// You should check [`api`][struct@crate::GLArea#api] before drawing
1203 /// with either API.
1204 ///
1205 /// By default, all APIs are allowed.
1206 /// ## `apis`
1207 /// the allowed APIs
1208 #[cfg(feature = "v4_12")]
1209 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1210 #[doc(alias = "gtk_gl_area_set_allowed_apis")]
1211 #[doc(alias = "allowed-apis")]
1212 fn set_allowed_apis(&self, apis: gdk::GLAPI) {
1213 unsafe {
1214 ffi::gtk_gl_area_set_allowed_apis(self.as_ref().to_glib_none().0, apis.into_glib());
1215 }
1216 }
1217
1218 /// Sets whether the [`GLArea`][crate::GLArea] is in auto render mode.
1219 ///
1220 /// If @auto_render is [`true`] the [`render`][struct@crate::GLArea#render] signal will
1221 /// be emitted every time the widget draws. This is the default and is
1222 /// useful if drawing the widget is faster.
1223 ///
1224 /// If @auto_render is [`false`] the data from previous rendering is kept
1225 /// around and will be used for drawing the widget the next time,
1226 /// unless the window is resized. In order to force a rendering
1227 /// [`queue_render()`][Self::queue_render()] must be called. This mode is
1228 /// useful when the scene changes seldom, but takes a long time to redraw.
1229 /// ## `auto_render`
1230 /// a boolean
1231 #[doc(alias = "gtk_gl_area_set_auto_render")]
1232 #[doc(alias = "auto-render")]
1233 fn set_auto_render(&self, auto_render: bool) {
1234 unsafe {
1235 ffi::gtk_gl_area_set_auto_render(
1236 self.as_ref().to_glib_none().0,
1237 auto_render.into_glib(),
1238 );
1239 }
1240 }
1241
1242 /// Sets an error on the area which will be shown instead of the
1243 /// GL rendering.
1244 ///
1245 /// This is useful in the [`create-context`][struct@crate::GLArea#create-context]
1246 /// signal if GL context creation fails.
1247 /// ## `error`
1248 /// a new `GError`, or [`None`] to unset the error
1249 #[doc(alias = "gtk_gl_area_set_error")]
1250 fn set_error(&self, error: Option<&glib::Error>) {
1251 unsafe {
1252 ffi::gtk_gl_area_set_error(self.as_ref().to_glib_none().0, error.to_glib_none().0);
1253 }
1254 }
1255
1256 /// Sets whether the [`GLArea`][crate::GLArea] should use a depth buffer.
1257 ///
1258 /// If @has_depth_buffer is [`true`] the widget will allocate and
1259 /// enable a depth buffer for the target framebuffer. Otherwise
1260 /// there will be none.
1261 /// ## `has_depth_buffer`
1262 /// [`true`] to add a depth buffer
1263 #[doc(alias = "gtk_gl_area_set_has_depth_buffer")]
1264 #[doc(alias = "has-depth-buffer")]
1265 fn set_has_depth_buffer(&self, has_depth_buffer: bool) {
1266 unsafe {
1267 ffi::gtk_gl_area_set_has_depth_buffer(
1268 self.as_ref().to_glib_none().0,
1269 has_depth_buffer.into_glib(),
1270 );
1271 }
1272 }
1273
1274 /// Sets whether the [`GLArea`][crate::GLArea] should use a stencil buffer.
1275 ///
1276 /// If @has_stencil_buffer is [`true`] the widget will allocate and
1277 /// enable a stencil buffer for the target framebuffer. Otherwise
1278 /// there will be none.
1279 /// ## `has_stencil_buffer`
1280 /// [`true`] to add a stencil buffer
1281 #[doc(alias = "gtk_gl_area_set_has_stencil_buffer")]
1282 #[doc(alias = "has-stencil-buffer")]
1283 fn set_has_stencil_buffer(&self, has_stencil_buffer: bool) {
1284 unsafe {
1285 ffi::gtk_gl_area_set_has_stencil_buffer(
1286 self.as_ref().to_glib_none().0,
1287 has_stencil_buffer.into_glib(),
1288 );
1289 }
1290 }
1291
1292 /// Sets the required version of OpenGL to be used when creating
1293 /// the context for the widget.
1294 ///
1295 /// This function must be called before the area has been realized.
1296 /// ## `major`
1297 /// the major version
1298 /// ## `minor`
1299 /// the minor version
1300 #[doc(alias = "gtk_gl_area_set_required_version")]
1301 fn set_required_version(&self, major: i32, minor: i32) {
1302 unsafe {
1303 ffi::gtk_gl_area_set_required_version(self.as_ref().to_glib_none().0, major, minor);
1304 }
1305 }
1306
1307 /// Sets whether the @self should create an OpenGL or an OpenGL ES context.
1308 ///
1309 /// You should check the capabilities of the [`gdk::GLContext`][crate::gdk::GLContext] before drawing
1310 /// with either API.
1311 ///
1312 /// # Deprecated since 4.12
1313 ///
1314 /// Use [`set_allowed_apis()`][Self::set_allowed_apis()]
1315 /// ## `use_es`
1316 /// whether to use OpenGL or OpenGL ES
1317 #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
1318 #[allow(deprecated)]
1319 #[doc(alias = "gtk_gl_area_set_use_es")]
1320 #[doc(alias = "use-es")]
1321 fn set_use_es(&self, use_es: bool) {
1322 unsafe {
1323 ffi::gtk_gl_area_set_use_es(self.as_ref().to_glib_none().0, use_es.into_glib());
1324 }
1325 }
1326
1327 /// Emitted when the widget is being realized.
1328 ///
1329 /// This allows you to override how the GL context is created.
1330 /// This is useful when you want to reuse an existing GL context,
1331 /// or if you want to try creating different kinds of GL options.
1332 ///
1333 /// If context creation fails then the signal handler can use
1334 /// [`set_error()`][Self::set_error()] to register a more detailed error
1335 /// of how the construction failed.
1336 ///
1337 /// # Returns
1338 ///
1339 /// a newly created [`gdk::GLContext`][crate::gdk::GLContext];
1340 /// the [`GLArea`][crate::GLArea] widget will take ownership of the returned value.
1341 #[doc(alias = "create-context")]
1342 fn connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>(
1343 &self,
1344 f: F,
1345 ) -> SignalHandlerId {
1346 unsafe extern "C" fn create_context_trampoline<
1347 P: IsA<GLArea>,
1348 F: Fn(&P) -> Option<gdk::GLContext> + 'static,
1349 >(
1350 this: *mut ffi::GtkGLArea,
1351 f: glib::ffi::gpointer,
1352 ) -> *mut gdk::ffi::GdkGLContext {
1353 unsafe {
1354 let f: &F = &*(f as *const F);
1355 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()).to_glib_full()
1356 }
1357 }
1358 unsafe {
1359 let f: Box_<F> = Box_::new(f);
1360 connect_raw(
1361 self.as_ptr() as *mut _,
1362 c"create-context".as_ptr(),
1363 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1364 create_context_trampoline::<Self, F> as *const (),
1365 )),
1366 Box_::into_raw(f),
1367 )
1368 }
1369 }
1370
1371 /// Emitted every time the contents of the [`GLArea`][crate::GLArea] should be redrawn.
1372 ///
1373 /// The @context is bound to the @area prior to emitting this function,
1374 /// and the buffers are painted to the window once the emission terminates.
1375 /// ## `context`
1376 /// the [`gdk::GLContext`][crate::gdk::GLContext] used by @area
1377 ///
1378 /// # Returns
1379 ///
1380 /// [`true`] to stop other handlers from being invoked for the event.
1381 /// [`false`] to propagate the event further.
1382 #[doc(alias = "render")]
1383 fn connect_render<F: Fn(&Self, &gdk::GLContext) -> glib::Propagation + 'static>(
1384 &self,
1385 f: F,
1386 ) -> SignalHandlerId {
1387 unsafe extern "C" fn render_trampoline<
1388 P: IsA<GLArea>,
1389 F: Fn(&P, &gdk::GLContext) -> glib::Propagation + 'static,
1390 >(
1391 this: *mut ffi::GtkGLArea,
1392 context: *mut gdk::ffi::GdkGLContext,
1393 f: glib::ffi::gpointer,
1394 ) -> glib::ffi::gboolean {
1395 unsafe {
1396 let f: &F = &*(f as *const F);
1397 f(
1398 GLArea::from_glib_borrow(this).unsafe_cast_ref(),
1399 &from_glib_borrow(context),
1400 )
1401 .into_glib()
1402 }
1403 }
1404 unsafe {
1405 let f: Box_<F> = Box_::new(f);
1406 connect_raw(
1407 self.as_ptr() as *mut _,
1408 c"render".as_ptr(),
1409 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1410 render_trampoline::<Self, F> as *const (),
1411 )),
1412 Box_::into_raw(f),
1413 )
1414 }
1415 }
1416
1417 /// Emitted once when the widget is realized, and then each time the widget
1418 /// is changed while realized.
1419 ///
1420 /// This is useful in order to keep GL state up to date with the widget size,
1421 /// like for instance camera properties which may depend on the width/height
1422 /// ratio.
1423 ///
1424 /// The GL context for the area is guaranteed to be current when this signal
1425 /// is emitted.
1426 ///
1427 /// The default handler sets up the GL viewport.
1428 /// ## `width`
1429 /// the width of the viewport
1430 /// ## `height`
1431 /// the height of the viewport
1432 #[doc(alias = "resize")]
1433 fn connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
1434 unsafe extern "C" fn resize_trampoline<P: IsA<GLArea>, F: Fn(&P, i32, i32) + 'static>(
1435 this: *mut ffi::GtkGLArea,
1436 width: std::ffi::c_int,
1437 height: std::ffi::c_int,
1438 f: glib::ffi::gpointer,
1439 ) {
1440 unsafe {
1441 let f: &F = &*(f as *const F);
1442 f(
1443 GLArea::from_glib_borrow(this).unsafe_cast_ref(),
1444 width,
1445 height,
1446 )
1447 }
1448 }
1449 unsafe {
1450 let f: Box_<F> = Box_::new(f);
1451 connect_raw(
1452 self.as_ptr() as *mut _,
1453 c"resize".as_ptr(),
1454 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1455 resize_trampoline::<Self, F> as *const (),
1456 )),
1457 Box_::into_raw(f),
1458 )
1459 }
1460 }
1461
1462 #[cfg(feature = "v4_12")]
1463 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1464 #[doc(alias = "allowed-apis")]
1465 fn connect_allowed_apis_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1466 unsafe extern "C" fn notify_allowed_apis_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
1467 this: *mut ffi::GtkGLArea,
1468 _param_spec: glib::ffi::gpointer,
1469 f: glib::ffi::gpointer,
1470 ) {
1471 unsafe {
1472 let f: &F = &*(f as *const F);
1473 f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
1474 }
1475 }
1476 unsafe {
1477 let f: Box_<F> = Box_::new(f);
1478 connect_raw(
1479 self.as_ptr() as *mut _,
1480 c"notify::allowed-apis".as_ptr(),
1481 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1482 notify_allowed_apis_trampoline::<Self, F> as *const (),
1483 )),
1484 Box_::into_raw(f),
1485 )
1486 }
1487 }
1488
1489 #[cfg(feature = "v4_12")]
1490 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1491 #[doc(alias = "api")]
1492 fn connect_api_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1493 unsafe extern "C" fn notify_api_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
1494 this: *mut ffi::GtkGLArea,
1495 _param_spec: glib::ffi::gpointer,
1496 f: glib::ffi::gpointer,
1497 ) {
1498 unsafe {
1499 let f: &F = &*(f as *const F);
1500 f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
1501 }
1502 }
1503 unsafe {
1504 let f: Box_<F> = Box_::new(f);
1505 connect_raw(
1506 self.as_ptr() as *mut _,
1507 c"notify::api".as_ptr(),
1508 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1509 notify_api_trampoline::<Self, F> as *const (),
1510 )),
1511 Box_::into_raw(f),
1512 )
1513 }
1514 }
1515
1516 #[doc(alias = "auto-render")]
1517 fn connect_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1518 unsafe extern "C" fn notify_auto_render_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
1519 this: *mut ffi::GtkGLArea,
1520 _param_spec: glib::ffi::gpointer,
1521 f: glib::ffi::gpointer,
1522 ) {
1523 unsafe {
1524 let f: &F = &*(f as *const F);
1525 f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
1526 }
1527 }
1528 unsafe {
1529 let f: Box_<F> = Box_::new(f);
1530 connect_raw(
1531 self.as_ptr() as *mut _,
1532 c"notify::auto-render".as_ptr(),
1533 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1534 notify_auto_render_trampoline::<Self, F> as *const (),
1535 )),
1536 Box_::into_raw(f),
1537 )
1538 }
1539 }
1540
1541 #[doc(alias = "context")]
1542 fn connect_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1543 unsafe extern "C" fn notify_context_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
1544 this: *mut ffi::GtkGLArea,
1545 _param_spec: glib::ffi::gpointer,
1546 f: glib::ffi::gpointer,
1547 ) {
1548 unsafe {
1549 let f: &F = &*(f as *const F);
1550 f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
1551 }
1552 }
1553 unsafe {
1554 let f: Box_<F> = Box_::new(f);
1555 connect_raw(
1556 self.as_ptr() as *mut _,
1557 c"notify::context".as_ptr(),
1558 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1559 notify_context_trampoline::<Self, F> as *const (),
1560 )),
1561 Box_::into_raw(f),
1562 )
1563 }
1564 }
1565
1566 #[doc(alias = "has-depth-buffer")]
1567 fn connect_has_depth_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1568 unsafe extern "C" fn notify_has_depth_buffer_trampoline<
1569 P: IsA<GLArea>,
1570 F: Fn(&P) + 'static,
1571 >(
1572 this: *mut ffi::GtkGLArea,
1573 _param_spec: glib::ffi::gpointer,
1574 f: glib::ffi::gpointer,
1575 ) {
1576 unsafe {
1577 let f: &F = &*(f as *const F);
1578 f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
1579 }
1580 }
1581 unsafe {
1582 let f: Box_<F> = Box_::new(f);
1583 connect_raw(
1584 self.as_ptr() as *mut _,
1585 c"notify::has-depth-buffer".as_ptr(),
1586 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1587 notify_has_depth_buffer_trampoline::<Self, F> as *const (),
1588 )),
1589 Box_::into_raw(f),
1590 )
1591 }
1592 }
1593
1594 #[doc(alias = "has-stencil-buffer")]
1595 fn connect_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1596 unsafe extern "C" fn notify_has_stencil_buffer_trampoline<
1597 P: IsA<GLArea>,
1598 F: Fn(&P) + 'static,
1599 >(
1600 this: *mut ffi::GtkGLArea,
1601 _param_spec: glib::ffi::gpointer,
1602 f: glib::ffi::gpointer,
1603 ) {
1604 unsafe {
1605 let f: &F = &*(f as *const F);
1606 f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
1607 }
1608 }
1609 unsafe {
1610 let f: Box_<F> = Box_::new(f);
1611 connect_raw(
1612 self.as_ptr() as *mut _,
1613 c"notify::has-stencil-buffer".as_ptr(),
1614 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1615 notify_has_stencil_buffer_trampoline::<Self, F> as *const (),
1616 )),
1617 Box_::into_raw(f),
1618 )
1619 }
1620 }
1621
1622 #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
1623 #[doc(alias = "use-es")]
1624 fn connect_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1625 unsafe extern "C" fn notify_use_es_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
1626 this: *mut ffi::GtkGLArea,
1627 _param_spec: glib::ffi::gpointer,
1628 f: glib::ffi::gpointer,
1629 ) {
1630 unsafe {
1631 let f: &F = &*(f as *const F);
1632 f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
1633 }
1634 }
1635 unsafe {
1636 let f: Box_<F> = Box_::new(f);
1637 connect_raw(
1638 self.as_ptr() as *mut _,
1639 c"notify::use-es".as_ptr(),
1640 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1641 notify_use_es_trampoline::<Self, F> as *const (),
1642 )),
1643 Box_::into_raw(f),
1644 )
1645 }
1646 }
1647}
1648
1649impl<O: IsA<GLArea>> GLAreaExt for O {}