Package: gtk
Class gtk:constraint-layout
Superclassesgtk:layout-manager, gobject:object, common-lisp:standard-object, common-lisp:t Documented Subclasses
None
Direct Slots
None
Details The gtk:constraint-layout object is a layout manager that uses relations between widget attributes, expressed via gtk:constraint
instances, to measure and allocate widgets. How do constraints workBy taking multiple constraints and applying them to the children of a widget using the gtk:constraint-layout object, it is possible to describe complex layout policies. Each constraint applied to a child or to the parent widgets contributes to the full description of the layout, in terms of parameters for resolving the value of each attribute. It is important to note that a layout is defined by the totality of constraints. Removing a child, or a constraint, from an existing layout without changing the remaining constraints may result in an unstable or unsolvable layout. Constraints have an implicit "reading order". You should start describing each edge of each child, as well as their relationship with the parent container, from the top left (or top right, in RTL languages), horizontally first, and then vertically. A constraint-based layout with too few constraints can become "unstable", that is: have more than one solution. The behavior of an unstable layout is undefined. A constraint-based layout with conflicting constraints may be unsolvable, and lead to an unstable layout. You can use the strength property to "nudge" the layout towards a solution. GtkConstraintLayout as GtkBuildableAn example of a UI definition fragment specifying a constraint:
<object class="GtkConstraintLayout">
<constraints>
<constraint target="button" target-attribute="start"
relation="eq"
source="super" source-attribute="start"
constant="12"
strength="required" />
<constraint target="button" target-attribute="width"
relation="ge"
constant="250"
strength="strong" />
</constraints>
</object>
The definition above will add two constraints to the gtk:constraint-layout object:
Additionally, the "constraints" element can also contain a description of the gtk:constraint-guide object used by the layout: <constraints> <guide min-width="100" max-width="500" name="hspace"/> <guide min-height="64" nat-height="128" name="vspace" strength="strong"/> </constraints>The "guide" element has the following optional attributes:
| Returned byInherited Slot Access FunctionsSee also |
2024-04-23