Top |
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 |
GEnum ├── EmeusConstraintAttribute ├── EmeusConstraintRelation ╰── EmeusConstraintStrength GObject ╰── GInitiallyUnowned ╰── EmeusConstraint
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.
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]
target_object |
the target widget, or
|
[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
|
[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 |
Since: 1.0
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:
“source_object” set to NULL
“source_attribute” set to EMEUS_CONSTRAINT_ATTRIBUTE_INVALID
“multiplier” set to 1.0
[constructor]
target_object |
the target widget,
or |
[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 |
Since: 1.0
gpointer
emeus_constraint_get_source_object (EmeusConstraint *constraint
);
Retrieves the source object of the constraint
.
EmeusConstraintAttribute
emeus_constraint_get_source_attribute (EmeusConstraint *constraint
);
Retrieves the attribute of the source object bound by this constraint
.
Since: 1.0
EmeusConstraintRelation
emeus_constraint_get_relation (EmeusConstraint *constraint
);
Retrieves the relation between the target and source attributes.
Since: 1.0
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.
Since: 1.0
EmeusConstraintAttribute
emeus_constraint_get_target_attribute (EmeusConstraint *constraint
);
Retrieves the attribute of the target object bound by this constraint
.
Since: 1.0
double
emeus_constraint_get_multiplier (EmeusConstraint *constraint
);
Retrieves the multiplication factor of the constraint
.
Since: 1.0
double
emeus_constraint_get_constant (EmeusConstraint *constraint
);
Retrieves the additional constant of the constraint
.
Since: 1.0
int
emeus_constraint_get_strength (EmeusConstraint *constraint
);
Retrieves the strength of the constraint
.
Since: 1.0
void emeus_constraint_set_active (EmeusConstraint *constraint
,gboolean active
);
Sets whether a constraint
should be actively used by
a EmeusConstraintLayout or not.
Since: 1.0
gboolean
emeus_constraint_get_active (EmeusConstraint *constraint
);
Checks whether a constraint
is active.
Since: 1.0
gboolean
emeus_constraint_is_attached (EmeusConstraint *constraint
);
Checks whether the constraint
is attached to a child of a
EmeusConstraintLayout.
Since: 1.0
gboolean
emeus_constraint_is_required (EmeusConstraint *constraint
);
Checks whether a constraint
is marked as required.
Since: 1.0
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
The possible strengths for a constraint.
The order is:
weak < medium < strong < required
Since: 1.0
The relation between the two terms of the constraint.
Since: 1.0
The attributes that can be used to build a constraint.
Used for constants |
||
The left edge of a widget |
||
The right edge of a widget |
||
The top edge of a widget |
||
The bottom edge of a widget |
||
The leading edge of a widget, depending on the text direction (left for LTR languages, right for RTL ones) |
||
The trailing edge of a widget, depending on the text direction (right for LTR languages, left for RTL ones) |
||
The width of a widget |
||
The height of a widget |
||
The center of a widget, on the horizontal axis |
||
The center of a widget, on the vertical axis |
||
The baseline of a widget |
Since: 1.0
“active”
property“active” gboolean
Whether a EmeusConstraint participates in the layout.
Flags: Read / Write
Default value: TRUE
Since: 1.0
“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
“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
“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
“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
“source-object”
property“source-object” GtkWidget *
The source object in the constraint.
Flags: Read / Write / Construct Only
Since: 1.0
“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
“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