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/gio"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type ConstraintLayoutChildClass struct {
17 _ structs.HostLayout
18
19 ParentClass LayoutChildClass
20}
21
22func (x *ConstraintLayoutChildClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26type ConstraintLayoutClass struct {
27 _ structs.HostLayout
28
29 ParentClass LayoutManagerClass
30}
31
32func (x *ConstraintLayoutClass) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36var xConstraintVflParserErrorQuark func() glib.Quark
37
38// Registers an error quark for VFL error parsing.
39func ConstraintVflParserErrorQuark() glib.Quark {
40
41 cret := xConstraintVflParserErrorQuark()
42 return cret
43}
44
45// Uses constraints to describe relations between widgets.
46//
47// `GtkConstraintLayout` is a layout manager that uses relations between
48// widget attributes, expressed via [class@Gtk.Constraint] instances, to
49// measure and allocate widgets.
50//
51// ### How do constraints work
52//
53// Constraints are objects defining the relationship between attributes
54// of a widget; you can read the description of the [class@Gtk.Constraint]
55// class to have a more in depth definition.
56//
57// By taking multiple constraints and applying them to the children of
58// a widget using `GtkConstraintLayout`, it's possible to describe
59// complex layout policies; each constraint applied to a child or to the parent
60// widgets contributes to the full description of the layout, in terms of
61// parameters for resolving the value of each attribute.
62//
63// It is important to note that a layout is defined by the totality of
64// constraints; removing a child, or a constraint, from an existing layout
65// without changing the remaining constraints may result in an unstable
66// or unsolvable layout.
67//
68// Constraints have an implicit "reading order"; you should start describing
69// each edge of each child, as well as their relationship with the parent
70// container, from the top left (or top right, in RTL languages), horizontally
71// first, and then vertically.
72//
73// A constraint-based layout with too few constraints can become "unstable",
74// that is: have more than one solution. The behavior of an unstable layout
75// is undefined.
76//
77// A constraint-based layout with conflicting constraints may be unsolvable,
78// and lead to an unstable layout. You can use the [property@Gtk.Constraint:strength]
79// property of [class@Gtk.Constraint] to "nudge" the layout towards a solution.
80//
81// ### GtkConstraintLayout as GtkBuildable
82//
83// `GtkConstraintLayout` implements the [iface@Gtk.Buildable] interface and
84// has a custom "constraints" element which allows describing constraints in
85// a [class@Gtk.Builder] UI file.
86//
87// An example of a UI definition fragment specifying a constraint:
88//
89// ```xml
90//
91// <object class="GtkConstraintLayout">
92// <constraints>
93// <constraint target="button" target-attribute="start"
94// relation="eq"
95// source="super" source-attribute="start"
96// constant="12"
97// strength="required" />
98// <constraint target="button" target-attribute="width"
99// relation="ge"
100// constant="250"
101// strength="strong" />
102// </constraints>
103// </object>
104//
105// ```
106//
107// The definition above will add two constraints to the GtkConstraintLayout:
108//
109// - a required constraint between the leading edge of "button" and
110// the leading edge of the widget using the constraint layout, plus
111// 12 pixels
112// - a strong, constant constraint making the width of "button" greater
113// than, or equal to 250 pixels
114//
115// The "target" and "target-attribute" attributes are required.
116//
117// The "source" and "source-attribute" attributes of the "constraint"
118// element are optional; if they are not specified, the constraint is
119// assumed to be a constant.
120//
121// The "relation" attribute is optional; if not specified, the constraint
122// is assumed to be an equality.
123//
124// The "strength" attribute is optional; if not specified, the constraint
125// is assumed to be required.
126//
127// The "source" and "target" attributes can be set to "super" to indicate
128// that the constraint target is the widget using the GtkConstraintLayout.
129//
130// There can be "constant" and "multiplier" attributes.
131//
132// Additionally, the "constraints" element can also contain a description
133// of the `GtkConstraintGuides` used by the layout:
134//
135// ```xml
136//
137// <constraints>
138// <guide min-width="100" max-width="500" name="hspace"/>
139// <guide min-height="64" nat-height="128" name="vspace" strength="strong"/>
140// </constraints>
141//
142// ```
143//
144// The "guide" element has the following optional attributes:
145//
146// - "min-width", "nat-width", and "max-width", describe the minimum,
147// natural, and maximum width of the guide, respectively
148// - "min-height", "nat-height", and "max-height", describe the minimum,
149// natural, and maximum height of the guide, respectively
150// - "strength" describes the strength of the constraint on the natural
151// size of the guide; if not specified, the constraint is assumed to
152// have a medium strength
153// - "name" describes a name for the guide, useful when debugging
154//
155// ### Using the Visual Format Language
156//
157// Complex constraints can be described using a compact syntax called VFL,
158// or *Visual Format Language*.
159//
160// The Visual Format Language describes all the constraints on a row or
161// column, typically starting from the leading edge towards the trailing
162// one. Each element of the layout is composed by "views", which identify
163// a [iface@Gtk.ConstraintTarget].
164//
165// For instance:
166//
167// ```
168//
169// [button]-[textField]
170//
171// ```
172//
173// Describes a constraint that binds the trailing edge of "button" to the
174// leading edge of "textField", leaving a default space between the two.
175//
176// Using VFL is also possible to specify predicates that describe constraints
177// on attributes like width and height:
178//
179// ```
180//
181// // Width must be greater than, or equal to 50
182// [button(>=50)]
183//
184// // Width of button1 must be equal to width of button2
185// [button1(==button2)]
186//
187// ```
188//
189// The default orientation for a VFL description is horizontal, unless
190// otherwise specified:
191//
192// ```
193//
194// // horizontal orientation, default attribute: width
195// H:[button(>=150)]
196//
197// // vertical orientation, default attribute: height
198// V:[button1(==button2)]
199//
200// ```
201//
202// It's also possible to specify multiple predicates, as well as their
203// strength:
204//
205// ```
206//
207// // minimum width of button must be 150
208// // natural width of button can be 250
209// [button(>=150@required, ==250@medium)]
210//
211// ```
212//
213// Finally, it's also possible to use simple arithmetic operators:
214//
215// ```
216//
217// // width of button1 must be equal to width of button2
218// // divided by 2 plus 12
219// [button1(button2 / 2 + 12)]
220//
221// ```
222type ConstraintLayout struct {
223 LayoutManager
224}
225
226var xConstraintLayoutGLibType func() types.GType
227
228func ConstraintLayoutGLibType() types.GType {
229 return xConstraintLayoutGLibType()
230}
231
232func ConstraintLayoutNewFromInternalPtr(ptr uintptr) *ConstraintLayout {
233 cls := &ConstraintLayout{}
234 cls.Ptr = ptr
235 return cls
236}
237
238var xNewConstraintLayout func() uintptr
239
240// Creates a new `GtkConstraintLayout` layout manager.
241func NewConstraintLayout() *ConstraintLayout {
242 var cls *ConstraintLayout
243
244 cret := xNewConstraintLayout()
245
246 if cret == 0 {
247 return nil
248 }
249 cls = &ConstraintLayout{}
250 cls.Ptr = cret
251 return cls
252}
253
254var xConstraintLayoutAddConstraint func(uintptr, uintptr)
255
256// Adds a constraint to the layout manager.
257//
258// The [property@Gtk.Constraint:source] and [property@Gtk.Constraint:target]
259// properties of `constraint` can be:
260//
261// - set to `NULL` to indicate that the constraint refers to the
262// widget using `layout`
263// - set to the [class@Gtk.Widget] using `layout`
264// - set to a child of the [class@Gtk.Widget] using `layout`
265// - set to a [class@Gtk.ConstraintGuide] that is part of `layout`
266//
267// The @layout acquires the ownership of @constraint after calling
268// this function.
269func (x *ConstraintLayout) AddConstraint(ConstraintVar *Constraint) {
270
271 xConstraintLayoutAddConstraint(x.GoPointer(), ConstraintVar.GoPointer())
272
273}
274
275var xConstraintLayoutAddConstraintsFromDescription func(uintptr, []string, uint, int, int, **glib.Error, string, ...interface{}) *glib.List
276
277// Creates a list of constraints from a VFL description.
278//
279// This function is a convenience wrapper around
280// [method@Gtk.ConstraintLayout.add_constraints_from_descriptionv], using
281// variadic arguments to populate the view/target map.
282func (x *ConstraintLayout) AddConstraintsFromDescription(LinesVar []string, NLinesVar uint, HspacingVar int, VspacingVar int, ErrorVar **glib.Error, FirstViewVar string, varArgs ...interface{}) *glib.List {
283
284 cret := xConstraintLayoutAddConstraintsFromDescription(x.GoPointer(), LinesVar, NLinesVar, HspacingVar, VspacingVar, ErrorVar, FirstViewVar, varArgs...)
285 return cret
286}
287
288var xConstraintLayoutAddConstraintsFromDescriptionv func(uintptr, []string, uint, int, int, *glib.HashTable, **glib.Error) *glib.List
289
290// Creates a list of constraints from a VFL description.
291//
292// The Visual Format Language, VFL, is based on Apple's AutoLayout [VFL](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html).
293//
294// The `views` dictionary is used to match [iface@Gtk.ConstraintTarget]
295// instances to the symbolic view name inside the VFL.
296//
297// The VFL grammar is:
298//
299// ```
300//
301// <visualFormatString> = (<orientation>)?
302// (<superview><connection>)?
303// <view>(<connection><view>)*
304// (<connection><superview>)?
305// <orientation> = 'H' | 'V'
306// <superview> = '|'
307// <connection> = '' | '-' <predicateList> '-' | '-'
308// <predicateList> = <simplePredicate> | <predicateListWithParens>
309// <simplePredicate> = <metricName> | <positiveNumber>
310// <predicateListWithParens> = '(' <predicate> (',' <predicate>)* ')'
311// <predicate> = (<relation>)? <objectOfPredicate> (<operatorList>)? ('@' <priority>)?
312// <relation> = '==' | '<=' | '>='
313// <objectOfPredicate> = <constant> | <viewName> | ('.' <attributeName>)?
314// <priority> = <positiveNumber> | 'required' | 'strong' | 'medium' | 'weak'
315// <constant> = <number>
316// <operatorList> = (<multiplyOperator>)? (<addOperator>)?
317// <multiplyOperator> = [ '*' | '/' ] <positiveNumber>
318// <addOperator> = [ '+' | '-' ] <positiveNumber>
319// <viewName> = [A-Za-z_]([A-Za-z0-9_]*) // A C identifier
320// <metricName> = [A-Za-z_]([A-Za-z0-9_]*) // A C identifier
321// <attributeName> = 'top' | 'bottom' | 'left' | 'right' | 'width' | 'height' |
322// 'start' | 'end' | 'centerX' | 'centerY' | 'baseline'
323// <positiveNumber> // A positive real number parseable by g_ascii_strtod()
324// <number> // A real number parseable by g_ascii_strtod()
325//
326// ```
327//
328// **Note**: The VFL grammar used by GTK is slightly different than the one
329// defined by Apple, as it can use symbolic values for the constraint's
330// strength instead of numeric values; additionally, GTK allows adding
331// simple arithmetic operations inside predicates.
332//
333// Examples of VFL descriptions are:
334//
335// ```
336//
337// // Default spacing
338// [button]-[textField]
339//
340// // Width constraint
341// [button(>=50)]
342//
343// // Connection to super view
344// |-50-[purpleBox]-50-|
345//
346// // Vertical layout
347// V:[topField]-10-[bottomField]
348//
349// // Flush views
350// [maroonView][blueView]
351//
352// // Priority
353// [button(100@strong)]
354//
355// // Equal widths
356// [button1(==button2)]
357//
358// // Multiple predicates
359// [flexibleButton(>=70,<=100)]
360//
361// // A complete line of layout
362// |-[find]-[findNext]-[findField(>=20)]-|
363//
364// // Operators
365// [button1(button2 / 3 + 50)]
366//
367// // Named attributes
368// [button1(==button2.height)]
369//
370// ```
371func (x *ConstraintLayout) AddConstraintsFromDescriptionv(LinesVar []string, NLinesVar uint, HspacingVar int, VspacingVar int, ViewsVar *glib.HashTable) (*glib.List, error) {
372 var cerr *glib.Error
373
374 cret := xConstraintLayoutAddConstraintsFromDescriptionv(x.GoPointer(), LinesVar, NLinesVar, HspacingVar, VspacingVar, ViewsVar, &cerr)
375 if cerr == nil {
376 return cret, nil
377 }
378 return cret, cerr
379
380}
381
382var xConstraintLayoutAddGuide func(uintptr, uintptr)
383
384// Adds a guide to `layout`.
385//
386// A guide can be used as the source or target of constraints,
387// like a widget, but it is not visible.
388//
389// The `layout` acquires the ownership of `guide` after calling
390// this function.
391func (x *ConstraintLayout) AddGuide(GuideVar *ConstraintGuide) {
392
393 xConstraintLayoutAddGuide(x.GoPointer(), GuideVar.GoPointer())
394
395}
396
397var xConstraintLayoutObserveConstraints func(uintptr) uintptr
398
399// Returns a `GListModel` to track the constraints that are
400// part of the layout.
401//
402// Calling this function will enable extra internal bookkeeping
403// to track constraints and emit signals on the returned listmodel.
404// It may slow down operations a lot.
405//
406// Applications should try hard to avoid calling this function
407// because of the slowdowns.
408func (x *ConstraintLayout) ObserveConstraints() *gio.ListModelBase {
409 var cls *gio.ListModelBase
410
411 cret := xConstraintLayoutObserveConstraints(x.GoPointer())
412
413 if cret == 0 {
414 return nil
415 }
416 cls = &gio.ListModelBase{}
417 cls.Ptr = cret
418 return cls
419}
420
421var xConstraintLayoutObserveGuides func(uintptr) uintptr
422
423// Returns a `GListModel` to track the guides that are
424// part of the layout.
425//
426// Calling this function will enable extra internal bookkeeping
427// to track guides and emit signals on the returned listmodel.
428// It may slow down operations a lot.
429//
430// Applications should try hard to avoid calling this function
431// because of the slowdowns.
432func (x *ConstraintLayout) ObserveGuides() *gio.ListModelBase {
433 var cls *gio.ListModelBase
434
435 cret := xConstraintLayoutObserveGuides(x.GoPointer())
436
437 if cret == 0 {
438 return nil
439 }
440 cls = &gio.ListModelBase{}
441 cls.Ptr = cret
442 return cls
443}
444
445var xConstraintLayoutRemoveAllConstraints func(uintptr)
446
447// Removes all constraints from the layout manager.
448func (x *ConstraintLayout) RemoveAllConstraints() {
449
450 xConstraintLayoutRemoveAllConstraints(x.GoPointer())
451
452}
453
454var xConstraintLayoutRemoveConstraint func(uintptr, uintptr)
455
456// Removes `constraint` from the layout manager,
457// so that it no longer influences the layout.
458func (x *ConstraintLayout) RemoveConstraint(ConstraintVar *Constraint) {
459
460 xConstraintLayoutRemoveConstraint(x.GoPointer(), ConstraintVar.GoPointer())
461
462}
463
464var xConstraintLayoutRemoveGuide func(uintptr, uintptr)
465
466// Removes `guide` from the layout manager,
467// so that it no longer influences the layout.
468func (x *ConstraintLayout) RemoveGuide(GuideVar *ConstraintGuide) {
469
470 xConstraintLayoutRemoveGuide(x.GoPointer(), GuideVar.GoPointer())
471
472}
473
474func (c *ConstraintLayout) GoPointer() uintptr {
475 if c == nil {
476 return 0
477 }
478 return c.Ptr
479}
480
481func (c *ConstraintLayout) SetGoPointer(ptr uintptr) {
482 c.Ptr = ptr
483}
484
485// Gets the ID of the @buildable object.
486//
487// `GtkBuilder` sets the name based on the ID attribute
488// of the `<object>` tag used to construct the @buildable.
489func (x *ConstraintLayout) GetBuildableId() string {
490
491 cret := XGtkBuildableGetBuildableId(x.GoPointer())
492 return cret
493}
494
495// `GtkLayoutChild` subclass for children in a `GtkConstraintLayout`.
496type ConstraintLayoutChild struct {
497 LayoutChild
498}
499
500var xConstraintLayoutChildGLibType func() types.GType
501
502func ConstraintLayoutChildGLibType() types.GType {
503 return xConstraintLayoutChildGLibType()
504}
505
506func ConstraintLayoutChildNewFromInternalPtr(ptr uintptr) *ConstraintLayoutChild {
507 cls := &ConstraintLayoutChild{}
508 cls.Ptr = ptr
509 return cls
510}
511
512func (c *ConstraintLayoutChild) GoPointer() uintptr {
513 if c == nil {
514 return 0
515 }
516 return c.Ptr
517}
518
519func (c *ConstraintLayoutChild) SetGoPointer(ptr uintptr) {
520 c.Ptr = ptr
521}
522
523func init() {
524 core.SetPackageName("GTK", "gtk4")
525 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
526 var libs []uintptr
527 for _, libPath := range core.GetPaths("GTK") {
528 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
529 if err != nil {
530 panic(err)
531 }
532 libs = append(libs, lib)
533 }
534
535 core.PuregoSafeRegister(&xConstraintVflParserErrorQuark, libs, "gtk_constraint_vfl_parser_error_quark")
536
537 core.PuregoSafeRegister(&xConstraintLayoutGLibType, libs, "gtk_constraint_layout_get_type")
538
539 core.PuregoSafeRegister(&xNewConstraintLayout, libs, "gtk_constraint_layout_new")
540
541 core.PuregoSafeRegister(&xConstraintLayoutAddConstraint, libs, "gtk_constraint_layout_add_constraint")
542 core.PuregoSafeRegister(&xConstraintLayoutAddConstraintsFromDescription, libs, "gtk_constraint_layout_add_constraints_from_description")
543 core.PuregoSafeRegister(&xConstraintLayoutAddConstraintsFromDescriptionv, libs, "gtk_constraint_layout_add_constraints_from_descriptionv")
544 core.PuregoSafeRegister(&xConstraintLayoutAddGuide, libs, "gtk_constraint_layout_add_guide")
545 core.PuregoSafeRegister(&xConstraintLayoutObserveConstraints, libs, "gtk_constraint_layout_observe_constraints")
546 core.PuregoSafeRegister(&xConstraintLayoutObserveGuides, libs, "gtk_constraint_layout_observe_guides")
547 core.PuregoSafeRegister(&xConstraintLayoutRemoveAllConstraints, libs, "gtk_constraint_layout_remove_all_constraints")
548 core.PuregoSafeRegister(&xConstraintLayoutRemoveConstraint, libs, "gtk_constraint_layout_remove_constraint")
549 core.PuregoSafeRegister(&xConstraintLayoutRemoveGuide, libs, "gtk_constraint_layout_remove_guide")
550
551 core.PuregoSafeRegister(&xConstraintLayoutChildGLibType, libs, "gtk_constraint_layout_child_get_type")
552
553}