1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
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/gio"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type MemoryTextureClass struct {
17 _ structs.HostLayout
18}
19
20func (x *MemoryTextureClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// A `GdkTexture` representing image data in memory.
25type MemoryTexture struct {
26 Texture
27}
28
29var xMemoryTextureGLibType func() types.GType
30
31func MemoryTextureGLibType() types.GType {
32 return xMemoryTextureGLibType()
33}
34
35func MemoryTextureNewFromInternalPtr(ptr uintptr) *MemoryTexture {
36 cls := &MemoryTexture{}
37 cls.Ptr = ptr
38 return cls
39}
40
41var xNewMemoryTexture func(int, int, MemoryFormat, *glib.Bytes, uint) uintptr
42
43// Creates a new texture for a blob of image data.
44//
45// The `GBytes` must contain @stride × @height pixels
46// in the given format.
47func NewMemoryTexture(WidthVar int, HeightVar int, FormatVar MemoryFormat, BytesVar *glib.Bytes, StrideVar uint) *MemoryTexture {
48 var cls *MemoryTexture
49
50 cret := xNewMemoryTexture(WidthVar, HeightVar, FormatVar, BytesVar, StrideVar)
51
52 if cret == 0 {
53 return nil
54 }
55 cls = &MemoryTexture{}
56 cls.Ptr = cret
57 return cls
58}
59
60func (c *MemoryTexture) GoPointer() uintptr {
61 if c == nil {
62 return 0
63 }
64 return c.Ptr
65}
66
67func (c *MemoryTexture) SetGoPointer(ptr uintptr) {
68 c.Ptr = ptr
69}
70
71// Compute a concrete size for the `GdkPaintable`.
72//
73// Applies the sizing algorithm outlined in the
74// [CSS Image spec](https://drafts.csswg.org/css-images-3/#default-sizing)
75// to the given @paintable. See that link for more details.
76//
77// It is not necessary to call this function when both @specified_width
78// and @specified_height are known, but it is useful to call this
79// function in GtkWidget:measure implementations to compute the
80// other dimension when only one dimension is given.
81func (x *MemoryTexture) ComputeConcreteSize(SpecifiedWidthVar float64, SpecifiedHeightVar float64, DefaultWidthVar float64, DefaultHeightVar float64, ConcreteWidthVar *float64, ConcreteHeightVar *float64) {
82
83 XGdkPaintableComputeConcreteSize(x.GoPointer(), SpecifiedWidthVar, SpecifiedHeightVar, DefaultWidthVar, DefaultHeightVar, ConcreteWidthVar, ConcreteHeightVar)
84
85}
86
87// Gets an immutable paintable for the current contents displayed by @paintable.
88//
89// This is useful when you want to retain the current state of an animation,
90// for example to take a screenshot of a running animation.
91//
92// If the @paintable is already immutable, it will return itself.
93func (x *MemoryTexture) GetCurrentImage() *PaintableBase {
94 var cls *PaintableBase
95
96 cret := XGdkPaintableGetCurrentImage(x.GoPointer())
97
98 if cret == 0 {
99 return nil
100 }
101 cls = &PaintableBase{}
102 cls.Ptr = cret
103 return cls
104}
105
106// Get flags for the paintable.
107//
108// This is oftentimes useful for optimizations.
109//
110// See [flags@Gdk.PaintableFlags] for the flags and what they mean.
111func (x *MemoryTexture) GetFlags() PaintableFlags {
112
113 cret := XGdkPaintableGetFlags(x.GoPointer())
114 return cret
115}
116
117// Gets the preferred aspect ratio the @paintable would like to be displayed at.
118//
119// The aspect ratio is the width divided by the height, so a value of 0.5
120// means that the @paintable prefers to be displayed twice as high as it
121// is wide. Consumers of this interface can use this to preserve aspect
122// ratio when displaying the paintable.
123//
124// This is a purely informational value and does not in any way limit the
125// values that may be passed to [method@Gdk.Paintable.snapshot].
126//
127// Usually when a @paintable returns nonzero values from
128// [method@Gdk.Paintable.get_intrinsic_width] and
129// [method@Gdk.Paintable.get_intrinsic_height] the aspect ratio
130// should conform to those values, though that is not required.
131//
132// If the @paintable does not have a preferred aspect ratio,
133// it returns 0. Negative values are never returned.
134func (x *MemoryTexture) GetIntrinsicAspectRatio() float64 {
135
136 cret := XGdkPaintableGetIntrinsicAspectRatio(x.GoPointer())
137 return cret
138}
139
140// Gets the preferred height the @paintable would like to be displayed at.
141//
142// Consumers of this interface can use this to reserve enough space to draw
143// the paintable.
144//
145// This is a purely informational value and does not in any way limit the
146// values that may be passed to [method@Gdk.Paintable.snapshot].
147//
148// If the @paintable does not have a preferred height, it returns 0.
149// Negative values are never returned.
150func (x *MemoryTexture) GetIntrinsicHeight() int {
151
152 cret := XGdkPaintableGetIntrinsicHeight(x.GoPointer())
153 return cret
154}
155
156// Gets the preferred width the @paintable would like to be displayed at.
157//
158// Consumers of this interface can use this to reserve enough space to draw
159// the paintable.
160//
161// This is a purely informational value and does not in any way limit the
162// values that may be passed to [method@Gdk.Paintable.snapshot].
163//
164// If the @paintable does not have a preferred width, it returns 0.
165// Negative values are never returned.
166func (x *MemoryTexture) GetIntrinsicWidth() int {
167
168 cret := XGdkPaintableGetIntrinsicWidth(x.GoPointer())
169 return cret
170}
171
172// Called by implementations of `GdkPaintable` to invalidate their contents.
173//
174// Unless the contents are invalidated, implementations must guarantee that
175// multiple calls of [method@Gdk.Paintable.snapshot] produce the same output.
176//
177// This function will emit the [signal@Gdk.Paintable::invalidate-contents]
178// signal.
179//
180// If a @paintable reports the %GDK_PAINTABLE_STATIC_CONTENTS flag,
181// it must not call this function.
182func (x *MemoryTexture) InvalidateContents() {
183
184 XGdkPaintableInvalidateContents(x.GoPointer())
185
186}
187
188// Called by implementations of `GdkPaintable` to invalidate their size.
189//
190// As long as the size is not invalidated, @paintable must return the same
191// values for its intrinsic width, height and aspect ratio.
192//
193// This function will emit the [signal@Gdk.Paintable::invalidate-size]
194// signal.
195//
196// If a @paintable reports the %GDK_PAINTABLE_STATIC_SIZE flag,
197// it must not call this function.
198func (x *MemoryTexture) InvalidateSize() {
199
200 XGdkPaintableInvalidateSize(x.GoPointer())
201
202}
203
204// Snapshots the given paintable with the given @width and @height.
205//
206// The paintable is drawn at the current (0,0) offset of the @snapshot.
207// If @width and @height are not larger than zero, this function will
208// do nothing.
209func (x *MemoryTexture) Snapshot(SnapshotVar *Snapshot, WidthVar float64, HeightVar float64) {
210
211 XGdkPaintableSnapshot(x.GoPointer(), SnapshotVar.GoPointer(), WidthVar, HeightVar)
212
213}
214
215// Checks if two icons are equal.
216func (x *MemoryTexture) Equal(Icon2Var gio.Icon) bool {
217
218 cret := gio.XGIconEqual(x.GoPointer(), Icon2Var.GoPointer())
219 return cret
220}
221
222// Gets a hash for an icon.
223func (x *MemoryTexture) Hash() uint {
224
225 cret := gio.XGIconHash(x.GoPointer())
226 return cret
227}
228
229// Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved
230// back by calling g_icon_deserialize() on the returned value.
231// As serialization will avoid using raw icon data when possible, it only
232// makes sense to transfer the #GVariant between processes on the same machine,
233// (as opposed to over the network), and within the same file system namespace.
234func (x *MemoryTexture) Serialize() *glib.Variant {
235
236 cret := gio.XGIconSerialize(x.GoPointer())
237 return cret
238}
239
240// Generates a textual representation of @icon that can be used for
241// serialization such as when passing @icon to a different process or
242// saving it to persistent storage. Use g_icon_new_for_string() to
243// get @icon back from the returned string.
244//
245// The encoding of the returned string is proprietary to #GIcon except
246// in the following two cases
247//
248// - If @icon is a #GFileIcon, the returned string is a native path
249// (such as `/path/to/my icon.png`) without escaping
250// if the #GFile for @icon is a native file. If the file is not
251// native, the returned string is the result of g_file_get_uri()
252// (such as `sftp://path/to/my%20icon.png`).
253//
254// - If @icon is a #GThemedIcon with exactly one name and no fallbacks,
255// the encoding is simply the name (such as `network-server`).
256func (x *MemoryTexture) ToString() string {
257
258 cret := gio.XGIconToString(x.GoPointer())
259 return cret
260}
261
262// Loads a loadable icon. For the asynchronous version of this function,
263// see g_loadable_icon_load_async().
264func (x *MemoryTexture) Load(SizeVar int, TypeVar *string, CancellableVar *gio.Cancellable) (*gio.InputStream, error) {
265 var cls *gio.InputStream
266 var cerr *glib.Error
267
268 cret := gio.XGLoadableIconLoad(x.GoPointer(), SizeVar, TypeVar, CancellableVar.GoPointer(), &cerr)
269
270 if cret == 0 {
271 return nil, cerr
272 }
273 cls = &gio.InputStream{}
274 cls.Ptr = cret
275 if cerr == nil {
276 return cls, nil
277 }
278 return cls, cerr
279
280}
281
282// Loads an icon asynchronously. To finish this function, see
283// g_loadable_icon_load_finish(). For the synchronous, blocking
284// version of this function, see g_loadable_icon_load().
285func (x *MemoryTexture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
286
287 gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
288
289}
290
291// Finishes an asynchronous icon load started in g_loadable_icon_load_async().
292func (x *MemoryTexture) LoadFinish(ResVar gio.AsyncResult, TypeVar *string) (*gio.InputStream, error) {
293 var cls *gio.InputStream
294 var cerr *glib.Error
295
296 cret := gio.XGLoadableIconLoadFinish(x.GoPointer(), ResVar.GoPointer(), TypeVar, &cerr)
297
298 if cret == 0 {
299 return nil, cerr
300 }
301 cls = &gio.InputStream{}
302 cls.Ptr = cret
303 if cerr == nil {
304 return cls, nil
305 }
306 return cls, cerr
307
308}
309
310func init() {
311 core.SetPackageName("GDK", "gtk4")
312 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
313 var libs []uintptr
314 for _, libPath := range core.GetPaths("GDK") {
315 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
316 if err != nil {
317 panic(err)
318 }
319 libs = append(libs, lib)
320 }
321
322 core.PuregoSafeRegister(&xMemoryTextureGLibType, libs, "gdk_memory_texture_get_type")
323
324 core.PuregoSafeRegister(&xNewMemoryTexture, libs, "gdk_memory_texture_new")
325
326}