Difference between revisions of "Sprite:setLayoutConstraints"

From GiderosMobile
(Created page with "__NOTOC__ '''<translate>Available since</translate>:''' Gideros 2018.9<br/> '''<translate>Class</translate>:''' Sprite<br/> === <translate>Descri...")
 
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
<languages />
 
'''<translate>Available since</translate>:''' Gideros 2018.9<br/>
 
'''<translate>Available since</translate>:''' Gideros 2018.9<br/>
 
'''<translate>Class</translate>:''' [[Special:MyLanguage/Sprite|Sprite]]<br/>
 
'''<translate>Class</translate>:''' [[Special:MyLanguage/Sprite|Sprite]]<br/>
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
 
<translate><br />
 
<translate><br />
<br /></translate>
+
<br />
 +
This function specify the child placement rules within the grid defined on its parent by [[Special:MyLanguage/Sprite:setLayoutParameters|Sprite:setLayoutParameters]].<br />
 +
Gideros layout system is heavily based on Java GridBagLayout principle. See here for more explanation:
 +
https://www.math.uni-hamburg.de/doc/java/tutorial/uiswing/layout/gridbag.html
 +
 
 +
The constraint table can contain the following fields:
 +
* '''gridx''': The 0-based index of the column the child must be placed into<br/>
 +
* '''gridy''': The 0-based index of the row the child must be placed into<br/>
 +
* '''gridwidth''': The number of column this child will take<br/>
 +
* '''gridheight''': The number of row this child will take<br/>
 +
* '''weightx''': The horizontal weight of the child. Used to distribute extra space among children<br/>
 +
* '''weighty''': The vertical weight of the child. Used to distribute extra space among children<br/>
 +
* '''anchor''': Defines where the child should be placed inside its grid space.
 +
Can be [[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_NORTHWEST|Sprite.LAYOUT_ANCHOR_NORTHWEST]], [[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_NORTH|Sprite.LAYOUT_ANCHOR_NORTH]], [[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_NORTHEAST|Sprite.LAYOUT_ANCHOR_NORTHEAST]],
 +
[[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_WEST|Sprite.LAYOUT_ANCHOR_WEST]], [[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_CENTER|Sprite.LAYOUT_ANCHOR_CENTER]], [[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_EAST|Sprite.LAYOUT_ANCHOR_EAST]],
 +
[[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_SOUTHWEST|Sprite.LAYOUT_ANCHOR_SOUTHWEST]], [[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_SOUTH|Sprite.LAYOUT_ANCHOR_SOUTH]] or [[Special:MyLanguage/Sprite.LAYOUT_ANCHOR_SOUTHEAST|Sprite.LAYOUT_ANCHOR_SOUTHEAST]]<br/>
 +
* '''fill''': In which directions the child should be expanded to fit the grid space. Can be [[Special:MyLanguage/Sprite.LAYOUT_FILL_NONE|Sprite.LAYOUT_FILL_NONE]], [[Special:MyLanguage/Sprite.LAYOUT_FILL_HORIZONTAL|Sprite.LAYOUT_FILL_HORIZONTAL]], [[Special:MyLanguage/Sprite.LAYOUT_FILL_VERTICAL|Sprite.LAYOUT_FILL_VERTICAL]] or [[Special:MyLanguage/Sprite.LAYOUT_FILL_BOTH|Sprite.LAYOUT_FILL_BOTH]]<br/>
 +
* '''ipadx''': Internal horizontal padding<br/>
 +
* '''ipady''': Internal vertical padding<br/>
 +
* '''minWidth''': Minimum width<br/>
 +
* '''minHeight''': Minimum height<br/>
 +
* '''prefWidth''': Preferred width<br/>
 +
* '''prefHeight''': Preferred height<br/>
 +
* '''insetTop''': the top margin<br/>
 +
* '''insetLeft''': the left margin<br/>
 +
* '''insetBottom''': the bottom margin<br/>
 +
* '''insetRight''': the right margin<br/>
 +
 
 +
Specifying a '''nil''' table will clear layout constraints.
 +
When a [[Special:MyLanguage/Sprite|Sprite]] is resized by the layout system, a ''Event.LAYOUT_RESIZDE'' is triggered.</translate>
 
<source lang="lua">
 
<source lang="lua">
 
  Sprite:setLayoutConstraints(constraints)
 
  Sprite:setLayoutConstraints(constraints)

Revision as of 10:57, 3 September 2018


Available since: Gideros 2018.9
Class: Sprite

Description



This function specify the child placement rules within the grid defined on its parent by Sprite:setLayoutParameters.
Gideros layout system is heavily based on Java GridBagLayout principle. See here for more explanation: https://www.math.uni-hamburg.de/doc/java/tutorial/uiswing/layout/gridbag.html

The constraint table can contain the following fields:

  • gridx: The 0-based index of the column the child must be placed into
  • gridy: The 0-based index of the row the child must be placed into
  • gridwidth: The number of column this child will take
  • gridheight: The number of row this child will take
  • weightx: The horizontal weight of the child. Used to distribute extra space among children
  • weighty: The vertical weight of the child. Used to distribute extra space among children
  • anchor: Defines where the child should be placed inside its grid space.

Can be Sprite.LAYOUT_ANCHOR_NORTHWEST, Sprite.LAYOUT_ANCHOR_NORTH, Sprite.LAYOUT_ANCHOR_NORTHEAST, Sprite.LAYOUT_ANCHOR_WEST, Sprite.LAYOUT_ANCHOR_CENTER, Sprite.LAYOUT_ANCHOR_EAST, Sprite.LAYOUT_ANCHOR_SOUTHWEST, Sprite.LAYOUT_ANCHOR_SOUTH or Sprite.LAYOUT_ANCHOR_SOUTHEAST

Specifying a nil table will clear layout constraints. When a Sprite is resized by the layout system, a Event.LAYOUT_RESIZDE is triggered.

 Sprite:setLayoutConstraints(constraints)

Parameters

constraints: (table) Table of layout constraints.