v0.2.2 9100209

gskrenderer.go RawHistoryFolder

1// Package gsk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gsk
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/cairo"
12	"github.com/bnema/puregotk/v4/gdk"
13	"github.com/bnema/puregotk/v4/glib"
14	"github.com/bnema/puregotk/v4/gobject"
15	"github.com/bnema/puregotk/v4/gobject/types"
16	"github.com/bnema/puregotk/v4/graphene"
17)
18
19type RendererClass struct {
20	_ structs.HostLayout
21}
22
23func (x *RendererClass) GoPointer() uintptr {
24	return uintptr(unsafe.Pointer(x))
25}
26
27// Renders a scene graph defined via a tree of [class@Gsk.RenderNode] instances.
28//
29// Typically you will use a `GskRenderer` instance to repeatedly call
30// [method@Gsk.Renderer.render] to update the contents of its associated
31// [class@Gdk.Surface].
32//
33// It is necessary to realize a `GskRenderer` instance using
34// [method@Gsk.Renderer.realize] before calling [method@Gsk.Renderer.render],
35// in order to create the appropriate windowing system resources needed
36// to render the scene.
37type Renderer struct {
38	gobject.Object
39}
40
41var xRendererGLibType func() types.GType
42
43func RendererGLibType() types.GType {
44	return xRendererGLibType()
45}
46
47func RendererNewFromInternalPtr(ptr uintptr) *Renderer {
48	cls := &Renderer{}
49	cls.Ptr = ptr
50	return cls
51}
52
53var xNewRendererForSurface func(uintptr) uintptr
54
55// Creates an appropriate `GskRenderer` instance for the given surface.
56//
57// If the `GSK_RENDERER` environment variable is set, GSK will
58// try that renderer first, before trying the backend-specific
59// default. The ultimate fallback is the cairo renderer.
60//
61// The renderer will be realized before it is returned.
62func NewRendererForSurface(SurfaceVar *gdk.Surface) *Renderer {
63	var cls *Renderer
64
65	cret := xNewRendererForSurface(SurfaceVar.GoPointer())
66
67	if cret == 0 {
68		return nil
69	}
70	cls = &Renderer{}
71	cls.Ptr = cret
72	return cls
73}
74
75var xRendererGetSurface func(uintptr) uintptr
76
77// Retrieves the surface that the renderer is associated with.
78//
79// If the renderer has not been realized yet, `NULL` will be returned.
80func (x *Renderer) GetSurface() *gdk.Surface {
81	var cls *gdk.Surface
82
83	cret := xRendererGetSurface(x.GoPointer())
84
85	if cret == 0 {
86		return nil
87	}
88	gobject.IncreaseRef(cret)
89	cls = &gdk.Surface{}
90	cls.Ptr = cret
91	return cls
92}
93
94var xRendererIsRealized func(uintptr) bool
95
96// Checks whether the renderer is realized or not.
97func (x *Renderer) IsRealized() bool {
98
99	cret := xRendererIsRealized(x.GoPointer())
100	return cret
101}
102
103var xRendererRealize func(uintptr, uintptr, **glib.Error) bool
104
105// Creates the resources needed by the renderer.
106//
107// Since GTK 4.6, the surface may be `NULL`, which allows using
108// renderers without having to create a surface. Since GTK 4.14,
109// it is recommended to use [method@Gsk.Renderer.realize_for_display]
110// for this case.
111//
112// Note that it is mandatory to call [method@Gsk.Renderer.unrealize]
113// before destroying the renderer.
114func (x *Renderer) Realize(SurfaceVar *gdk.Surface) (bool, error) {
115	var cerr *glib.Error
116
117	cret := xRendererRealize(x.GoPointer(), SurfaceVar.GoPointer(), &cerr)
118	if cerr == nil {
119		return cret, nil
120	}
121	return cret, cerr
122
123}
124
125var xRendererRealizeForDisplay func(uintptr, uintptr, **glib.Error) bool
126
127// Creates the resources needed by the renderer.
128//
129// Note that it is mandatory to call [method@Gsk.Renderer.unrealize]
130// before destroying the renderer.
131func (x *Renderer) RealizeForDisplay(DisplayVar *gdk.Display) (bool, error) {
132	var cerr *glib.Error
133
134	cret := xRendererRealizeForDisplay(x.GoPointer(), DisplayVar.GoPointer(), &cerr)
135	if cerr == nil {
136		return cret, nil
137	}
138	return cret, cerr
139
140}
141
142var xRendererRender func(uintptr, uintptr, *cairo.Region)
143
144// Renders the scene graph, described by a tree of `GskRenderNode` instances
145// to the renderer's surface, ensuring that the given region gets redrawn.
146//
147// If the renderer has no associated surface, this function does nothing.
148//
149// Renderers must ensure that changes of the contents given by the @root
150// node as well as the area given by @region are redrawn. They are however
151// free to not redraw any pixel outside of @region if they can guarantee that
152// it didn't change.
153//
154// The renderer will acquire a reference on the `GskRenderNode` tree while
155// the rendering is in progress.
156func (x *Renderer) Render(RootVar *RenderNode, RegionVar *cairo.Region) {
157
158	xRendererRender(x.GoPointer(), RootVar.GoPointer(), RegionVar)
159
160}
161
162var xRendererRenderTexture func(uintptr, uintptr, *graphene.Rect) uintptr
163
164// Renders a scene graph, described by a tree of `GskRenderNode` instances,
165// to a texture.
166//
167// The renderer will acquire a reference on the `GskRenderNode` tree while
168// the rendering is in progress.
169//
170// If you want to apply any transformations to @root, you should put it into a
171// transform node and pass that node instead.
172func (x *Renderer) RenderTexture(RootVar *RenderNode, ViewportVar *graphene.Rect) *gdk.Texture {
173	var cls *gdk.Texture
174
175	cret := xRendererRenderTexture(x.GoPointer(), RootVar.GoPointer(), ViewportVar)
176
177	if cret == 0 {
178		return nil
179	}
180	cls = &gdk.Texture{}
181	cls.Ptr = cret
182	return cls
183}
184
185var xRendererUnrealize func(uintptr)
186
187// Releases all the resources created by [method@Gsk.Renderer.realize].
188func (x *Renderer) Unrealize() {
189
190	xRendererUnrealize(x.GoPointer())
191
192}
193
194func (c *Renderer) GoPointer() uintptr {
195	if c == nil {
196		return 0
197	}
198	return c.Ptr
199}
200
201func (c *Renderer) SetGoPointer(ptr uintptr) {
202	c.Ptr = ptr
203}
204
205// GetPropertyRealized gets the "realized" property.
206// Whether the renderer has been associated with a surface or draw context.
207func (x *Renderer) GetPropertyRealized() bool {
208	var v gobject.Value
209	x.GetProperty("realized", &v)
210	return v.GetBoolean()
211}
212
213func init() {
214	core.SetPackageName("GSK", "gtk4")
215	core.SetSharedLibraries("GSK", []string{"libgtk-4.so.1"})
216	var libs []uintptr
217	for _, libPath := range core.GetPaths("GSK") {
218		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
219		if err != nil {
220			panic(err)
221		}
222		libs = append(libs, lib)
223	}
224
225	core.PuregoSafeRegister(&xRendererGLibType, libs, "gsk_renderer_get_type")
226
227	core.PuregoSafeRegister(&xNewRendererForSurface, libs, "gsk_renderer_new_for_surface")
228
229	core.PuregoSafeRegister(&xRendererGetSurface, libs, "gsk_renderer_get_surface")
230	core.PuregoSafeRegister(&xRendererIsRealized, libs, "gsk_renderer_is_realized")
231	core.PuregoSafeRegister(&xRendererRealize, libs, "gsk_renderer_realize")
232	core.PuregoSafeRegister(&xRendererRealizeForDisplay, libs, "gsk_renderer_realize_for_display")
233	core.PuregoSafeRegister(&xRendererRender, libs, "gsk_renderer_render")
234	core.PuregoSafeRegister(&xRendererRenderTexture, libs, "gsk_renderer_render_texture")
235	core.PuregoSafeRegister(&xRendererUnrealize, libs, "gsk_renderer_unrealize")
236
237}

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