EmeusConstraint

EmeusConstraint — The representation of a single constraint

Functions

Properties

gboolean active Read / Write
gdouble constant Read / Write / Construct Only
gdouble multiplier Read / Write / Construct Only
EmeusConstraintRelation relation Read / Write / Construct Only
EmeusConstraintAttribute source-attribute Read / Write / Construct Only
GtkWidget * source-object Read / Write / Construct Only
gint strength Read / Write / Construct Only
EmeusConstraintAttribute target-attribute Read / Write / Construct Only
GtkWidget * target-object Read / Write / Construct Only

Types and Values

Object Hierarchy

    GEnum
    ├── EmeusConstraintAttribute
    ├── EmeusConstraintRelation
    ╰── EmeusConstraintStrength
    GObject
    ╰── GInitiallyUnowned
        ╰── EmeusConstraint

Includes

#include <emeus.h>

Description

EmeusConstraint is a type that describes a constraint between two widget attributes which must be satisfied by a GtkConstraintLayout.

Each constraint is a linear equation in the form:

1
target.attribute1 = source.attribute2 × multiplier + constant

The EmeusConstraintLayout will take all the constraints associated to each of its children and solve the value of attribute1 that satisfy the system of equations.

For instance, if a EmeusConstraintLayout has two children, button1 and button2, and you wish for button2 to follow button1 with 8 pixels of spacing between the two, using the direction of the text, you can express this relationship as this constraint:

1
button2.start = button1.end × 1.0 + 8.0

If you also wish button1 to have a minimum width of 120 pixels, and button2 to have the same size, you can use the following constraints:

1
2
button1.width ≥ 120.0
button2.width = button1.width × 1.0 + 0.0

Each EmeusConstraint instance references a target attribute; the target object to which the attribute applies is a child of a EmeusConstraintLayout, and it's associated with the EmeusConstraint instance once the constraint is added to a child GtkWidget of the layout.

Functions

emeus_constraint_new ()

EmeusConstraint *
emeus_constraint_new (gpointer target_object,
                      EmeusConstraintAttribute target_attribute,
                      EmeusConstraintRelation relation,
                      gpointer source_object,
                      EmeusConstraintAttribute source_attribute,
                      double multiplier,
                      double constant,
                      int strength);

Creates a new constraint using a value from the source widget's attribute and applying it to the target widget's attribute.

[constructor]

Parameters

target_object

the target widget, or NULL for the parent layout.

[type Gtk.Widget][nullable]

target_attribute

the attribute to set on the target widget

 

relation

the relation between the target and source attributes

 

source_object

the source widget, or NULL for the parent layout.

[type Gtk.Widget][nullable]

source_attribute

the attribute to get from the source widget

 

multiplier

the multiplication coefficient to apply to the source attribute

 

constant

the constant to add to the source attribute

 

strength

the priority of the constraint

 

Returns

the newly created constraint.

[transfer full]

Since: 1.0


emeus_constraint_new_constant ()

EmeusConstraint *
emeus_constraint_new_constant (gpointer target_object,
                               EmeusConstraintAttribute target_attribute,
                               EmeusConstraintRelation relation,
                               double constant,
                               int strength);

Creates a new constant constraint.

This function is the equivalent of creating a new EmeusConstraint with:

[constructor]

Parameters

target_object

the target widget, or NULL for the parent layout.

[type Gtk.Widget][nullable]

target_attribute

the attribute to set on the target widget

 

relation

the relation between the target and the constant

 

constant

the constant value of the constraint

 

strength

the priority of the constraint

 

Returns

the newly created constraint.

[transfer full]

Since: 1.0


emeus_constraint_get_source_object ()

gpointer
emeus_constraint_get_source_object (EmeusConstraint *constraint);

Retrieves the source object of the constraint .

Parameters

constraint

a EmeusConstraint

 

Returns

the source object.

[transfer none][nullable][type Gtk.Widget]


emeus_constraint_get_source_attribute ()

EmeusConstraintAttribute
emeus_constraint_get_source_attribute (EmeusConstraint *constraint);

Retrieves the attribute of the source object bound by this constraint .

Parameters

constraint

a EmeusConstraint

 

Returns

a constraint attribute

Since: 1.0


emeus_constraint_get_relation ()

EmeusConstraintRelation
emeus_constraint_get_relation (EmeusConstraint *constraint);

Retrieves the relation between the target and source attributes.

Parameters

constraint

a EmeusConstraint

 

Returns

a constraint relation

Since: 1.0


emeus_constraint_get_target_object ()

gpointer
emeus_constraint_get_target_object (EmeusConstraint *constraint);

Retrieves the target object of the constraint.

This function may return NULL if the constraint is not attached to a EmeusConstraintLayout. Use emeus_constraint_is_attached() to before calling this function.

Parameters

constraint

a EmeusConstraint

 

Returns

the target object.

[transfer none][type Gtk.Widget][nullable]

Since: 1.0


emeus_constraint_get_target_attribute ()

EmeusConstraintAttribute
emeus_constraint_get_target_attribute (EmeusConstraint *constraint);

Retrieves the attribute of the target object bound by this constraint .

Parameters

constraint

a EmeusConstraint

 

Returns

a constraint attribute

Since: 1.0


emeus_constraint_get_multiplier ()

double
emeus_constraint_get_multiplier (EmeusConstraint *constraint);

Retrieves the multiplication factor of the constraint .

Parameters

constraint

a EmeusConstraint

 

Returns

a factor

Since: 1.0


emeus_constraint_get_constant ()

double
emeus_constraint_get_constant (EmeusConstraint *constraint);

Retrieves the additional constant of the constraint .

Parameters

constraint

a EmeusConstraint

 

Returns

a constant

Since: 1.0


emeus_constraint_get_strength ()

int
emeus_constraint_get_strength (EmeusConstraint *constraint);

Retrieves the strength of the constraint .

Parameters

constraint

a EmeusConstraint

 

Returns

a constraint strength

Since: 1.0


emeus_constraint_set_active ()

void
emeus_constraint_set_active (EmeusConstraint *constraint,
                             gboolean active);

Sets whether a constraint should be actively used by a EmeusConstraintLayout or not.

Parameters

constraint

a EmeusConstraint

 

active

whether the constraint should be active

 

Since: 1.0


emeus_constraint_get_active ()

gboolean
emeus_constraint_get_active (EmeusConstraint *constraint);

Checks whether a constraint is active.

Parameters

constraint

a EmeusConstraint

 

Returns

TRUE if the constraint is active

Since: 1.0


emeus_constraint_is_attached ()

gboolean
emeus_constraint_is_attached (EmeusConstraint *constraint);

Checks whether the constraint is attached to a child of a EmeusConstraintLayout.

Parameters

constraint

a EmeusConstraint

 

Returns

TRUE if the constraint is attached

Since: 1.0


emeus_constraint_is_required ()

gboolean
emeus_constraint_is_required (EmeusConstraint *constraint);

Checks whether a constraint is marked as required.

Parameters

constraint

a EmeusConstraint

 

Returns

TRUE if the constraint is required

Since: 1.0

Types and Values

EmeusConstraint

typedef struct _EmeusConstraint EmeusConstraint;

The representation of a constraint inside an EmeusConstraintLayout.

The contents of the EmeusConstraint structure are private and should never be accessed directly.

Since: 1.0


enum EmeusConstraintStrength

The possible strengths for a constraint.

The order is:

  weak < medium < strong < required

Members

EMEUS_CONSTRAINT_STRENGTH_REQUIRED

Requires constraint

 

EMEUS_CONSTRAINT_STRENGTH_WEAK

Weak constraint

 

EMEUS_CONSTRAINT_STRENGTH_MEDIUM

Medium constraint

 

EMEUS_CONSTRAINT_STRENGTH_STRONG

Strong constraint

 

Since: 1.0


enum EmeusConstraintRelation

The relation between the two terms of the constraint.

Members

EMEUS_CONSTRAINT_RELATION_LE

Less than, or equal

 

EMEUS_CONSTRAINT_RELATION_EQ

Equal

 

EMEUS_CONSTRAINT_RELATION_GE

Greater than, or equal

 

Since: 1.0


enum EmeusConstraintAttribute

The attributes that can be used to build a constraint.

Members

EMEUS_CONSTRAINT_ATTRIBUTE_INVALID

Used for constants

 

EMEUS_CONSTRAINT_ATTRIBUTE_LEFT

The left edge of a widget

 

EMEUS_CONSTRAINT_ATTRIBUTE_RIGHT

The right edge of a widget

 

EMEUS_CONSTRAINT_ATTRIBUTE_TOP

The top edge of a widget

 

EMEUS_CONSTRAINT_ATTRIBUTE_BOTTOM

The bottom edge of a widget

 

EMEUS_CONSTRAINT_ATTRIBUTE_START

The leading edge of a widget, depending on the text direction (left for LTR languages, right for RTL ones)

 

EMEUS_CONSTRAINT_ATTRIBUTE_END

The trailing edge of a widget, depending on the text direction (right for LTR languages, left for RTL ones)

 

EMEUS_CONSTRAINT_ATTRIBUTE_WIDTH

The width of a widget

 

EMEUS_CONSTRAINT_ATTRIBUTE_HEIGHT

The height of a widget

 

EMEUS_CONSTRAINT_ATTRIBUTE_CENTER_X

The center of a widget, on the horizontal axis

 

EMEUS_CONSTRAINT_ATTRIBUTE_CENTER_Y

The center of a widget, on the vertical axis

 

EMEUS_CONSTRAINT_ATTRIBUTE_BASELINE

The baseline of a widget

 

Since: 1.0

Property Details

The “active” property

  “active”                   gboolean

Whether a EmeusConstraint participates in the layout.

Flags: Read / Write

Default value: TRUE

Since: 1.0


The “constant” property

  “constant”                 gdouble

The constant factor to be applied to the value of the “source-attribute” in the constraint.

Flags: Read / Write / Construct Only

Default value: 0

Since: 1.0


The “multiplier” property

  “multiplier”               gdouble

The multiplication factor to be applied to the value of the “source-attribute” in the constraint.

Flags: Read / Write / Construct Only

Default value: 1

Since: 1.0


The “relation” property

  “relation”                 EmeusConstraintRelation

The relation between target and source attributes in the constraint.

Flags: Read / Write / Construct Only

Default value: EMEUS_CONSTRAINT_RELATION_EQ

Since: 1.0


The “source-attribute” property

  “source-attribute”         EmeusConstraintAttribute

The attribute on the “source-object” in the constraint.

Flags: Read / Write / Construct Only

Default value: EMEUS_CONSTRAINT_ATTRIBUTE_INVALID

Since: 1.0


The “source-object” property

  “source-object”            GtkWidget *

The source object in the constraint.

Flags: Read / Write / Construct Only

Since: 1.0


The “strength” property

  “strength”                 gint

The strength, or priority of the constraint.

You can use any positive integer for custom priorities, or use the values of the EmeusConstraintStrength enumeration for common strength values.

Flags: Read / Write / Construct Only

Default value: 0

Since: 1.0


The “target-attribute” property

  “target-attribute”         EmeusConstraintAttribute

The attribute on the “target-object” in the constraint.

Flags: Read / Write / Construct Only

Default value: EMEUS_CONSTRAINT_ATTRIBUTE_INVALID

Since: 1.0


The “target-object” property

  “target-object”            GtkWidget *

The target object in the constraint.

Flags: Read / Write / Construct Only

Since: 1.0