Class: Gtk::ConstraintLayout
- Inherits:
-
LayoutManager
- Object
- LayoutManager
- Gtk::ConstraintLayout
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#add_constraint(constraint) ⇒ nil
Adds a constraint to the layout manager.
-
#add_constraints_from_description(lines, n_lines, hspacing, vspacing, error, first_view, array) ⇒ GLib::List<Gtk::Constraint>
Creates a list of constraints from a VFL description.
-
#add_constraints_from_descriptionv(lines, n_lines, hspacing, vspacing, views) ⇒ GLib::List<Gtk::Constraint>
Creates a list of constraints from a VFL description.
-
#add_guide(guide) ⇒ nil
Adds a guide to
layout. -
#initialize ⇒ Gtk::LayoutManager
constructor
Creates a new
GtkConstraintLayoutlayout manager. -
#observe_constraints ⇒ Gio::ListModel
Returns a
GListModelto track the constraints that are part of the layout. -
#observe_guides ⇒ Gio::ListModel
Returns a
GListModelto track the guides that are part of the layout. -
#remove_all_constraints ⇒ nil
Removes all constraints from the layout manager.
-
#remove_constraint(constraint) ⇒ nil
Removes
constraintfrom the layout manager, so that it no longer influences the layout. -
#remove_guide(guide) ⇒ nil
Removes
guidefrom the layout manager, so that it no longer influences the layout.
Methods inherited from LayoutManager
#allocate, #get_layout_child, #layout_changed, #measure, #request_mode, #widget
Constructor Details
#initialize ⇒ Gtk::LayoutManager
Creates a new GtkConstraintLayout layout manager.
Instance Method Details
#add_constraint(constraint) ⇒ nil
Adds a constraint to the layout manager.
The [propertyGtk.Constraint:source] and [propertyGtk.Constraint:target]
properties of constraint can be:
- set to
NULLto indicate that the constraint refers to the widget usinglayout - set to the [classGtk.Widget] using
layout - set to a child of the [classGtk.Widget] using
layout - set to a [classGtk.ConstraintGuide] that is part of
layout
The layout acquires the ownership of constraint after calling this function.
#add_constraints_from_description(lines, n_lines, hspacing, vspacing, error, first_view, array) ⇒ GLib::List<Gtk::Constraint>
Creates a list of constraints from a VFL description.
This function is a convenience wrapper around [methodGtk.ConstraintLayout.add_constraints_from_descriptionv], using variadic arguments to populate the view/target map.
#add_constraints_from_descriptionv(lines, n_lines, hspacing, vspacing, views) ⇒ GLib::List<Gtk::Constraint>
Creates a list of constraints from a VFL description.
The Visual Format Language, VFL, is based on Apple's AutoLayout VFL.
The views dictionary is used to match [ifaceGtk.ConstraintTarget]
instances to the symbolic view name inside the VFL.
The VFL grammar is:
<visualFormatString> = (<orientation>)?
(<superview><connection>)?
<view>(<connection><view>)*
(<connection><superview>)?
<orientation> = 'H' | 'V'
<superview> = '|'
<connection> = '' | '-' <predicateList> '-' | '-'
<predicateList> = <simplePredicate> | <predicateListWithParens>
<simplePredicate> = <metricName> | <positiveNumber>
<predicateListWithParens> = '(' <predicate> (',' <predicate>)* ')'
<predicate> = (<relation>)? <objectOfPredicate> (<operatorList>)? ('@' <priority>)?
<relation> = '==' | '<=' | '>='
<objectOfPredicate> = <constant> | <viewName> | ('.' <attributeName>)?
<priority> = <positiveNumber> | 'required' | 'strong' | 'medium' | 'weak'
<constant> = <number>
<operatorList> = (<multiplyOperator>)? (<addOperator>)?
<multiplyOperator> = [ '*' | '/' ] <positiveNumber>
<addOperator> = [ '+' | '-' ] <positiveNumber>
<viewName> = [A-Za-z_]([A-Za-z0-9_]*) // A C identifier
<metricName> = [A-Za-z_]([A-Za-z0-9_]*) // A C identifier
<attributeName> = 'top' | 'bottom' | 'left' | 'right' | 'width' | 'height' |
'start' | 'end' | 'centerX' | 'centerY' | 'baseline'
<positiveNumber> // A positive real number parseable by g_ascii_strtod()
<number> // A real number parseable by g_ascii_strtod()
Note: The VFL grammar used by GTK is slightly different than the one defined by Apple, as it can use symbolic values for the constraint's strength instead of numeric values; additionally, GTK allows adding simple arithmetic operations inside predicates.
Examples of VFL descriptions are:
// Default spacing
[button]-[textField]
// Width constraint
[button(>=50)]
// Connection to super view
|-50-[purpleBox]-50-|
// Vertical layout
V:[topField]-10-[bottomField]
// Flush views
[maroonView][blueView]
// Priority
[button(100<b>strong</b>)]
// Equal widths
[button1(==button2)]
// Multiple predicates
[flexibleButton(>=70,<=100)]
// A complete line of layout
|-[find]-[findNext]-[findField(>=20)]-|
// Operators
[button1(button2 / 3 + 50)]
// Named attributes
[button1(==button2.height)]
#add_guide(guide) ⇒ nil
Adds a guide to layout.
A guide can be used as the source or target of constraints, like a widget, but it is not visible.
The layout acquires the ownership of guide after calling
this function.
#observe_constraints ⇒ Gio::ListModel
Returns a GListModel to track the constraints that are
part of the layout.
Calling this function will enable extra internal bookkeeping to track constraints and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
#observe_guides ⇒ Gio::ListModel
Returns a GListModel to track the guides that are
part of the layout.
Calling this function will enable extra internal bookkeeping to track guides and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
#remove_all_constraints ⇒ nil
Removes all constraints from the layout manager.
#remove_constraint(constraint) ⇒ nil
Removes constraint from the layout manager,
so that it no longer influences the layout.
#remove_guide(guide) ⇒ nil
Removes guide from the layout manager,
so that it no longer influences the layout.