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