v0.2.1 c0399be

gtkglarea.go RawHistoryFolder

1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11	"github.com/bnema/puregotk/v4/gdk"
12	"github.com/bnema/puregotk/v4/glib"
13	"github.com/bnema/puregotk/v4/gobject"
14	"github.com/bnema/puregotk/v4/gobject/types"
15)
16
17// The `GtkGLAreaClass` structure contains only private data.
18type GLAreaClass struct {
19	_ structs.HostLayout
20
21	ParentClass WidgetClass
22
23	xRender uintptr
24
25	xResize uintptr
26
27	xCreateContext uintptr
28
29	Padding [8]uintptr
30}
31
32func (x *GLAreaClass) GoPointer() uintptr {
33	return uintptr(unsafe.Pointer(x))
34}
35
36// OverrideRender sets the "render" callback function.
37// class closure for the `GtkGLArea::render` signal
38func (x *GLAreaClass) OverrideRender(cb func(*GLArea, *gdk.GLContext) bool) {
39	if cb == nil {
40		x.xRender = 0
41	} else {
42		x.xRender = purego.NewCallback(func(AreaVarp uintptr, ContextVarp uintptr) bool {
43			return cb(GLAreaNewFromInternalPtr(AreaVarp), gdk.GLContextNewFromInternalPtr(ContextVarp))
44		})
45	}
46}
47
48// GetRender gets the "render" callback function.
49// class closure for the `GtkGLArea::render` signal
50func (x *GLAreaClass) GetRender() func(*GLArea, *gdk.GLContext) bool {
51	if x.xRender == 0 {
52		return nil
53	}
54	var rawCallback func(AreaVarp uintptr, ContextVarp uintptr) bool
55	purego.RegisterFunc(&rawCallback, x.xRender)
56	return func(AreaVar *GLArea, ContextVar *gdk.GLContext) bool {
57		return rawCallback(AreaVar.GoPointer(), ContextVar.GoPointer())
58	}
59}
60
61// OverrideResize sets the "resize" callback function.
62// class closeure for the `GtkGLArea::resize` signal
63func (x *GLAreaClass) OverrideResize(cb func(*GLArea, int, int)) {
64	if cb == nil {
65		x.xResize = 0
66	} else {
67		x.xResize = purego.NewCallback(func(AreaVarp uintptr, WidthVarp int, HeightVarp int) {
68			cb(GLAreaNewFromInternalPtr(AreaVarp), WidthVarp, HeightVarp)
69		})
70	}
71}
72
73// GetResize gets the "resize" callback function.
74// class closeure for the `GtkGLArea::resize` signal
75func (x *GLAreaClass) GetResize() func(*GLArea, int, int) {
76	if x.xResize == 0 {
77		return nil
78	}
79	var rawCallback func(AreaVarp uintptr, WidthVarp int, HeightVarp int)
80	purego.RegisterFunc(&rawCallback, x.xResize)
81	return func(AreaVar *GLArea, WidthVar int, HeightVar int) {
82		rawCallback(AreaVar.GoPointer(), WidthVar, HeightVar)
83	}
84}
85
86// OverrideCreateContext sets the "create_context" callback function.
87// class closure for the `GtkGLArea::create-context` signal
88func (x *GLAreaClass) OverrideCreateContext(cb func(*GLArea) *gdk.GLContext) {
89	if cb == nil {
90		x.xCreateContext = 0
91	} else {
92		x.xCreateContext = purego.NewCallback(func(AreaVarp uintptr) uintptr {
93			ret := cb(GLAreaNewFromInternalPtr(AreaVarp))
94			if ret == nil {
95				return 0
96			}
97			return ret.GoPointer()
98		})
99	}
100}
101
102// GetCreateContext gets the "create_context" callback function.
103// class closure for the `GtkGLArea::create-context` signal
104func (x *GLAreaClass) GetCreateContext() func(*GLArea) *gdk.GLContext {
105	if x.xCreateContext == 0 {
106		return nil
107	}
108	var rawCallback func(AreaVarp uintptr) uintptr
109	purego.RegisterFunc(&rawCallback, x.xCreateContext)
110	return func(AreaVar *GLArea) *gdk.GLContext {
111		rawRet := rawCallback(AreaVar.GoPointer())
112		if rawRet == 0 {
113			return nil
114		}
115		ret := &gdk.GLContext{}
116		ret.Ptr = rawRet
117		return ret
118	}
119}
120
121// Allows drawing with OpenGL.
122//
123// <picture>
124//
125//	<source srcset="glarea-dark.png" media="(prefers-color-scheme: dark)">
126//	<img alt="An example GtkGLArea" src="glarea.png">
127//
128// </picture>
129//
130// `GtkGLArea` sets up its own [class@Gdk.GLContext], and creates a custom
131// GL framebuffer that the widget will do GL rendering onto. It also ensures
132// that this framebuffer is the default GL rendering target when rendering.
133// The completed rendering is integrated into the larger GTK scene graph as
134// a texture.
135//
136// In order to draw, you have to connect to the [signal@Gtk.GLArea::render]
137// signal, or subclass `GtkGLArea` and override the GtkGLAreaClass.render
138// virtual function.
139//
140// The `GtkGLArea` widget ensures that the `GdkGLContext` is associated with
141// the widget's drawing area, and it is kept updated when the size and
142// position of the drawing area changes.
143//
144// ## Drawing with GtkGLArea
145//
146// The simplest way to draw using OpenGL commands in a `GtkGLArea` is to
147// create a widget instance and connect to the [signal@Gtk.GLArea::render] signal:
148//
149// The `render()` function will be called when the `GtkGLArea` is ready
150// for you to draw its content:
151//
152// The initial contents of the framebuffer are transparent.
153//
154// ```c
155// static gboolean
156// render (GtkGLArea *area, GdkGLContext *context)
157//
158//	{
159//	  // inside this function it's safe to use GL; the given
160//	  // GdkGLContext has been made current to the drawable
161//	  // surface used by the `GtkGLArea` and the viewport has
162//	  // already been set to be the size of the allocation
163//
164//	  // we can start by clearing the buffer
165//	  glClearColor (0, 0, 0, 0);
166//	  glClear (GL_COLOR_BUFFER_BIT);
167//
168//	  // record the active framebuffer ID, so we can return to it
169//	  // with `glBindFramebuffer (GL_FRAMEBUFFER, screen_fb)` should
170//	  // we, for instance, intend on utilizing the results of an
171//	  // intermediate render texture pass
172//	  GLuint screen_fb = 0;
173//	  glGetIntegerv (GL_FRAMEBUFFER_BINDING, &screen_fb);
174//
175//	  // draw your object
176//	  // draw_an_object ();
177//
178//	  // we completed our drawing; the draw commands will be
179//	  // flushed at the end of the signal emission chain, and
180//	  // the buffers will be drawn on the window
181//	  return TRUE;
182//	}
183//
184// void setup_glarea (void)
185//
186//	{
187//	  // create a GtkGLArea instance
188//	  GtkWidget *gl_area = gtk_gl_area_new ();
189//
190//	  // connect to the "render" signal
191//	  g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL);
192//	}
193//
194// ```
195//
196// If you need to initialize OpenGL state, e.g. buffer objects or
197// shaders, you should use the [signal@Gtk.Widget::realize] signal;
198// you can use the [signal@Gtk.Widget::unrealize] signal to clean up.
199// Since the `GdkGLContext` creation and initialization may fail, you
200// will need to check for errors, using [method@Gtk.GLArea.get_error].
201//
202// An example of how to safely initialize the GL state is:
203//
204// ```c
205// static void
206// on_realize (GtkGLArea *area)
207//
208//	{
209//	  // We need to make the context current if we want to
210//	  // call GL API
211//	  gtk_gl_area_make_current (area);
212//
213//	  // If there were errors during the initialization or
214//	  // when trying to make the context current, this
215//	  // function will return a GError for you to catch
216//	  if (gtk_gl_area_get_error (area) != NULL)
217//	    return;
218//
219//	  // You can also use gtk_gl_area_set_error() in order
220//	  // to show eventual initialization errors on the
221//	  // GtkGLArea widget itself
222//	  GError *internal_error = NULL;
223//	  init_buffer_objects (&error);
224//	  if (error != NULL)
225//	    {
226//	      gtk_gl_area_set_error (area, error);
227//	      g_error_free (error);
228//	      return;
229//	    }
230//
231//	  init_shaders (&error);
232//	  if (error != NULL)
233//	    {
234//	      gtk_gl_area_set_error (area, error);
235//	      g_error_free (error);
236//	      return;
237//	    }
238//	}
239//
240// ```
241//
242// If you need to change the options for creating the `GdkGLContext`
243// you should use the [signal@Gtk.GLArea::create-context] signal.
244type GLArea struct {
245	Widget
246}
247
248var xGLAreaGLibType func() types.GType
249
250func GLAreaGLibType() types.GType {
251	return xGLAreaGLibType()
252}
253
254func GLAreaNewFromInternalPtr(ptr uintptr) *GLArea {
255	cls := &GLArea{}
256	cls.Ptr = ptr
257	return cls
258}
259
260var xNewGLArea func() uintptr
261
262// Creates a new `GtkGLArea` widget.
263func NewGLArea() *GLArea {
264	var cls *GLArea
265
266	cret := xNewGLArea()
267
268	if cret == 0 {
269		return nil
270	}
271	gobject.IncreaseRef(cret)
272	cls = &GLArea{}
273	cls.Ptr = cret
274	return cls
275}
276
277var xGLAreaAttachBuffers func(uintptr)
278
279// Binds buffers to the framebuffer.
280//
281// Ensures that the @area framebuffer object is made the current draw
282// and read target, and that all the required buffers for the @area
283// are created and bound to the framebuffer.
284//
285// This function is automatically called before emitting the
286// [signal@Gtk.GLArea::render] signal, and doesn't normally need to be
287// called by application code.
288func (x *GLArea) AttachBuffers() {
289
290	xGLAreaAttachBuffers(x.GoPointer())
291
292}
293
294var xGLAreaGetAllowedApis func(uintptr) gdk.GLAPI
295
296// Gets the allowed APIs.
297//
298// See [method@Gtk.GLArea.set_allowed_apis].
299func (x *GLArea) GetAllowedApis() gdk.GLAPI {
300
301	cret := xGLAreaGetAllowedApis(x.GoPointer())
302	return cret
303}
304
305var xGLAreaGetApi func(uintptr) gdk.GLAPI
306
307// Gets the API that is currently in use.
308//
309// If the GL area has not been realized yet, 0 is returned.
310func (x *GLArea) GetApi() gdk.GLAPI {
311
312	cret := xGLAreaGetApi(x.GoPointer())
313	return cret
314}
315
316var xGLAreaGetAutoRender func(uintptr) bool
317
318// Returns whether the area is in auto render mode or not.
319func (x *GLArea) GetAutoRender() bool {
320
321	cret := xGLAreaGetAutoRender(x.GoPointer())
322	return cret
323}
324
325var xGLAreaGetContext func(uintptr) uintptr
326
327// Retrieves the `GdkGLContext` used by @area.
328func (x *GLArea) GetContext() *gdk.GLContext {
329	var cls *gdk.GLContext
330
331	cret := xGLAreaGetContext(x.GoPointer())
332
333	if cret == 0 {
334		return nil
335	}
336	gobject.IncreaseRef(cret)
337	cls = &gdk.GLContext{}
338	cls.Ptr = cret
339	return cls
340}
341
342var xGLAreaGetError func(uintptr) *glib.Error
343
344// Gets the current error set on the @area.
345func (x *GLArea) GetError() *glib.Error {
346
347	cret := xGLAreaGetError(x.GoPointer())
348	return cret
349}
350
351var xGLAreaGetHasDepthBuffer func(uintptr) bool
352
353// Returns whether the area has a depth buffer.
354func (x *GLArea) GetHasDepthBuffer() bool {
355
356	cret := xGLAreaGetHasDepthBuffer(x.GoPointer())
357	return cret
358}
359
360var xGLAreaGetHasStencilBuffer func(uintptr) bool
361
362// Returns whether the area has a stencil buffer.
363func (x *GLArea) GetHasStencilBuffer() bool {
364
365	cret := xGLAreaGetHasStencilBuffer(x.GoPointer())
366	return cret
367}
368
369var xGLAreaGetRequiredVersion func(uintptr, *int, *int)
370
371// Retrieves the required version of OpenGL.
372//
373// See [method@Gtk.GLArea.set_required_version].
374func (x *GLArea) GetRequiredVersion(MajorVar *int, MinorVar *int) {
375
376	xGLAreaGetRequiredVersion(x.GoPointer(), MajorVar, MinorVar)
377
378}
379
380var xGLAreaGetUseEs func(uintptr) bool
381
382// Returns whether the `GtkGLArea` should use OpenGL ES.
383//
384// See [method@Gtk.GLArea.set_use_es].
385func (x *GLArea) GetUseEs() bool {
386
387	cret := xGLAreaGetUseEs(x.GoPointer())
388	return cret
389}
390
391var xGLAreaMakeCurrent func(uintptr)
392
393// Ensures that the `GdkGLContext` used by @area is associated with
394// the `GtkGLArea`.
395//
396// This function is automatically called before emitting the
397// [signal@Gtk.GLArea::render] signal, and doesn't normally need
398// to be called by application code.
399func (x *GLArea) MakeCurrent() {
400
401	xGLAreaMakeCurrent(x.GoPointer())
402
403}
404
405var xGLAreaQueueRender func(uintptr)
406
407// Marks the currently rendered data (if any) as invalid, and queues
408// a redraw of the widget.
409//
410// This ensures that the [signal@Gtk.GLArea::render] signal
411// is emitted during the draw.
412//
413// This is only needed when [method@Gtk.GLArea.set_auto_render] has
414// been called with a %FALSE value. The default behaviour is to
415// emit [signal@Gtk.GLArea::render] on each draw.
416func (x *GLArea) QueueRender() {
417
418	xGLAreaQueueRender(x.GoPointer())
419
420}
421
422var xGLAreaSetAllowedApis func(uintptr, gdk.GLAPI)
423
424// Sets the allowed APIs to create a context with.
425//
426// You should check [property@Gtk.GLArea:api] before drawing
427// with either API.
428//
429// By default, all APIs are allowed.
430func (x *GLArea) SetAllowedApis(ApisVar gdk.GLAPI) {
431
432	xGLAreaSetAllowedApis(x.GoPointer(), ApisVar)
433
434}
435
436var xGLAreaSetAutoRender func(uintptr, bool)
437
438// Sets whether the `GtkGLArea` is in auto render mode.
439//
440// If @auto_render is %TRUE the [signal@Gtk.GLArea::render] signal will
441// be emitted every time the widget draws. This is the default and is
442// useful if drawing the widget is faster.
443//
444// If @auto_render is %FALSE the data from previous rendering is kept
445// around and will be used for drawing the widget the next time,
446// unless the window is resized. In order to force a rendering
447// [method@Gtk.GLArea.queue_render] must be called. This mode is
448// useful when the scene changes seldom, but takes a long time to redraw.
449func (x *GLArea) SetAutoRender(AutoRenderVar bool) {
450
451	xGLAreaSetAutoRender(x.GoPointer(), AutoRenderVar)
452
453}
454
455var xGLAreaSetError func(uintptr, *glib.Error)
456
457// Sets an error on the area which will be shown instead of the
458// GL rendering.
459//
460// This is useful in the [signal@Gtk.GLArea::create-context]
461// signal if GL context creation fails.
462func (x *GLArea) SetError(ErrorVar *glib.Error) {
463
464	xGLAreaSetError(x.GoPointer(), ErrorVar)
465
466}
467
468var xGLAreaSetHasDepthBuffer func(uintptr, bool)
469
470// Sets whether the `GtkGLArea` should use a depth buffer.
471//
472// If @has_depth_buffer is %TRUE the widget will allocate and
473// enable a depth buffer for the target framebuffer. Otherwise
474// there will be none.
475func (x *GLArea) SetHasDepthBuffer(HasDepthBufferVar bool) {
476
477	xGLAreaSetHasDepthBuffer(x.GoPointer(), HasDepthBufferVar)
478
479}
480
481var xGLAreaSetHasStencilBuffer func(uintptr, bool)
482
483// Sets whether the `GtkGLArea` should use a stencil buffer.
484//
485// If @has_stencil_buffer is %TRUE the widget will allocate and
486// enable a stencil buffer for the target framebuffer. Otherwise
487// there will be none.
488func (x *GLArea) SetHasStencilBuffer(HasStencilBufferVar bool) {
489
490	xGLAreaSetHasStencilBuffer(x.GoPointer(), HasStencilBufferVar)
491
492}
493
494var xGLAreaSetRequiredVersion func(uintptr, int, int)
495
496// Sets the required version of OpenGL to be used when creating
497// the context for the widget.
498//
499// This function must be called before the area has been realized.
500func (x *GLArea) SetRequiredVersion(MajorVar int, MinorVar int) {
501
502	xGLAreaSetRequiredVersion(x.GoPointer(), MajorVar, MinorVar)
503
504}
505
506var xGLAreaSetUseEs func(uintptr, bool)
507
508// Sets whether the @area should create an OpenGL or an OpenGL ES context.
509//
510// You should check the capabilities of the `GdkGLContext` before drawing
511// with either API.
512func (x *GLArea) SetUseEs(UseEsVar bool) {
513
514	xGLAreaSetUseEs(x.GoPointer(), UseEsVar)
515
516}
517
518func (c *GLArea) GoPointer() uintptr {
519	if c == nil {
520		return 0
521	}
522	return c.Ptr
523}
524
525func (c *GLArea) SetGoPointer(ptr uintptr) {
526	c.Ptr = ptr
527}
528
529// SetPropertyAutoRender sets the "auto-render" property.
530// If set to %TRUE the ::render signal will be emitted every time
531// the widget draws.
532//
533// This is the default and is useful if drawing the widget is faster.
534//
535// If set to %FALSE the data from previous rendering is kept around and will
536// be used for drawing the widget the next time, unless the window is resized.
537// In order to force a rendering [method@Gtk.GLArea.queue_render] must be called.
538// This mode is useful when the scene changes seldom, but takes a long time
539// to redraw.
540func (x *GLArea) SetPropertyAutoRender(value bool) {
541	var v gobject.Value
542	v.Init(gobject.TypeBooleanVal)
543	v.SetBoolean(value)
544	x.SetProperty("auto-render", &v)
545}
546
547// GetPropertyAutoRender gets the "auto-render" property.
548// If set to %TRUE the ::render signal will be emitted every time
549// the widget draws.
550//
551// This is the default and is useful if drawing the widget is faster.
552//
553// If set to %FALSE the data from previous rendering is kept around and will
554// be used for drawing the widget the next time, unless the window is resized.
555// In order to force a rendering [method@Gtk.GLArea.queue_render] must be called.
556// This mode is useful when the scene changes seldom, but takes a long time
557// to redraw.
558func (x *GLArea) GetPropertyAutoRender() bool {
559	var v gobject.Value
560	x.GetProperty("auto-render", &v)
561	return v.GetBoolean()
562}
563
564// SetPropertyHasDepthBuffer sets the "has-depth-buffer" property.
565// If set to %TRUE the widget will allocate and enable a depth buffer for the
566// target framebuffer.
567//
568// Setting this property will enable GL's depth testing as a side effect. If
569// you don't need depth testing, you should call `glDisable(GL_DEPTH_TEST)`
570// in your `GtkGLArea::render` handler.
571func (x *GLArea) SetPropertyHasDepthBuffer(value bool) {
572	var v gobject.Value
573	v.Init(gobject.TypeBooleanVal)
574	v.SetBoolean(value)
575	x.SetProperty("has-depth-buffer", &v)
576}
577
578// GetPropertyHasDepthBuffer gets the "has-depth-buffer" property.
579// If set to %TRUE the widget will allocate and enable a depth buffer for the
580// target framebuffer.
581//
582// Setting this property will enable GL's depth testing as a side effect. If
583// you don't need depth testing, you should call `glDisable(GL_DEPTH_TEST)`
584// in your `GtkGLArea::render` handler.
585func (x *GLArea) GetPropertyHasDepthBuffer() bool {
586	var v gobject.Value
587	x.GetProperty("has-depth-buffer", &v)
588	return v.GetBoolean()
589}
590
591// SetPropertyHasStencilBuffer sets the "has-stencil-buffer" property.
592// If set to %TRUE the widget will allocate and enable a stencil buffer for the
593// target framebuffer.
594func (x *GLArea) SetPropertyHasStencilBuffer(value bool) {
595	var v gobject.Value
596	v.Init(gobject.TypeBooleanVal)
597	v.SetBoolean(value)
598	x.SetProperty("has-stencil-buffer", &v)
599}
600
601// GetPropertyHasStencilBuffer gets the "has-stencil-buffer" property.
602// If set to %TRUE the widget will allocate and enable a stencil buffer for the
603// target framebuffer.
604func (x *GLArea) GetPropertyHasStencilBuffer() bool {
605	var v gobject.Value
606	x.GetProperty("has-stencil-buffer", &v)
607	return v.GetBoolean()
608}
609
610// SetPropertyUseEs sets the "use-es" property.
611// If set to %TRUE the widget will try to create a `GdkGLContext` using
612// OpenGL ES instead of OpenGL.
613func (x *GLArea) SetPropertyUseEs(value bool) {
614	var v gobject.Value
615	v.Init(gobject.TypeBooleanVal)
616	v.SetBoolean(value)
617	x.SetProperty("use-es", &v)
618}
619
620// GetPropertyUseEs gets the "use-es" property.
621// If set to %TRUE the widget will try to create a `GdkGLContext` using
622// OpenGL ES instead of OpenGL.
623func (x *GLArea) GetPropertyUseEs() bool {
624	var v gobject.Value
625	x.GetProperty("use-es", &v)
626	return v.GetBoolean()
627}
628
629// Emitted when the widget is being realized.
630//
631// This allows you to override how the GL context is created.
632// This is useful when you want to reuse an existing GL context,
633// or if you want to try creating different kinds of GL options.
634//
635// If context creation fails then the signal handler can use
636// [method@Gtk.GLArea.set_error] to register a more detailed error
637// of how the construction failed.
638func (x *GLArea) ConnectCreateContext(cb *func(GLArea) gdk.GLContext) uint {
639	cbPtr := uintptr(unsafe.Pointer(cb))
640	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
641		handlerID := gobject.SignalConnect(x.GoPointer(), "create-context", cbRefPtr)
642		glib.SaveHandlerMapping(handlerID, cbPtr)
643		return handlerID
644	}
645
646	fcb := func(clsPtr uintptr) uintptr {
647		fa := GLArea{}
648		fa.Ptr = clsPtr
649		cbFn := *cb
650
651		CreateContextCls := cbFn(fa)
652		return CreateContextCls.Ptr
653
654	}
655	cbRefPtr := purego.NewCallback(fcb)
656	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
657	handlerID := gobject.SignalConnect(x.GoPointer(), "create-context", cbRefPtr)
658	glib.SaveHandlerMapping(handlerID, cbPtr)
659	return handlerID
660}
661
662// Emitted every time the contents of the `GtkGLArea` should be redrawn.
663//
664// The @context is bound to the @area prior to emitting this function,
665// and the buffers are painted to the window once the emission terminates.
666func (x *GLArea) ConnectRender(cb *func(GLArea, uintptr) bool) uint {
667	cbPtr := uintptr(unsafe.Pointer(cb))
668	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
669		handlerID := gobject.SignalConnect(x.GoPointer(), "render", cbRefPtr)
670		glib.SaveHandlerMapping(handlerID, cbPtr)
671		return handlerID
672	}
673
674	fcb := func(clsPtr uintptr, ContextVarp uintptr) bool {
675		fa := GLArea{}
676		fa.Ptr = clsPtr
677		cbFn := *cb
678
679		return cbFn(fa, ContextVarp)
680
681	}
682	cbRefPtr := purego.NewCallback(fcb)
683	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
684	handlerID := gobject.SignalConnect(x.GoPointer(), "render", cbRefPtr)
685	glib.SaveHandlerMapping(handlerID, cbPtr)
686	return handlerID
687}
688
689// Emitted once when the widget is realized, and then each time the widget
690// is changed while realized.
691//
692// This is useful in order to keep GL state up to date with the widget size,
693// like for instance camera properties which may depend on the width/height
694// ratio.
695//
696// The GL context for the area is guaranteed to be current when this signal
697// is emitted.
698//
699// The default handler sets up the GL viewport.
700func (x *GLArea) ConnectResize(cb *func(GLArea, int, int)) uint {
701	cbPtr := uintptr(unsafe.Pointer(cb))
702	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
703		handlerID := gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr)
704		glib.SaveHandlerMapping(handlerID, cbPtr)
705		return handlerID
706	}
707
708	fcb := func(clsPtr uintptr, WidthVarp int, HeightVarp int) {
709		fa := GLArea{}
710		fa.Ptr = clsPtr
711		cbFn := *cb
712
713		cbFn(fa, WidthVarp, HeightVarp)
714
715	}
716	cbRefPtr := purego.NewCallback(fcb)
717	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
718	handlerID := gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr)
719	glib.SaveHandlerMapping(handlerID, cbPtr)
720	return handlerID
721}
722
723// Requests the user's screen reader to announce the given message.
724//
725// This kind of notification is useful for messages that
726// either have only a visual representation or that are not
727// exposed visually at all, e.g. a notification about a
728// successful operation.
729//
730// Also, by using this API, you can ensure that the message
731// does not interrupts the user's current screen reader output.
732func (x *GLArea) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) {
733
734	XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
735
736}
737
738// Retrieves the accessible parent for an accessible object.
739//
740// This function returns `NULL` for top level widgets.
741func (x *GLArea) GetAccessibleParent() *AccessibleBase {
742	var cls *AccessibleBase
743
744	cret := XGtkAccessibleGetAccessibleParent(x.GoPointer())
745
746	if cret == 0 {
747		return nil
748	}
749	cls = &AccessibleBase{}
750	cls.Ptr = cret
751	return cls
752}
753
754// Retrieves the accessible role of an accessible object.
755func (x *GLArea) GetAccessibleRole() AccessibleRole {
756
757	cret := XGtkAccessibleGetAccessibleRole(x.GoPointer())
758	return cret
759}
760
761// Retrieves the implementation for the given accessible object.
762func (x *GLArea) GetAtContext() *ATContext {
763	var cls *ATContext
764
765	cret := XGtkAccessibleGetAtContext(x.GoPointer())
766
767	if cret == 0 {
768		return nil
769	}
770	cls = &ATContext{}
771	cls.Ptr = cret
772	return cls
773}
774
775// Queries the coordinates and dimensions of this accessible
776//
777// This functionality can be overridden by `GtkAccessible`
778// implementations, e.g. to get the bounds from an ignored
779// child widget.
780func (x *GLArea) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
781
782	cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
783	return cret
784}
785
786// Retrieves the first accessible child of an accessible object.
787func (x *GLArea) GetFirstAccessibleChild() *AccessibleBase {
788	var cls *AccessibleBase
789
790	cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
791
792	if cret == 0 {
793		return nil
794	}
795	cls = &AccessibleBase{}
796	cls.Ptr = cret
797	return cls
798}
799
800// Retrieves the next accessible sibling of an accessible object
801func (x *GLArea) GetNextAccessibleSibling() *AccessibleBase {
802	var cls *AccessibleBase
803
804	cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
805
806	if cret == 0 {
807		return nil
808	}
809	cls = &AccessibleBase{}
810	cls.Ptr = cret
811	return cls
812}
813
814// Queries a platform state, such as focus.
815//
816// This functionality can be overridden by `GtkAccessible`
817// implementations, e.g. to get platform state from an ignored
818// child widget, as is the case for `GtkText` wrappers.
819func (x *GLArea) GetPlatformState(StateVar AccessiblePlatformState) bool {
820
821	cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
822	return cret
823}
824
825// Resets the accessible property to its default value.
826func (x *GLArea) ResetProperty(PropertyVar AccessibleProperty) {
827
828	XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
829
830}
831
832// Resets the accessible relation to its default value.
833func (x *GLArea) ResetRelation(RelationVar AccessibleRelation) {
834
835	XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
836
837}
838
839// Resets the accessible state to its default value.
840func (x *GLArea) ResetState(StateVar AccessibleState) {
841
842	XGtkAccessibleResetState(x.GoPointer(), StateVar)
843
844}
845
846// Sets the parent and sibling of an accessible object.
847//
848// This function is meant to be used by accessible implementations that are
849// not part of the widget hierarchy, and but act as a logical bridge between
850// widgets. For instance, if a widget creates an object that holds metadata
851// for each child, and you want that object to implement the `GtkAccessible`
852// interface, you will use this function to ensure that the parent of each
853// child widget is the metadata object, and the parent of each metadata
854// object is the container widget.
855func (x *GLArea) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) {
856
857	XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
858
859}
860
861// Updates the next accessible sibling.
862//
863// That might be useful when a new child of a custom accessible
864// is created, and it needs to be linked to a previous child.
865func (x *GLArea) UpdateNextAccessibleSibling(NewSiblingVar Accessible) {
866
867	XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
868
869}
870
871// Informs ATs that the platform state has changed.
872//
873// This function should be used by `GtkAccessible` implementations that
874// have a platform state but are not widgets. Widgets handle platform
875// states automatically.
876func (x *GLArea) UpdatePlatformState(StateVar AccessiblePlatformState) {
877
878	XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
879
880}
881
882// Updates a list of accessible properties.
883//
884// See the [enum@Gtk.AccessibleProperty] documentation for the
885// value types of accessible properties.
886//
887// This function should be called by `GtkWidget` types whenever
888// an accessible property change must be communicated to assistive
889// technologies.
890//
891// Example:
892// ```c
893// value = gtk_adjustment_get_value (adjustment);
894// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
895//
896//	GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
897//	-1);
898//
899// ```
900func (x *GLArea) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) {
901
902	XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
903
904}
905
906// Updates an array of accessible properties.
907//
908// This function should be called by `GtkWidget` types whenever an accessible
909// property change must be communicated to assistive technologies.
910//
911// This function is meant to be used by language bindings.
912func (x *GLArea) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) {
913
914	XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
915
916}
917
918// Updates a list of accessible relations.
919//
920// This function should be called by `GtkWidget` types whenever an accessible
921// relation change must be communicated to assistive technologies.
922//
923// If the [enum@Gtk.AccessibleRelation] requires a list of references,
924// you should pass each reference individually, followed by `NULL`, e.g.
925//
926// ```c
927// gtk_accessible_update_relation (accessible,
928//
929//	GTK_ACCESSIBLE_RELATION_CONTROLS,
930//	  ref1, NULL,
931//	GTK_ACCESSIBLE_RELATION_LABELLED_BY,
932//	  ref1, ref2, ref3, NULL,
933//	-1);
934//
935// ```
936func (x *GLArea) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) {
937
938	XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
939
940}
941
942// Updates an array of accessible relations.
943//
944// This function should be called by `GtkWidget` types whenever an accessible
945// relation change must be communicated to assistive technologies.
946//
947// This function is meant to be used by language bindings.
948func (x *GLArea) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) {
949
950	XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
951
952}
953
954// Updates a list of accessible states.
955//
956// See the [enum@Gtk.AccessibleState] documentation for the
957// value types of accessible states.
958//
959// This function should be called by `GtkWidget` types whenever
960// an accessible state change must be communicated to assistive
961// technologies.
962//
963// Example:
964//
965// ```c
966// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
967// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
968//
969//	GTK_ACCESSIBLE_STATE_CHECKED, value,
970//	-1);
971//
972// ```
973func (x *GLArea) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) {
974
975	XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
976
977}
978
979// Updates an array of accessible states.
980//
981// This function should be called by `GtkWidget` types whenever an accessible
982// state change must be communicated to assistive technologies.
983//
984// This function is meant to be used by language bindings.
985func (x *GLArea) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) {
986
987	XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
988
989}
990
991// Gets the ID of the @buildable object.
992//
993// `GtkBuilder` sets the name based on the ID attribute
994// of the `<object>` tag used to construct the @buildable.
995func (x *GLArea) GetBuildableId() string {
996
997	cret := XGtkBuildableGetBuildableId(x.GoPointer())
998	return cret
999}
1000
1001func init() {
1002	core.SetPackageName("GTK", "gtk4")
1003	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
1004	var libs []uintptr
1005	for _, libPath := range core.GetPaths("GTK") {
1006		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1007		if err != nil {
1008			panic(err)
1009		}
1010		libs = append(libs, lib)
1011	}
1012
1013	core.PuregoSafeRegister(&xGLAreaGLibType, libs, "gtk_gl_area_get_type")
1014
1015	core.PuregoSafeRegister(&xNewGLArea, libs, "gtk_gl_area_new")
1016
1017	core.PuregoSafeRegister(&xGLAreaAttachBuffers, libs, "gtk_gl_area_attach_buffers")
1018	core.PuregoSafeRegister(&xGLAreaGetAllowedApis, libs, "gtk_gl_area_get_allowed_apis")
1019	core.PuregoSafeRegister(&xGLAreaGetApi, libs, "gtk_gl_area_get_api")
1020	core.PuregoSafeRegister(&xGLAreaGetAutoRender, libs, "gtk_gl_area_get_auto_render")
1021	core.PuregoSafeRegister(&xGLAreaGetContext, libs, "gtk_gl_area_get_context")
1022	core.PuregoSafeRegister(&xGLAreaGetError, libs, "gtk_gl_area_get_error")
1023	core.PuregoSafeRegister(&xGLAreaGetHasDepthBuffer, libs, "gtk_gl_area_get_has_depth_buffer")
1024	core.PuregoSafeRegister(&xGLAreaGetHasStencilBuffer, libs, "gtk_gl_area_get_has_stencil_buffer")
1025	core.PuregoSafeRegister(&xGLAreaGetRequiredVersion, libs, "gtk_gl_area_get_required_version")
1026	core.PuregoSafeRegister(&xGLAreaGetUseEs, libs, "gtk_gl_area_get_use_es")
1027	core.PuregoSafeRegister(&xGLAreaMakeCurrent, libs, "gtk_gl_area_make_current")
1028	core.PuregoSafeRegister(&xGLAreaQueueRender, libs, "gtk_gl_area_queue_render")
1029	core.PuregoSafeRegister(&xGLAreaSetAllowedApis, libs, "gtk_gl_area_set_allowed_apis")
1030	core.PuregoSafeRegister(&xGLAreaSetAutoRender, libs, "gtk_gl_area_set_auto_render")
1031	core.PuregoSafeRegister(&xGLAreaSetError, libs, "gtk_gl_area_set_error")
1032	core.PuregoSafeRegister(&xGLAreaSetHasDepthBuffer, libs, "gtk_gl_area_set_has_depth_buffer")
1033	core.PuregoSafeRegister(&xGLAreaSetHasStencilBuffer, libs, "gtk_gl_area_set_has_stencil_buffer")
1034	core.PuregoSafeRegister(&xGLAreaSetRequiredVersion, libs, "gtk_gl_area_set_required_version")
1035	core.PuregoSafeRegister(&xGLAreaSetUseEs, libs, "gtk_gl_area_set_use_es")
1036
1037}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close