GtkConstraint

GtkConstraint — The description of a constraint

Properties

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

Object Hierarchy

    GInterface
    ╰── GtkConstraintTarget
    GObject
    ╰── GtkConstraint

Prerequisites

GtkConstraintTarget requires GObject.

Known Implementations

GtkConstraintTarget is implemented by GtkAboutDialog, GtkActionBar, GtkAppChooserButton, GtkAppChooserDialog, GtkAppChooserWidget, GtkApplicationWindow, GtkAspectFrame, GtkAssistant, GtkBox, GtkButton, GtkCalendar, GtkCellView, GtkCenterBox, 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.

Includes

#include <gtk/gtk.h>

Description

GtkConstraint describes a constraint between an attribute on a widget and another attribute on another widget, expressed as a linear equation like:

1
target.attr1 = source.attr2 × multiplier + constant

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.

Functions

gtk_constraint_new ()

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.

Parameters

target

a GtkConstraintTarget.

[nullable][type GtkConstraintTarget]

target_attribute

the attribute of target to be set

 

relation

the relation equivalence between target_attribute and source_attribute

 

source

a GtkConstraintTarget.

[nullable][type GtkConstraintTarget]

source_attribute

the attribute of source to be read

 

multiplier

a multiplication factor to be applied to source_attribute

 

constant

a constant factor to be added to source_attribute

 

strength

the strength of the constraint

 

Returns

the newly created GtkConstraint


gtk_constraint_new_constant ()

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.

Parameters

target

a GtkConstraintTarget.

[nullable][type GtkConstraintTarget]

target_attribute

the attribute of target to be set

 

relation

the relation equivalence between target_attribute and constant

 

constant

a constant factor to be set on target_attribute

 

strength

the strength of the constraint

 

Returns

the newly created GtkConstraint


gtk_constraint_get_target ()

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.

Parameters

constraint

a GtkConstraint

 

Returns

a GtkConstraintTarget.

[transfer none][nullable]


gtk_constraint_get_target_attribute ()

GtkConstraintAttribute
gtk_constraint_get_target_attribute (GtkConstraint *constraint);

Retrieves the attribute of the target to be set by the constraint .

Parameters

constraint

a GtkConstraint

 

Returns

the target's attribute


gtk_constraint_get_relation ()

GtkConstraintRelation
gtk_constraint_get_relation (GtkConstraint *constraint);

The order relation between the terms of the constraint .

Parameters

constraint

a GtkConstraint

 

Returns

a GtkConstraintRelation value


gtk_constraint_get_source ()

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.

Parameters

constraint

a GtkConstraint

 

Returns

a GtkConstraintTarget.

[transfer none][nullable]


gtk_constraint_get_source_attribute ()

GtkConstraintAttribute
gtk_constraint_get_source_attribute (GtkConstraint *constraint);

Retrieves the attribute of the source to be read by the constraint .

Parameters

constraint

a GtkConstraint

 

Returns

the target's attribute


gtk_constraint_get_multiplier ()

double
gtk_constraint_get_multiplier (GtkConstraint *constraint);

Retrieves the multiplication factor applied to the source attribute's value.

Parameters

constraint

a GtkConstraint

 

Returns

a multiplication factor


gtk_constraint_get_constant ()

double
gtk_constraint_get_constant (GtkConstraint *constraint);

Retrieves the constant factor added to the source attributes' value.

Parameters

constraint

a GtkConstraint

 

Returns

a constant factor


gtk_constraint_get_strength ()

int
gtk_constraint_get_strength (GtkConstraint *constraint);

Retrieves the strength of the constraint.

Parameters

constraint

a GtkConstraint

 

Returns

the strength of the constraint


gtk_constraint_is_required ()

gboolean
gtk_constraint_is_required (GtkConstraint *constraint);

Checks whether the constraint is a required relation for solving the constraint layout.

Parameters

constraint

a GtkConstraint

 

Returns

TRUE if the constraint is required


gtk_constraint_is_attached ()

gboolean
gtk_constraint_is_attached (GtkConstraint *constraint);

Checks whether the constraint is attached to a GtkConstraintLayout, and it is contributing to the layout.

Parameters

constraint

a GtkConstraint

 

Returns

TRUE if the constraint is attached


gtk_constraint_is_constant ()

gboolean
gtk_constraint_is_constant (GtkConstraint *constraint);

Checks whether the constraint describes a relation between an attribute on the “target” and a constant value.

Parameters

constraint

a GtkConstraint

 

Returns

TRUE if the constraint is a constant relation

Types and Values

GtkConstraint

typedef struct _GtkConstraint GtkConstraint;

An object describing the relation between two widget attributes.

All relations are in the form:

1
target.attr_name = source.attr_name × multiplier + constant

A GtkConstraint is immutable once it's created.


GtkConstraintTarget

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.


enum GtkConstraintAttribute

The widget attributes that can be used when creating a GtkConstraint.

Members

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_LEFT for LTR languages, and GTK_CONSTRAINT_ATTRIBUTE_RIGHT for RTL ones

 

GTK_CONSTRAINT_ATTRIBUTE_END

The trailing edge of a widget, depending on text direction; equivalent to GTK_CONSTRAINT_ATTRIBUTE_RIGHT for LTR languages, and GTK_CONSTRAINT_ATTRIBUTE_LEFT for RTL ones

 

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

 

enum GtkConstraintRelation

The relation between two terms of a constraint.

Members

GTK_CONSTRAINT_RELATION_LE

Less than, or equal

 

GTK_CONSTRAINT_RELATION_EQ

Equal

 

GTK_CONSTRAINT_RELATION_GE

Greater than, or equal

 

enum GtkConstraintStrength

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.

Members

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

 

Property Details

The “constant” property

  “constant”                 double

The constant value to be added to the “source-attribute”.

Owner: GtkConstraint

Flags: Read / Write / Construct Only

Default value: 0


The “multiplier” property

  “multiplier”               double

The multiplication factor to be applied to the “source-attribute”.

Owner: GtkConstraint

Flags: Read / Write / Construct Only

Default value: 1


The “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


The “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


The “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


The “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


The “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


The “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