1use gdk;
6#[cfg(any(feature = "v3_16", feature = "dox"))]
7use gdk_sys;
8use glib::object::Cast;
9use glib::object::IsA;
10#[cfg(any(feature = "v3_16", feature = "dox"))]
11use glib::signal::connect_raw;
12#[cfg(any(feature = "v3_16", feature = "dox"))]
13use glib::signal::SignalHandlerId;
14use glib::translate::*;
15use glib::StaticType;
16use glib::ToValue;
17#[cfg(any(feature = "v3_16", feature = "dox"))]
18use glib_sys;
19use gtk_sys;
20#[cfg(any(feature = "v3_16", feature = "dox"))]
21use libc;
22#[cfg(any(feature = "v3_16", feature = "dox"))]
23use signal::Inhibit;
24#[cfg(any(feature = "v3_16", feature = "dox"))]
25use std::boxed::Box as Box_;
26use std::fmt;
27#[cfg(any(feature = "v3_16", feature = "dox"))]
28use std::mem;
29#[cfg(any(feature = "v3_16", feature = "dox"))]
30use std::mem::transmute;
31use Align;
32use Buildable;
33use Container;
34#[cfg(any(feature = "v3_16", feature = "dox"))]
35use Error;
36use Widget;
37
38glib_wrapper! {
39 pub struct GLArea(Object<gtk_sys::GtkGLArea, gtk_sys::GtkGLAreaClass, GLAreaClass>) @extends Widget, @implements Buildable;
40
41 match fn {
42 get_type => || gtk_sys::gtk_gl_area_get_type(),
43 }
44}
45
46impl GLArea {
47 #[cfg(any(feature = "v3_16", feature = "dox"))]
48 pub fn new() -> GLArea {
49 assert_initialized_main_thread!();
50 unsafe { Widget::from_glib_none(gtk_sys::gtk_gl_area_new()).unsafe_cast() }
51 }
52}
53
54#[cfg(any(feature = "v3_16", feature = "dox"))]
55impl Default for GLArea {
56 fn default() -> Self {
57 Self::new()
58 }
59}
60
61pub struct GLAreaBuilder {
62 #[cfg(any(feature = "v3_16", feature = "dox"))]
63 auto_render: Option<bool>,
64 #[cfg(any(feature = "v3_16", feature = "dox"))]
65 has_alpha: Option<bool>,
66 #[cfg(any(feature = "v3_16", feature = "dox"))]
67 has_depth_buffer: Option<bool>,
68 #[cfg(any(feature = "v3_16", feature = "dox"))]
69 has_stencil_buffer: Option<bool>,
70 #[cfg(any(feature = "v3_22", feature = "dox"))]
71 use_es: Option<bool>,
72 app_paintable: Option<bool>,
73 can_default: Option<bool>,
74 can_focus: Option<bool>,
75 events: Option<gdk::EventMask>,
76 expand: Option<bool>,
77 #[cfg(any(feature = "v3_20", feature = "dox"))]
78 focus_on_click: Option<bool>,
79 halign: Option<Align>,
80 has_default: Option<bool>,
81 has_focus: Option<bool>,
82 has_tooltip: Option<bool>,
83 height_request: Option<i32>,
84 hexpand: Option<bool>,
85 hexpand_set: Option<bool>,
86 is_focus: Option<bool>,
87 margin: Option<i32>,
88 margin_bottom: Option<i32>,
89 margin_end: Option<i32>,
90 margin_start: Option<i32>,
91 margin_top: Option<i32>,
92 name: Option<String>,
93 no_show_all: Option<bool>,
94 opacity: Option<f64>,
95 parent: Option<Container>,
96 receives_default: Option<bool>,
97 sensitive: Option<bool>,
98 tooltip_markup: Option<String>,
100 tooltip_text: Option<String>,
101 valign: Option<Align>,
102 vexpand: Option<bool>,
103 vexpand_set: Option<bool>,
104 visible: Option<bool>,
105 width_request: Option<i32>,
106}
107
108impl GLAreaBuilder {
109 pub fn new() -> Self {
110 Self {
111 #[cfg(any(feature = "v3_16", feature = "dox"))]
112 auto_render: None,
113 #[cfg(any(feature = "v3_16", feature = "dox"))]
114 has_alpha: None,
115 #[cfg(any(feature = "v3_16", feature = "dox"))]
116 has_depth_buffer: None,
117 #[cfg(any(feature = "v3_16", feature = "dox"))]
118 has_stencil_buffer: None,
119 #[cfg(any(feature = "v3_22", feature = "dox"))]
120 use_es: None,
121 app_paintable: None,
122 can_default: None,
123 can_focus: None,
124 events: None,
125 expand: None,
126 #[cfg(any(feature = "v3_20", feature = "dox"))]
127 focus_on_click: None,
128 halign: None,
129 has_default: None,
130 has_focus: None,
131 has_tooltip: None,
132 height_request: None,
133 hexpand: None,
134 hexpand_set: None,
135 is_focus: None,
136 margin: None,
137 margin_bottom: None,
138 margin_end: None,
139 margin_start: None,
140 margin_top: None,
141 name: None,
142 no_show_all: None,
143 opacity: None,
144 parent: None,
145 receives_default: None,
146 sensitive: None,
147 tooltip_markup: None,
148 tooltip_text: None,
149 valign: None,
150 vexpand: None,
151 vexpand_set: None,
152 visible: None,
153 width_request: None,
154 }
155 }
156
157 pub fn build(self) -> GLArea {
158 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
159 #[cfg(any(feature = "v3_16", feature = "dox"))]
160 {
161 if let Some(ref auto_render) = self.auto_render {
162 properties.push(("auto-render", auto_render));
163 }
164 }
165 #[cfg(any(feature = "v3_16", feature = "dox"))]
166 {
167 if let Some(ref has_alpha) = self.has_alpha {
168 properties.push(("has-alpha", has_alpha));
169 }
170 }
171 #[cfg(any(feature = "v3_16", feature = "dox"))]
172 {
173 if let Some(ref has_depth_buffer) = self.has_depth_buffer {
174 properties.push(("has-depth-buffer", has_depth_buffer));
175 }
176 }
177 #[cfg(any(feature = "v3_16", feature = "dox"))]
178 {
179 if let Some(ref has_stencil_buffer) = self.has_stencil_buffer {
180 properties.push(("has-stencil-buffer", has_stencil_buffer));
181 }
182 }
183 #[cfg(any(feature = "v3_22", feature = "dox"))]
184 {
185 if let Some(ref use_es) = self.use_es {
186 properties.push(("use-es", use_es));
187 }
188 }
189 if let Some(ref app_paintable) = self.app_paintable {
190 properties.push(("app-paintable", app_paintable));
191 }
192 if let Some(ref can_default) = self.can_default {
193 properties.push(("can-default", can_default));
194 }
195 if let Some(ref can_focus) = self.can_focus {
196 properties.push(("can-focus", can_focus));
197 }
198 if let Some(ref events) = self.events {
199 properties.push(("events", events));
200 }
201 if let Some(ref expand) = self.expand {
202 properties.push(("expand", expand));
203 }
204 #[cfg(any(feature = "v3_20", feature = "dox"))]
205 {
206 if let Some(ref focus_on_click) = self.focus_on_click {
207 properties.push(("focus-on-click", focus_on_click));
208 }
209 }
210 if let Some(ref halign) = self.halign {
211 properties.push(("halign", halign));
212 }
213 if let Some(ref has_default) = self.has_default {
214 properties.push(("has-default", has_default));
215 }
216 if let Some(ref has_focus) = self.has_focus {
217 properties.push(("has-focus", has_focus));
218 }
219 if let Some(ref has_tooltip) = self.has_tooltip {
220 properties.push(("has-tooltip", has_tooltip));
221 }
222 if let Some(ref height_request) = self.height_request {
223 properties.push(("height-request", height_request));
224 }
225 if let Some(ref hexpand) = self.hexpand {
226 properties.push(("hexpand", hexpand));
227 }
228 if let Some(ref hexpand_set) = self.hexpand_set {
229 properties.push(("hexpand-set", hexpand_set));
230 }
231 if let Some(ref is_focus) = self.is_focus {
232 properties.push(("is-focus", is_focus));
233 }
234 if let Some(ref margin) = self.margin {
235 properties.push(("margin", margin));
236 }
237 if let Some(ref margin_bottom) = self.margin_bottom {
238 properties.push(("margin-bottom", margin_bottom));
239 }
240 if let Some(ref margin_end) = self.margin_end {
241 properties.push(("margin-end", margin_end));
242 }
243 if let Some(ref margin_start) = self.margin_start {
244 properties.push(("margin-start", margin_start));
245 }
246 if let Some(ref margin_top) = self.margin_top {
247 properties.push(("margin-top", margin_top));
248 }
249 if let Some(ref name) = self.name {
250 properties.push(("name", name));
251 }
252 if let Some(ref no_show_all) = self.no_show_all {
253 properties.push(("no-show-all", no_show_all));
254 }
255 if let Some(ref opacity) = self.opacity {
256 properties.push(("opacity", opacity));
257 }
258 if let Some(ref parent) = self.parent {
259 properties.push(("parent", parent));
260 }
261 if let Some(ref receives_default) = self.receives_default {
262 properties.push(("receives-default", receives_default));
263 }
264 if let Some(ref sensitive) = self.sensitive {
265 properties.push(("sensitive", sensitive));
266 }
267 if let Some(ref tooltip_markup) = self.tooltip_markup {
268 properties.push(("tooltip-markup", tooltip_markup));
269 }
270 if let Some(ref tooltip_text) = self.tooltip_text {
271 properties.push(("tooltip-text", tooltip_text));
272 }
273 if let Some(ref valign) = self.valign {
274 properties.push(("valign", valign));
275 }
276 if let Some(ref vexpand) = self.vexpand {
277 properties.push(("vexpand", vexpand));
278 }
279 if let Some(ref vexpand_set) = self.vexpand_set {
280 properties.push(("vexpand-set", vexpand_set));
281 }
282 if let Some(ref visible) = self.visible {
283 properties.push(("visible", visible));
284 }
285 if let Some(ref width_request) = self.width_request {
286 properties.push(("width-request", width_request));
287 }
288 glib::Object::new(GLArea::static_type(), &properties)
289 .expect("object new")
290 .downcast()
291 .expect("downcast")
292 }
293
294 #[cfg(any(feature = "v3_16", feature = "dox"))]
295 pub fn auto_render(mut self, auto_render: bool) -> Self {
296 self.auto_render = Some(auto_render);
297 self
298 }
299
300 #[cfg(any(feature = "v3_16", feature = "dox"))]
301 pub fn has_alpha(mut self, has_alpha: bool) -> Self {
302 self.has_alpha = Some(has_alpha);
303 self
304 }
305
306 #[cfg(any(feature = "v3_16", feature = "dox"))]
307 pub fn has_depth_buffer(mut self, has_depth_buffer: bool) -> Self {
308 self.has_depth_buffer = Some(has_depth_buffer);
309 self
310 }
311
312 #[cfg(any(feature = "v3_16", feature = "dox"))]
313 pub fn has_stencil_buffer(mut self, has_stencil_buffer: bool) -> Self {
314 self.has_stencil_buffer = Some(has_stencil_buffer);
315 self
316 }
317
318 #[cfg(any(feature = "v3_22", feature = "dox"))]
319 pub fn use_es(mut self, use_es: bool) -> Self {
320 self.use_es = Some(use_es);
321 self
322 }
323
324 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
325 self.app_paintable = Some(app_paintable);
326 self
327 }
328
329 pub fn can_default(mut self, can_default: bool) -> Self {
330 self.can_default = Some(can_default);
331 self
332 }
333
334 pub fn can_focus(mut self, can_focus: bool) -> Self {
335 self.can_focus = Some(can_focus);
336 self
337 }
338
339 pub fn events(mut self, events: gdk::EventMask) -> Self {
340 self.events = Some(events);
341 self
342 }
343
344 pub fn expand(mut self, expand: bool) -> Self {
345 self.expand = Some(expand);
346 self
347 }
348
349 #[cfg(any(feature = "v3_20", feature = "dox"))]
350 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
351 self.focus_on_click = Some(focus_on_click);
352 self
353 }
354
355 pub fn halign(mut self, halign: Align) -> Self {
356 self.halign = Some(halign);
357 self
358 }
359
360 pub fn has_default(mut self, has_default: bool) -> Self {
361 self.has_default = Some(has_default);
362 self
363 }
364
365 pub fn has_focus(mut self, has_focus: bool) -> Self {
366 self.has_focus = Some(has_focus);
367 self
368 }
369
370 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
371 self.has_tooltip = Some(has_tooltip);
372 self
373 }
374
375 pub fn height_request(mut self, height_request: i32) -> Self {
376 self.height_request = Some(height_request);
377 self
378 }
379
380 pub fn hexpand(mut self, hexpand: bool) -> Self {
381 self.hexpand = Some(hexpand);
382 self
383 }
384
385 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
386 self.hexpand_set = Some(hexpand_set);
387 self
388 }
389
390 pub fn is_focus(mut self, is_focus: bool) -> Self {
391 self.is_focus = Some(is_focus);
392 self
393 }
394
395 pub fn margin(mut self, margin: i32) -> Self {
396 self.margin = Some(margin);
397 self
398 }
399
400 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
401 self.margin_bottom = Some(margin_bottom);
402 self
403 }
404
405 pub fn margin_end(mut self, margin_end: i32) -> Self {
406 self.margin_end = Some(margin_end);
407 self
408 }
409
410 pub fn margin_start(mut self, margin_start: i32) -> Self {
411 self.margin_start = Some(margin_start);
412 self
413 }
414
415 pub fn margin_top(mut self, margin_top: i32) -> Self {
416 self.margin_top = Some(margin_top);
417 self
418 }
419
420 pub fn name(mut self, name: &str) -> Self {
421 self.name = Some(name.to_string());
422 self
423 }
424
425 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
426 self.no_show_all = Some(no_show_all);
427 self
428 }
429
430 pub fn opacity(mut self, opacity: f64) -> Self {
431 self.opacity = Some(opacity);
432 self
433 }
434
435 pub fn parent(mut self, parent: &Container) -> Self {
436 self.parent = Some(parent.clone());
437 self
438 }
439
440 pub fn receives_default(mut self, receives_default: bool) -> Self {
441 self.receives_default = Some(receives_default);
442 self
443 }
444
445 pub fn sensitive(mut self, sensitive: bool) -> Self {
446 self.sensitive = Some(sensitive);
447 self
448 }
449
450 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
451 self.tooltip_markup = Some(tooltip_markup.to_string());
452 self
453 }
454
455 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
456 self.tooltip_text = Some(tooltip_text.to_string());
457 self
458 }
459
460 pub fn valign(mut self, valign: Align) -> Self {
461 self.valign = Some(valign);
462 self
463 }
464
465 pub fn vexpand(mut self, vexpand: bool) -> Self {
466 self.vexpand = Some(vexpand);
467 self
468 }
469
470 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
471 self.vexpand_set = Some(vexpand_set);
472 self
473 }
474
475 pub fn visible(mut self, visible: bool) -> Self {
476 self.visible = Some(visible);
477 self
478 }
479
480 pub fn width_request(mut self, width_request: i32) -> Self {
481 self.width_request = Some(width_request);
482 self
483 }
484}
485
486pub const NONE_GL_AREA: Option<&GLArea> = None;
487
488pub trait GLAreaExt: 'static {
489 #[cfg(any(feature = "v3_16", feature = "dox"))]
490 fn attach_buffers(&self);
491
492 #[cfg(any(feature = "v3_16", feature = "dox"))]
493 fn get_auto_render(&self) -> bool;
494
495 #[cfg(any(feature = "v3_16", feature = "dox"))]
496 fn get_context(&self) -> Option<gdk::GLContext>;
497
498 #[cfg(any(feature = "v3_16", feature = "dox"))]
499 fn get_error(&self) -> Option<Error>;
500
501 #[cfg(any(feature = "v3_16", feature = "dox"))]
502 fn get_has_alpha(&self) -> bool;
503
504 #[cfg(any(feature = "v3_16", feature = "dox"))]
505 fn get_has_depth_buffer(&self) -> bool;
506
507 #[cfg(any(feature = "v3_16", feature = "dox"))]
508 fn get_has_stencil_buffer(&self) -> bool;
509
510 #[cfg(any(feature = "v3_16", feature = "dox"))]
511 fn get_required_version(&self) -> (i32, i32);
512
513 #[cfg(any(feature = "v3_22", feature = "dox"))]
514 fn get_use_es(&self) -> bool;
515
516 #[cfg(any(feature = "v3_16", feature = "dox"))]
517 fn make_current(&self);
518
519 #[cfg(any(feature = "v3_16", feature = "dox"))]
520 fn queue_render(&self);
521
522 #[cfg(any(feature = "v3_16", feature = "dox"))]
523 fn set_auto_render(&self, auto_render: bool);
524
525 #[cfg(any(feature = "v3_16", feature = "dox"))]
526 fn set_error(&self, error: Option<&Error>);
527
528 #[cfg(any(feature = "v3_16", feature = "dox"))]
529 fn set_has_alpha(&self, has_alpha: bool);
530
531 #[cfg(any(feature = "v3_16", feature = "dox"))]
532 fn set_has_depth_buffer(&self, has_depth_buffer: bool);
533
534 #[cfg(any(feature = "v3_16", feature = "dox"))]
535 fn set_has_stencil_buffer(&self, has_stencil_buffer: bool);
536
537 #[cfg(any(feature = "v3_16", feature = "dox"))]
538 fn set_required_version(&self, major: i32, minor: i32);
539
540 #[cfg(any(feature = "v3_22", feature = "dox"))]
541 fn set_use_es(&self, use_es: bool);
542
543 #[cfg(any(feature = "v3_16", feature = "dox"))]
544 fn connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>(
545 &self,
546 f: F,
547 ) -> SignalHandlerId;
548
549 #[cfg(any(feature = "v3_16", feature = "dox"))]
550 fn connect_render<F: Fn(&Self, &gdk::GLContext) -> Inhibit + 'static>(
551 &self,
552 f: F,
553 ) -> SignalHandlerId;
554
555 #[cfg(any(feature = "v3_16", feature = "dox"))]
556 fn connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId;
557
558 #[cfg(any(feature = "v3_16", feature = "dox"))]
559 fn connect_property_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
560
561 #[cfg(any(feature = "v3_16", feature = "dox"))]
562 fn connect_property_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
563
564 #[cfg(any(feature = "v3_16", feature = "dox"))]
565 fn connect_property_has_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
566
567 #[cfg(any(feature = "v3_16", feature = "dox"))]
568 fn connect_property_has_depth_buffer_notify<F: Fn(&Self) + 'static>(
569 &self,
570 f: F,
571 ) -> SignalHandlerId;
572
573 #[cfg(any(feature = "v3_16", feature = "dox"))]
574 fn connect_property_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(
575 &self,
576 f: F,
577 ) -> SignalHandlerId;
578
579 #[cfg(any(feature = "v3_22", feature = "dox"))]
580 fn connect_property_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
581}
582
583impl<O: IsA<GLArea>> GLAreaExt for O {
584 #[cfg(any(feature = "v3_16", feature = "dox"))]
585 fn attach_buffers(&self) {
586 unsafe {
587 gtk_sys::gtk_gl_area_attach_buffers(self.as_ref().to_glib_none().0);
588 }
589 }
590
591 #[cfg(any(feature = "v3_16", feature = "dox"))]
592 fn get_auto_render(&self) -> bool {
593 unsafe {
594 from_glib(gtk_sys::gtk_gl_area_get_auto_render(
595 self.as_ref().to_glib_none().0,
596 ))
597 }
598 }
599
600 #[cfg(any(feature = "v3_16", feature = "dox"))]
601 fn get_context(&self) -> Option<gdk::GLContext> {
602 unsafe {
603 from_glib_none(gtk_sys::gtk_gl_area_get_context(
604 self.as_ref().to_glib_none().0,
605 ))
606 }
607 }
608
609 #[cfg(any(feature = "v3_16", feature = "dox"))]
610 fn get_error(&self) -> Option<Error> {
611 unsafe {
612 from_glib_none(gtk_sys::gtk_gl_area_get_error(
613 self.as_ref().to_glib_none().0,
614 ))
615 }
616 }
617
618 #[cfg(any(feature = "v3_16", feature = "dox"))]
619 fn get_has_alpha(&self) -> bool {
620 unsafe {
621 from_glib(gtk_sys::gtk_gl_area_get_has_alpha(
622 self.as_ref().to_glib_none().0,
623 ))
624 }
625 }
626
627 #[cfg(any(feature = "v3_16", feature = "dox"))]
628 fn get_has_depth_buffer(&self) -> bool {
629 unsafe {
630 from_glib(gtk_sys::gtk_gl_area_get_has_depth_buffer(
631 self.as_ref().to_glib_none().0,
632 ))
633 }
634 }
635
636 #[cfg(any(feature = "v3_16", feature = "dox"))]
637 fn get_has_stencil_buffer(&self) -> bool {
638 unsafe {
639 from_glib(gtk_sys::gtk_gl_area_get_has_stencil_buffer(
640 self.as_ref().to_glib_none().0,
641 ))
642 }
643 }
644
645 #[cfg(any(feature = "v3_16", feature = "dox"))]
646 fn get_required_version(&self) -> (i32, i32) {
647 unsafe {
648 let mut major = mem::uninitialized();
649 let mut minor = mem::uninitialized();
650 gtk_sys::gtk_gl_area_get_required_version(
651 self.as_ref().to_glib_none().0,
652 &mut major,
653 &mut minor,
654 );
655 (major, minor)
656 }
657 }
658
659 #[cfg(any(feature = "v3_22", feature = "dox"))]
660 fn get_use_es(&self) -> bool {
661 unsafe {
662 from_glib(gtk_sys::gtk_gl_area_get_use_es(
663 self.as_ref().to_glib_none().0,
664 ))
665 }
666 }
667
668 #[cfg(any(feature = "v3_16", feature = "dox"))]
669 fn make_current(&self) {
670 unsafe {
671 gtk_sys::gtk_gl_area_make_current(self.as_ref().to_glib_none().0);
672 }
673 }
674
675 #[cfg(any(feature = "v3_16", feature = "dox"))]
676 fn queue_render(&self) {
677 unsafe {
678 gtk_sys::gtk_gl_area_queue_render(self.as_ref().to_glib_none().0);
679 }
680 }
681
682 #[cfg(any(feature = "v3_16", feature = "dox"))]
683 fn set_auto_render(&self, auto_render: bool) {
684 unsafe {
685 gtk_sys::gtk_gl_area_set_auto_render(
686 self.as_ref().to_glib_none().0,
687 auto_render.to_glib(),
688 );
689 }
690 }
691
692 #[cfg(any(feature = "v3_16", feature = "dox"))]
693 fn set_error(&self, error: Option<&Error>) {
694 unsafe {
695 gtk_sys::gtk_gl_area_set_error(self.as_ref().to_glib_none().0, error.to_glib_none().0);
696 }
697 }
698
699 #[cfg(any(feature = "v3_16", feature = "dox"))]
700 fn set_has_alpha(&self, has_alpha: bool) {
701 unsafe {
702 gtk_sys::gtk_gl_area_set_has_alpha(self.as_ref().to_glib_none().0, has_alpha.to_glib());
703 }
704 }
705
706 #[cfg(any(feature = "v3_16", feature = "dox"))]
707 fn set_has_depth_buffer(&self, has_depth_buffer: bool) {
708 unsafe {
709 gtk_sys::gtk_gl_area_set_has_depth_buffer(
710 self.as_ref().to_glib_none().0,
711 has_depth_buffer.to_glib(),
712 );
713 }
714 }
715
716 #[cfg(any(feature = "v3_16", feature = "dox"))]
717 fn set_has_stencil_buffer(&self, has_stencil_buffer: bool) {
718 unsafe {
719 gtk_sys::gtk_gl_area_set_has_stencil_buffer(
720 self.as_ref().to_glib_none().0,
721 has_stencil_buffer.to_glib(),
722 );
723 }
724 }
725
726 #[cfg(any(feature = "v3_16", feature = "dox"))]
727 fn set_required_version(&self, major: i32, minor: i32) {
728 unsafe {
729 gtk_sys::gtk_gl_area_set_required_version(self.as_ref().to_glib_none().0, major, minor);
730 }
731 }
732
733 #[cfg(any(feature = "v3_22", feature = "dox"))]
734 fn set_use_es(&self, use_es: bool) {
735 unsafe {
736 gtk_sys::gtk_gl_area_set_use_es(self.as_ref().to_glib_none().0, use_es.to_glib());
737 }
738 }
739
740 #[cfg(any(feature = "v3_16", feature = "dox"))]
741 fn connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>(
742 &self,
743 f: F,
744 ) -> SignalHandlerId {
745 unsafe extern "C" fn create_context_trampoline<
746 P,
747 F: Fn(&P) -> Option<gdk::GLContext> + 'static,
748 >(
749 this: *mut gtk_sys::GtkGLArea,
750 f: glib_sys::gpointer,
751 ) -> *mut gdk_sys::GdkGLContext
752 where
753 P: IsA<GLArea>,
754 {
755 let f: &F = &*(f as *const F);
756 f(&GLArea::from_glib_borrow(this).unsafe_cast()).to_glib_full()
757 }
758 unsafe {
759 let f: Box_<F> = Box_::new(f);
760 connect_raw(
761 self.as_ptr() as *mut _,
762 b"create-context\0".as_ptr() as *const _,
763 Some(transmute(create_context_trampoline::<Self, F> as usize)),
764 Box_::into_raw(f),
765 )
766 }
767 }
768
769 #[cfg(any(feature = "v3_16", feature = "dox"))]
770 fn connect_render<F: Fn(&Self, &gdk::GLContext) -> Inhibit + 'static>(
771 &self,
772 f: F,
773 ) -> SignalHandlerId {
774 unsafe extern "C" fn render_trampoline<P, F: Fn(&P, &gdk::GLContext) -> Inhibit + 'static>(
775 this: *mut gtk_sys::GtkGLArea,
776 context: *mut gdk_sys::GdkGLContext,
777 f: glib_sys::gpointer,
778 ) -> glib_sys::gboolean
779 where
780 P: IsA<GLArea>,
781 {
782 let f: &F = &*(f as *const F);
783 f(
784 &GLArea::from_glib_borrow(this).unsafe_cast(),
785 &from_glib_borrow(context),
786 )
787 .to_glib()
788 }
789 unsafe {
790 let f: Box_<F> = Box_::new(f);
791 connect_raw(
792 self.as_ptr() as *mut _,
793 b"render\0".as_ptr() as *const _,
794 Some(transmute(render_trampoline::<Self, F> as usize)),
795 Box_::into_raw(f),
796 )
797 }
798 }
799
800 #[cfg(any(feature = "v3_16", feature = "dox"))]
801 fn connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
802 unsafe extern "C" fn resize_trampoline<P, F: Fn(&P, i32, i32) + 'static>(
803 this: *mut gtk_sys::GtkGLArea,
804 width: libc::c_int,
805 height: libc::c_int,
806 f: glib_sys::gpointer,
807 ) where
808 P: IsA<GLArea>,
809 {
810 let f: &F = &*(f as *const F);
811 f(&GLArea::from_glib_borrow(this).unsafe_cast(), width, height)
812 }
813 unsafe {
814 let f: Box_<F> = Box_::new(f);
815 connect_raw(
816 self.as_ptr() as *mut _,
817 b"resize\0".as_ptr() as *const _,
818 Some(transmute(resize_trampoline::<Self, F> as usize)),
819 Box_::into_raw(f),
820 )
821 }
822 }
823
824 #[cfg(any(feature = "v3_16", feature = "dox"))]
825 fn connect_property_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
826 unsafe extern "C" fn notify_auto_render_trampoline<P, F: Fn(&P) + 'static>(
827 this: *mut gtk_sys::GtkGLArea,
828 _param_spec: glib_sys::gpointer,
829 f: glib_sys::gpointer,
830 ) where
831 P: IsA<GLArea>,
832 {
833 let f: &F = &*(f as *const F);
834 f(&GLArea::from_glib_borrow(this).unsafe_cast())
835 }
836 unsafe {
837 let f: Box_<F> = Box_::new(f);
838 connect_raw(
839 self.as_ptr() as *mut _,
840 b"notify::auto-render\0".as_ptr() as *const _,
841 Some(transmute(notify_auto_render_trampoline::<Self, F> as usize)),
842 Box_::into_raw(f),
843 )
844 }
845 }
846
847 #[cfg(any(feature = "v3_16", feature = "dox"))]
848 fn connect_property_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
849 unsafe extern "C" fn notify_context_trampoline<P, F: Fn(&P) + 'static>(
850 this: *mut gtk_sys::GtkGLArea,
851 _param_spec: glib_sys::gpointer,
852 f: glib_sys::gpointer,
853 ) where
854 P: IsA<GLArea>,
855 {
856 let f: &F = &*(f as *const F);
857 f(&GLArea::from_glib_borrow(this).unsafe_cast())
858 }
859 unsafe {
860 let f: Box_<F> = Box_::new(f);
861 connect_raw(
862 self.as_ptr() as *mut _,
863 b"notify::context\0".as_ptr() as *const _,
864 Some(transmute(notify_context_trampoline::<Self, F> as usize)),
865 Box_::into_raw(f),
866 )
867 }
868 }
869
870 #[cfg(any(feature = "v3_16", feature = "dox"))]
871 fn connect_property_has_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
872 unsafe extern "C" fn notify_has_alpha_trampoline<P, F: Fn(&P) + 'static>(
873 this: *mut gtk_sys::GtkGLArea,
874 _param_spec: glib_sys::gpointer,
875 f: glib_sys::gpointer,
876 ) where
877 P: IsA<GLArea>,
878 {
879 let f: &F = &*(f as *const F);
880 f(&GLArea::from_glib_borrow(this).unsafe_cast())
881 }
882 unsafe {
883 let f: Box_<F> = Box_::new(f);
884 connect_raw(
885 self.as_ptr() as *mut _,
886 b"notify::has-alpha\0".as_ptr() as *const _,
887 Some(transmute(notify_has_alpha_trampoline::<Self, F> as usize)),
888 Box_::into_raw(f),
889 )
890 }
891 }
892
893 #[cfg(any(feature = "v3_16", feature = "dox"))]
894 fn connect_property_has_depth_buffer_notify<F: Fn(&Self) + 'static>(
895 &self,
896 f: F,
897 ) -> SignalHandlerId {
898 unsafe extern "C" fn notify_has_depth_buffer_trampoline<P, F: Fn(&P) + 'static>(
899 this: *mut gtk_sys::GtkGLArea,
900 _param_spec: glib_sys::gpointer,
901 f: glib_sys::gpointer,
902 ) where
903 P: IsA<GLArea>,
904 {
905 let f: &F = &*(f as *const F);
906 f(&GLArea::from_glib_borrow(this).unsafe_cast())
907 }
908 unsafe {
909 let f: Box_<F> = Box_::new(f);
910 connect_raw(
911 self.as_ptr() as *mut _,
912 b"notify::has-depth-buffer\0".as_ptr() as *const _,
913 Some(transmute(
914 notify_has_depth_buffer_trampoline::<Self, F> as usize,
915 )),
916 Box_::into_raw(f),
917 )
918 }
919 }
920
921 #[cfg(any(feature = "v3_16", feature = "dox"))]
922 fn connect_property_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(
923 &self,
924 f: F,
925 ) -> SignalHandlerId {
926 unsafe extern "C" fn notify_has_stencil_buffer_trampoline<P, F: Fn(&P) + 'static>(
927 this: *mut gtk_sys::GtkGLArea,
928 _param_spec: glib_sys::gpointer,
929 f: glib_sys::gpointer,
930 ) where
931 P: IsA<GLArea>,
932 {
933 let f: &F = &*(f as *const F);
934 f(&GLArea::from_glib_borrow(this).unsafe_cast())
935 }
936 unsafe {
937 let f: Box_<F> = Box_::new(f);
938 connect_raw(
939 self.as_ptr() as *mut _,
940 b"notify::has-stencil-buffer\0".as_ptr() as *const _,
941 Some(transmute(
942 notify_has_stencil_buffer_trampoline::<Self, F> as usize,
943 )),
944 Box_::into_raw(f),
945 )
946 }
947 }
948
949 #[cfg(any(feature = "v3_22", feature = "dox"))]
950 fn connect_property_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
951 unsafe extern "C" fn notify_use_es_trampoline<P, F: Fn(&P) + 'static>(
952 this: *mut gtk_sys::GtkGLArea,
953 _param_spec: glib_sys::gpointer,
954 f: glib_sys::gpointer,
955 ) where
956 P: IsA<GLArea>,
957 {
958 let f: &F = &*(f as *const F);
959 f(&GLArea::from_glib_borrow(this).unsafe_cast())
960 }
961 unsafe {
962 let f: Box_<F> = Box_::new(f);
963 connect_raw(
964 self.as_ptr() as *mut _,
965 b"notify::use-es\0".as_ptr() as *const _,
966 Some(transmute(notify_use_es_trampoline::<Self, F> as usize)),
967 Box_::into_raw(f),
968 )
969 }
970 }
971}
972
973impl fmt::Display for GLArea {
974 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
975 write!(f, "GLArea")
976 }
977}