This layout arranges components based on anchors - descriptions of hard connections between two components. These connections are specified per component, where each component may specify a dependent relationship with exactly one other component. Each relationship consists of the two dependent components, the alignment points on each, and optional x/y offsets.
As an example, the following would setup labelA in the top left corner of the container, 5 pixels from the top and 5 pixels from the bottom. Directly below that (5 pixels from the bottom of labelA) is labelB, left aligned to labelA:
UIContainer container; UILabel labelA, labelB ... container.setLayout(new AnchorLayout()); labelA.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, container, Alignment.TOP_LEFT, 5, -5)); labelB.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, labelA, Alignment.BOTTOM_LEFT, 0, -5));@see AnchorLayoutData
Sides of the components can be anchored either absolutely (eg, if the right side is anchored absolutely then it will always be a fixed number of pixels from the right side of it's parent container) or relatively (ie, if any side is anchored relatively then it will always occur a fixed fraction of the way along it's parent's side). Or they can be not anchored, at all in which case they will occur at places determined by their component's "bounds" property and the anchoring of the component's other sides.
anchorSize
is specified, the layout will use it as a virtual container for the purposes of calculating anchor measurements based on it instead, allowing the container to be sized independently of the anchoring logic if necessary. The items added to an AnchorLayout can also supply an anchoring-specific layout property (see {@link AnchorData#setAnchorSpec(String)}) which is a string containing two values: the horizontal anchor value and the vertical anchor value (for example, '100% 50%'). This value is what tells the layout how the item should be anchored to the container. The following types of anchor values are supported: This is a layout that enables anchoring of contained elements relative to the container's dimensions. If the container is resized, all anchored items are automatically rerendered according to their anchor rules.
AnchorLayout does not have any direct config options (other than inherited ones). However, the container using the AnchorLayout can supply an anchoring-specific config property of anchorSize. By default, AnchorLayout will calculate anchor measurements based on the size of the container itself. However, if anchorSize is specifed, the layout will use it as a virtual container for the purposes of calculating anchor measurements based on it instead, allowing the container to be sized independently of the anchoring logic if necessary.
The items added to an AnchorLayout can also supply an anchoring-specific config property of anchor which is a string containing two values: the horizontal anchor value and the vertical anchor value (for example, '100% 50%'). This value is what tells the layout how the item should be anchored to the container. The following types of anchor values are supported:
Anchor values can also be mixed as needed. For example, '-50 75%' would render the width offset from the container right edge by 50 pixels and 75% of the container's height.
@author Sanjiv Jivan @see com.gwtext.client.widgets.layout.AnchorLayoutData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|