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/gobject/types"
12)
13
14// Represents a color, in a way that is compatible with cairo’s notion of color.
15//
16// `GdkRGBA` is a convenient way to pass colors around. It’s based on
17// cairo’s way to deal with colors and mirrors its behavior. All values
18// are in the range from 0.0 to 1.0 inclusive. So the color
19// (0.0, 0.0, 0.0, 0.0) represents transparent black and
20// (1.0, 1.0, 1.0, 1.0) is opaque white. Other values will
21// be clamped to this range when drawing.
22type RGBA struct {
23 _ structs.HostLayout
24
25 Red float32
26
27 Green float32
28
29 Blue float32
30
31 Alpha float32
32}
33
34var xRGBAGLibType func() types.GType
35
36func RGBAGLibType() types.GType {
37 return xRGBAGLibType()
38}
39
40func (x *RGBA) GoPointer() uintptr {
41 return uintptr(unsafe.Pointer(x))
42}
43
44var xRGBACopy func(uintptr) *RGBA
45
46// Makes a copy of a `GdkRGBA`.
47//
48// The result must be freed through [method@Gdk.RGBA.free].
49func (x *RGBA) Copy() *RGBA {
50
51 cret := xRGBACopy(x.GoPointer())
52 return cret
53}
54
55var xRGBAEqual func(uintptr, uintptr) bool
56
57// Compares two `GdkRGBA` colors.
58func (x *RGBA) Equal(P2Var uintptr) bool {
59
60 cret := xRGBAEqual(x.GoPointer(), P2Var)
61 return cret
62}
63
64var xRGBAFree func(uintptr)
65
66// Frees a `GdkRGBA`.
67func (x *RGBA) Free() {
68
69 xRGBAFree(x.GoPointer())
70
71}
72
73var xRGBAHash func(uintptr) uint
74
75// A hash function suitable for using for a hash
76// table that stores `GdkRGBA`s.
77func (x *RGBA) Hash() uint {
78
79 cret := xRGBAHash(x.GoPointer())
80 return cret
81}
82
83var xRGBAIsClear func(uintptr) bool
84
85// Checks if an @rgba value is transparent.
86//
87// That is, drawing with the value would not produce any change.
88func (x *RGBA) IsClear() bool {
89
90 cret := xRGBAIsClear(x.GoPointer())
91 return cret
92}
93
94var xRGBAIsOpaque func(uintptr) bool
95
96// Checks if an @rgba value is opaque.
97//
98// That is, drawing with the value will not retain any results
99// from previous contents.
100func (x *RGBA) IsOpaque() bool {
101
102 cret := xRGBAIsOpaque(x.GoPointer())
103 return cret
104}
105
106var xRGBAParse func(uintptr, string) bool
107
108// Parses a textual representation of a color.
109//
110// The string can be either one of:
111//
112// - A standard name (Taken from the CSS specification).
113// - A hexadecimal value in the form “\#rgb”, “\#rrggbb”,
114// “\#rrrgggbbb” or ”\#rrrrggggbbbb”
115// - A hexadecimal value in the form “\#rgba”, “\#rrggbbaa”,
116// or ”\#rrrrggggbbbbaaaa”
117// - A RGB color in the form “rgb(r,g,b)” (In this case the color
118// will have full opacity)
119// - A RGBA color in the form “rgba(r,g,b,a)”
120// - A HSL color in the form "hsl(hue, saturation, lightness)"
121// - A HSLA color in the form "hsla(hue, saturation, lightness, alpha)"
122//
123// Where “r”, “g”, “b” and “a” are respectively the red, green,
124// blue and alpha color values. In the last two cases, “r”, “g”,
125// and “b” are either integers in the range 0 to 255 or percentage
126// values in the range 0% to 100%, and a is a floating point value
127// in the range 0 to 1.
128func (x *RGBA) Parse(SpecVar string) bool {
129
130 cret := xRGBAParse(x.GoPointer(), SpecVar)
131 return cret
132}
133
134var xRGBAToString func(uintptr) string
135
136// Returns a textual specification of @rgba in the form
137// `rgb(r,g,b)` or `rgba(r,g,b,a)`, where “r”, “g”, “b” and
138// “a” represent the red, green, blue and alpha values
139// respectively. “r”, “g”, and “b” are represented as integers
140// in the range 0 to 255, and “a” is represented as a floating
141// point value in the range 0 to 1.
142//
143// These string forms are string forms that are supported by
144// the CSS3 colors module, and can be parsed by [method@Gdk.RGBA.parse].
145//
146// Note that this string representation may lose some precision,
147// since “r”, “g” and “b” are represented as 8-bit integers. If
148// this is a concern, you should use a different representation.
149func (x *RGBA) ToString() string {
150
151 cret := xRGBAToString(x.GoPointer())
152 return cret
153}
154
155func init() {
156 core.SetPackageName("GDK", "gtk4")
157 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
158 var libs []uintptr
159 for _, libPath := range core.GetPaths("GDK") {
160 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
161 if err != nil {
162 panic(err)
163 }
164 libs = append(libs, lib)
165 }
166
167 core.PuregoSafeRegister(&xRGBAGLibType, libs, "gdk_rgba_get_type")
168
169 core.PuregoSafeRegister(&xRGBACopy, libs, "gdk_rgba_copy")
170 core.PuregoSafeRegister(&xRGBAEqual, libs, "gdk_rgba_equal")
171 core.PuregoSafeRegister(&xRGBAFree, libs, "gdk_rgba_free")
172 core.PuregoSafeRegister(&xRGBAHash, libs, "gdk_rgba_hash")
173 core.PuregoSafeRegister(&xRGBAIsClear, libs, "gdk_rgba_is_clear")
174 core.PuregoSafeRegister(&xRGBAIsOpaque, libs, "gdk_rgba_is_opaque")
175 core.PuregoSafeRegister(&xRGBAParse, libs, "gdk_rgba_parse")
176 core.PuregoSafeRegister(&xRGBAToString, libs, "gdk_rgba_to_string")
177
178}