GtkConstraint — The description of a constraint
double | constant | Read / Write / Construct Only |
double | multiplier | Read / Write / Construct Only |
GtkConstraintRelation | relation | Read / Write / Construct Only |
GtkConstraintTarget * | source | Read / Write / Construct Only |
GtkConstraintAttribute | source-attribute | Read / Write / Construct Only |
int | strength | Read / Write / Construct Only |
GtkConstraintTarget * | target | Read / Write / Construct Only |
GtkConstraintAttribute | target-attribute | Read / Write / Construct Only |
GInterface ╰── GtkConstraintTarget GObject ╰── GtkConstraint
GtkConstraintTarget requires GObject.
GtkConstraintTarget is implemented by GtkAboutDialog, GtkActionBar, GtkAppChooserButton, GtkAppChooserDialog, GtkAppChooserWidget, GtkApplicationWindow, GtkAspectFrame, GtkAssistant, GtkBox, GtkButton, GtkCalendar, GtkCellView, GtkCheckButton, GtkColorButton, GtkColorChooserDialog, GtkColorChooserWidget, GtkColumnView, GtkComboBox, GtkComboBoxText, GtkConstraintGuide, GtkDialog, GtkDragIcon, GtkDrawingArea, GtkDropDown, GtkEditableLabel, GtkEmojiChooser, GtkEntry, GtkExpander, GtkFileChooserDialog, GtkFileChooserWidget, GtkFixed, GtkFlowBox, GtkFlowBoxChild, GtkFontButton, GtkFontChooserDialog, GtkFontChooserWidget, GtkFrame, GtkGLArea, GtkGrid, GtkGridView, GtkHeaderBar, GtkIconView, GtkImage, GtkInfoBar, GtkLabel, GtkLevelBar, GtkLinkButton, GtkListBox, GtkListBoxRow, GtkListView, GtkLockButton, GtkMediaControls, GtkMenuButton, GtkMessageDialog, GtkNotebook, GtkOverlay, GtkPageSetupUnixDialog, GtkPaned, GtkPasswordEntry, GtkPicture, GtkPopover, GtkPopoverMenu, GtkPopoverMenuBar, GtkPrintUnixDialog, GtkProgressBar, GtkRange, GtkRevealer, GtkScale, GtkScaleButton, GtkScrollbar, GtkScrolledWindow, GtkSearchBar, GtkSearchEntry, GtkSeparator, GtkShortcutLabel, GtkShortcutsGroup, GtkShortcutsSection, GtkShortcutsShortcut, GtkShortcutsWindow, GtkSpinButton, GtkSpinner, GtkStack, GtkStackSidebar, GtkStackSwitcher, GtkStatusbar, GtkSwitch, GtkText, GtkTextView, GtkToggleButton, GtkTreeExpander, GtkTreeView, GtkVideo, GtkViewport, GtkVolumeButton, GtkWidget, GtkWindow, GtkWindowControls and GtkWindowHandle.
#include <gtk/gtk.h>
GtkConstraint describes a constraint between an attribute on a widget and another attribute on another widget, expressed as a linear equation like:
Each GtkConstraint is part of a system that will be solved by a GtkConstraintLayout in order to allocate and position each child widget.
The source and target widgets, as well as their attributes, of a GtkConstraint instance are immutable after creation.
GtkConstraint * gtk_constraint_new (gpointer target
,GtkConstraintAttribute target_attribute
,GtkConstraintRelation relation
,gpointer source
,GtkConstraintAttribute source_attribute
,double multiplier
,double constant
,int strength
);
Creates a new GtkConstraint representing a relation between a layout attribute on a source and a layout attribute on a target.
target | [nullable][type GtkConstraintTarget] | |
target_attribute | the attribute of | |
relation | the relation equivalence between | |
source | [nullable][type GtkConstraintTarget] | |
source_attribute | the attribute of | |
multiplier | a multiplication factor to be applied to | |
constant | a constant factor to be added to | |
strength | the strength of the constraint |
the newly created GtkConstraint
GtkConstraint * gtk_constraint_new_constant (gpointer target
,GtkConstraintAttribute target_attribute
,GtkConstraintRelation relation
,double constant
,int strength
);
Creates a new GtkConstraint representing a relation between a layout attribute on a target and a constant value.
target | [nullable][type GtkConstraintTarget] | |
target_attribute | the attribute of | |
relation | the relation equivalence between | |
constant | a constant factor to be set on | |
strength | the strength of the constraint |
the newly created GtkConstraint
GtkConstraintTarget *
gtk_constraint_get_target (GtkConstraint *constraint
);
Retrieves the GtkConstraintTarget used as the target for constraint
.
If the “target” property is set to NULL
, the constraint
will use the GtkConstraintLayout's widget.
constraint |
GtkConstraintAttribute
gtk_constraint_get_target_attribute (GtkConstraint *constraint
);
Retrieves the attribute of the target to be set by the constraint
.
constraint |
the target's attribute
GtkConstraintRelation
gtk_constraint_get_relation (GtkConstraint *constraint
);
The order relation between the terms of the constraint
.
constraint |
a GtkConstraintRelation value
GtkConstraintTarget *
gtk_constraint_get_source (GtkConstraint *constraint
);
Retrieves the GtkConstraintTarget used as the source for constraint
.
If the “source” property is set to NULL
, the constraint
will use the GtkConstraintLayout's widget.
constraint |
GtkConstraintAttribute
gtk_constraint_get_source_attribute (GtkConstraint *constraint
);
Retrieves the attribute of the source to be read by the constraint
.
constraint |
the target's attribute
double
gtk_constraint_get_multiplier (GtkConstraint *constraint
);
Retrieves the multiplication factor applied to the source attribute's value.
constraint |
a multiplication factor
double
gtk_constraint_get_constant (GtkConstraint *constraint
);
Retrieves the constant factor added to the source attributes' value.
constraint |
a constant factor
int
gtk_constraint_get_strength (GtkConstraint *constraint
);
Retrieves the strength of the constraint.
constraint |
the strength of the constraint
gboolean
gtk_constraint_is_required (GtkConstraint *constraint
);
Checks whether the constraint
is a required relation for solving the constraint layout.
constraint |
TRUE
if the constraint is required
gboolean
gtk_constraint_is_attached (GtkConstraint *constraint
);
Checks whether the constraint
is attached to a GtkConstraintLayout, and it is contributing to the layout.
constraint |
TRUE
if the constraint is attached
gboolean
gtk_constraint_is_constant (GtkConstraint *constraint
);
Checks whether the constraint
describes a relation between an attribute on the “target” and a constant value.
constraint |
TRUE
if the constraint is a constant relation
typedef struct _GtkConstraint GtkConstraint;
An object describing the relation between two widget attributes.
All relations are in the form:
target.attr1 = source.attr2 × multiplier + constant
A GtkConstraint is immutable once it's created.
typedef struct _GtkConstraintTarget GtkConstraintTarget;
The GtkConstraintTarget interface is implemented by objects that can be used as source or target in GtkConstraints. Besides GtkWidget, it is also implemented by GtkConstraintGuide.
The widget attributes that can be used when creating a GtkConstraint.
GTK_CONSTRAINT_ATTRIBUTE_NONE | No attribute, used for constant relations | |
GTK_CONSTRAINT_ATTRIBUTE_LEFT | The left edge of a widget, regardless of text direction | |
GTK_CONSTRAINT_ATTRIBUTE_RIGHT | The right edge of a widget, regardless of text direction | |
GTK_CONSTRAINT_ATTRIBUTE_TOP | The top edge of a widget | |
GTK_CONSTRAINT_ATTRIBUTE_BOTTOM | The bottom edge of a widget | |
GTK_CONSTRAINT_ATTRIBUTE_START | The leading edge of a widget, depending on text direction; equivalent to | |
GTK_CONSTRAINT_ATTRIBUTE_END | The trailing edge of a widget, depending on text direction; equivalent to | |
GTK_CONSTRAINT_ATTRIBUTE_WIDTH | The width of a widget | |
GTK_CONSTRAINT_ATTRIBUTE_HEIGHT | The height of a widget | |
GTK_CONSTRAINT_ATTRIBUTE_CENTER_X | The center of a widget, on the horizontal axis | |
GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y | The center of a widget, on the vertical axis | |
GTK_CONSTRAINT_ATTRIBUTE_BASELINE | The baseline of a widget |
The relation between two terms of a constraint.
GTK_CONSTRAINT_RELATION_LE | Less than, or equal | |
GTK_CONSTRAINT_RELATION_EQ | Equal | |
GTK_CONSTRAINT_RELATION_GE | Greater than, or equal |
The strength of a constraint, expressed as a symbolic constant.
The strength of a GtkConstraint can be expressed with any positive integer; the values of this enumeration can be used for readability.
GTK_CONSTRAINT_STRENGTH_REQUIRED | The constraint is required towards solving the layout | |
GTK_CONSTRAINT_STRENGTH_STRONG | A strong constraint | |
GTK_CONSTRAINT_STRENGTH_MEDIUM | A medium constraint | |
GTK_CONSTRAINT_STRENGTH_WEAK | A weak constraint |
“constant”
property“constant” double
The constant value to be added to the “source-attribute”.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: 0
“multiplier”
property“multiplier” double
The multiplication factor to be applied to the “source-attribute”.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: 1
“relation”
property“relation” GtkConstraintRelation
The order relation between the terms of the constraint.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: GTK_CONSTRAINT_RELATION_EQ
“source”
property“source” GtkConstraintTarget *
The source of the constraint.
The constraint will set the “target-attribute” of the target using the “source-attribute” of the source.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
“source-attribute”
property“source-attribute” GtkConstraintAttribute
The attribute of the “source” read by the constraint.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: GTK_CONSTRAINT_ATTRIBUTE_NONE
“strength”
property“strength” int
The strength of the constraint.
The strength can be expressed either using one of the symbolic values of the GtkConstraintStrength enumeration, or any positive integer value.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Allowed values: [0,1001001000]
Default value: 1001001000
“target”
property“target” GtkConstraintTarget *
The target of the constraint.
The constraint will set the “target-attribute” of the target using the “source-attribute” of the source widget.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
“target-attribute”
property“target-attribute” GtkConstraintAttribute
The attribute of the “target” set by the constraint.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: GTK_CONSTRAINT_ATTRIBUTE_NONE
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkConstraint.html