Class Constraint

All Implemented Interfaces:
PointerInterface

public class Constraint extends Object
`GtkConstraint` describes a constraint between attributes of two widgets,
expressed as a linear equation.

The typical equation for a constraint is:

```
target.target_attr = source.source_attr × multiplier + constant
```

Each `GtkConstraint` is part of a system that will be solved by a
[class@Gtk.ConstraintLayout] in order to allocate and position each
child widget or guide.

The source and target, as well as their attributes, of a `GtkConstraint`
instance are immutable after creation.

https://docs.gtk.org/gtk4/class.Constraint.html

  • Constructor Details

    • Constraint

      public Constraint(PointerContainer pointer)
    • Constraint

      public Constraint(@Nullable Pointer target, int target_attribute, int relation, @Nullable Pointer source, int source_attribute, double multiplier, double constant, int strength)
      Creates a new constraint representing a relation between a layout
      attribute on a source and a layout attribute on a target.
      Parameters:
      target - the target of the constraint
      target_attribute - the attribute of `target` to be set
      relation - the relation equivalence between `target_attribute` and `source_attribute`
      source - the source of the constraint
      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
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newConstantConstraint

      public static Constraint newConstantConstraint(@Nullable Pointer target, int target_attribute, int relation, double constant, int strength)
      Creates a new constraint representing a relation between a layout
      attribute on a target and a constant value.
      Parameters:
      target - a the target of the constraint
      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 constraint
    • getConstant

      public double getConstant()
      Retrieves the constant factor added to the source attributes' value.
      Returns:
      a constant factor
    • getMultiplier

      public double getMultiplier()
      Retrieves the multiplication factor applied to the source
      attribute's value.
      Returns:
      a multiplication factor
    • getRelation

      public int getRelation()
      The order relation between the terms of the constraint.
      Returns:
      a relation type
    • getSource

      public ConstraintTarget getSource()
      Retrieves the [iface@Gtk.ConstraintTarget] used as the source for the
      constraint.

      If the source is set to `NULL` at creation, the constraint will use
      the widget using the [class@Gtk.ConstraintLayout] as the source.
      Returns:
      the source of the constraint
    • getSourceAttribute

      public int getSourceAttribute()
      Retrieves the attribute of the source to be read by the constraint.
      Returns:
      the source's attribute
    • getStrength

      public int getStrength()
      Retrieves the strength of the constraint.
      Returns:
      the strength value
    • getTarget

      public ConstraintTarget getTarget()
      Retrieves the [iface@Gtk.ConstraintTarget] used as the target for
      the constraint.

      If the targe is set to `NULL` at creation, the constraint will use
      the widget using the [class@Gtk.ConstraintLayout] as the target.
      Returns:
      a `GtkConstraintTarget`
    • getTargetAttribute

      public int getTargetAttribute()
      Retrieves the attribute of the target to be set by the constraint.
      Returns:
      the target's attribute
    • isAttached

      public boolean isAttached()
      Checks whether the constraint is attached to a [class@Gtk.ConstraintLayout],
      and it is contributing to the layout.
      Returns:
      `TRUE` if the constraint is attached
    • isConstant

      public boolean isConstant()
      Checks whether the constraint describes a relation between an attribute
      on the [property@Gtk.Constraint:target] and a constant value.
      Returns:
      `TRUE` if the constraint is a constant relation
    • isRequired

      public boolean isRequired()
      Checks whether the constraint is a required relation for solving the
      constraint layout.
      Returns:
      %TRUE if the constraint is required
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()