class CAlfAnchorLayout : public CAlfLayout |
CAlfAnchorLayout is a layout that allows visuals to be positioned with flexible relative anchor points.
To use this class, an anchor layout is created, and then a number of anchors are added to it using calls to the Attach() methods. The visuals inside the layout will be stretched between these anchor points.
Protected Member Functions | |
---|---|
IMPORT_C void | DoRemoveAndDestroyAllD() |
IMPORT_C void | PropertyOwnerExtension(const TUid &, TAny **) |
Inherited Enumerations | |
---|---|
CAlfLayout:TExpansionFlags |
Private Attributes | |
---|---|
TAnchorLayoutPrivateData * | iAnchorLayoutData |
IMPORT_C CAlfAnchorLayout * | AddNewL | ( | CAlfControl & | aOwnerControl, |
CAlfLayout * | aParentLayout = 0 | |||
) | [static] |
Two-phased constructor, which attach new object into the control.
CAlfControl & aOwnerControl | Control that owns this new obejct. |
CAlfLayout * aParentLayout = 0 | If given, the new object is set as child. |
IMPORT_C TInt | Attach | ( | TInt | aOrdinal, |
TAlfAnchorType | aType, | |||
const TAlfMetric & | aOffset, | |||
TAlfAnchorAttachmentOrigin | aAttachmentOrigin, | |||
TInt | aAttachmentOrdinal = EAlfAnchorAttachToParent | |||
) |
Anchors one or more edges of a child visual to a specific position within this layout. When combined together, a correctly specified group of anchors provide sufficient information for the anchor layout to determine the size and position of the child visual.
Each child can have up to four anchors, each of which correspond to an edge. A corner anchor is equivalent to supplying two similar orthogonal edge anchors, so typically it is easier to use corners. Therefore, each child can have up to two corner anchors, or a mixture of corners and edges. Alternatively, four similar edges can be specified in one call by supplying a box metric.
In a typical case you set two different corner anchors (for example both EAlfAnchorTypeTopLeft and EAlfAnchorTypeBottomRight), taking care to ensure that they are sufficiently orthogonal in order to define all needed coordinates. However it is also possible to set only one corner anchor, which only positions the child without affecting it's size. Alternatively, one anchor can be specified as a corner, and then the other can be specified as EAlfAnchorTypeSize; similarly the coordinates along one axis can be specified by an appropriate combination of edge and width or height anchors.
The position of each anchor relative to this layout is determined by the choice of origin (i.e. which point of the layout the child's is attached to), and the offset position, which is specified using a TAlfMetric or related type. All available features of TAlfMetric may be used to affect the resulting position, providing the benefit that different metrics can be used for each child. Also note that the metric used will override the base unit that has been set in this layout.
if called again to specify the same anchor types that have been previous set, those definitions will be updated. However, in order to change type, it is necessary to detach a previously defined anchor first, as there can only be a maximum of two anchors along each axis (for a given child).
that size anchor type and attachment origins are not currenly supported.
that center anchor type is not currently supported.
if an anchor of similar type has already been defined it will be replaced, however in general it is easier to manage anchors by removing them all and starting again.
After updating anchors, you should call CAlfLayout::UpdateChildrenLayout(), to cause the anchors to be applied to child positions and/or sizes.
// using edges... iLayout->Attach(0, EAlfAnchorTypeLeft, TAlfXYMetric(0.25, EAlfMetricNormalized), EAlfAnchorAttachmentOriginLeft); iLayout->Attach(0, EAlfAnchorTypeRight, TAlfXYMetric(-0.25, EAlfMetricNormalized), EAlfAnchorAttachmentOriginRight); iLayout->Attach(0, EAlfAnchorTypeTop, TAlfXYMetric(0.25, EAlfMetricNormalized), EAlfAnchorAttachmentOriginTop); iLayout->Attach(0, EAlfAnchorTypeBottom, TAlfXYMetric(-0.25, EAlfMetricNormalized), EAlfAnchorAttachmentOriginBottom); // using corners... iLayout->Attach(1, EAlfAnchorTypeTopLeft, TAlfXYMetric(0.25, EAlfMetricNormalized), EAlfAnchorAttachmentOriginTopLeft); iLayout->Attach(1, EAlfAnchorTypeBottomRight, TAlfXYMetric(-0.25, EAlfMetricNormalized), EAlfAnchorAttachmentOriginBottomRight); // .. and using a box iLayout->Attach(2, TAlfBoxMetric( TAlfMetric(0.25, EAlfMetricNormalized), TAlfMetric(-0.25, EAlfMetricNormalized), TAlfMetric(0.25, EAlfMetricNormalized), TAlfMetric(-0.25, EAlfMetricNormalized)));
TInt aOrdinal | Ordinal of the child visual that this anchor applies to |
TAlfAnchorType aType | Type of the anchor, which determines how and where the anchor attaches to this layout |
const TAlfMetric & aOffset | The anchor position as an offset from the origin point, specifying both the magnitude and units of the offset for the relevant axes. |
TAlfAnchorAttachmentOrigin aAttachmentOrigin | Origin for the anchor offset. Defines the point inside the layout from which the evaluation of the child's placement is based. |
TInt aAttachmentOrdinal = EAlfAnchorAttachToParent | the ordinal of the anchor to which this anchor is attached, use the default value of EAlfAnchorAttachToParent in order to attach to parent |
IMPORT_C TInt | Attach | ( | TInt | aOrdinal, |
TAlfAnchorType | aType, | |||
const TAlfXYMetric & | aOffset, | |||
TAlfAnchorAttachmentOrigin | aAttachmentOrigin = EAlfAnchorAttachmentOriginTopLeft, | |||
TInt | aAttachmentOrdinal = EAlfAnchorAttachToParent | |||
) |
Attach a corner of a child visual to a specific position within this layout.
Attach() for all API documentation
TInt aOrdinal | |
TAlfAnchorType aType | |
const TAlfXYMetric & aOffset | |
TAlfAnchorAttachmentOrigin aAttachmentOrigin = EAlfAnchorAttachmentOriginTopLeft | |
TInt aAttachmentOrdinal = EAlfAnchorAttachToParent |
IMPORT_C TInt | Attach | ( | TInt | aOrdinal, |
const TAlfBoxMetric & | aOffset, | |||
TAlfAnchorAttachmentOrigin | aAttachmentOrigin = EAlfAnchorAttachmentOriginTopLeft, | |||
TInt | aAttachmentOrdinal = EAlfAnchorAttachToParent | |||
) |
Attach all four edges of a child visual to a specific position within this layout.
, will detach all existing edges first. In case of error, all edges that were successfull added before the error occurred will be detached.
TInt aOrdinal | |
const TAlfBoxMetric & aOffset | |
TAlfAnchorAttachmentOrigin aAttachmentOrigin = EAlfAnchorAttachmentOriginTopLeft | if set to EAlfAnchorAttachmentOriginNone, each edge will be attached to the corresponding edge |
TInt aAttachmentOrdinal = EAlfAnchorAttachToParent |
IMPORT_C void | ConstructL | ( | CAlfControl & | aOwner | ) | [virtual] |
From CAlfLayout. Second-phase constructor.
CAlfControl & aOwner |
IMPORT_C void | Detach | ( | TInt | aOrdinal | ) |
Undefines all anchors for a specified ordinal. Has no effect if the specified ordinal cannot be found.
TInt aOrdinal | the ordinal of the anchor to remove |
IMPORT_C void | Detach | ( | TInt | aOrdinal, |
TAlfAnchorType | aType | |||
) |
Undefines an anchor. Has no effect if the specified anchor type cannot be found. For example to detach a corner anchor with ordinal equal to zero:
iLayout->Detach(0, EAlfAnchorTypeTopLeft);
can be used to separately remove the edges that were attached using different combinations of types, but try to be consistent in using either edges or corners to avoid confusion.
TInt aOrdinal | the ordinal of the anchor to remove |
TAlfAnchorType aType | the edge relating to the anchor to remove |
IMPORT_C void | DoRemoveAndDestroyAllD | ( | ) | [protected, virtual] |
From CAlfVisual CAlfVisual
IMPORT_C CAlfVisual * | FindTag | ( | const TDesC8 & | aTag | ) | [virtual] |
CAlfVisual Finds a visual whose tag descriptor contains a specific tag.
CAlfLayout::FindTag() extends the search into child visuals, covering recursively entire visual hierarchies.
Todo: how should several visuals with matching tag to be handled ??
CAlfVisual::Tag() CAlfVisual::SetTagL() CAlfVisual::IsTagged() CAlfVisual::FindTag()
const TDesC8 & aTag | Tag to look for. If this tag is found as a part of a visual's colon-separated tag descriptor, it is treated as a match and the visual is returned. The tag to look for cannot contain separator characters (:). |
IMPORT_C void | PropertyOwnerExtension | ( | const TUid & | aExtensionUid, |
TAny ** | aExtensionParams | |||
) | [protected, virtual] |
! future proofing
IMPORT_C void | RemoveAnchor | ( | TAlfAnchor | aAnchor, |
TInt | aOrdinal | |||
) |
Undefines an anchor. SetAnchor() instead use Detach and see relevant API documentation for example code
TAlfAnchor aAnchor | |
TInt aOrdinal |
IMPORT_C TInt | SetAnchor | ( | TAlfAnchor | aAnchor, |
TInt | aOrdinal, | |||
TAlfAnchorOrigin | aHorizOrigin, | |||
TAlfAnchorOrigin | aVertOrigin, | |||
TAlfAnchorMetric | aHorizMetric, | |||
TAlfAnchorMetric | aVertMetric, | |||
const TAlfTimedPoint & | aOffset | |||
) |
Anchors a child visual's corner to specific position within this layout.
, use new Attach APIs with TAlfMetric support. See the relevant API documentation for an example of how to migrate your code
Each child can have two anchors: the top left and bottom right corners of the child visual. These anchors can be fastened to any point within this layout, as specified by the other parameters.
In a typical case you set two anchors (both EAlfAnchorTopLeft and EAlfAnchorBottomRight), which specifies both size and position for the child. However it is also possible to set only the EAlfAnchorTopLeft anchor, which only positions the child without affecting it's size.
After updating anchors, you should call CAlfLayout::UpdateChildrenLayout(), to cause the anchors to be applied to child positions and/or sizes.
// set top left corner position of 1st child .. iLayout->SetAnchor(EAlfAnchorTopLeft, 0, EAlfAnchorOriginLeft, EAlfAnchorOriginTop, EAlfAnchorMetricRelativeToSize, // With EAlfAnchorOriginLeft means that 0.0 goes to left edge, and 1.0 to the right EAlfAnchorMetricRelativeToSize, // With EAlfAnchorOriginTop means that 0.0 goes to top edge, and 1.0 to the bottom TAlfTimedPoint(0.25, 0.25)); // .. and set the bottom right corner also to fix the size iLayout->SetAnchor(EAlfAnchorBottomRight, 0, EAlfAnchorOriginRight, EAlfAnchorOriginBottom, EAlfAnchorMetricRelativeToSize, EAlfAnchorMetricRelativeToSize, TAlfTimedPoint(-0.25, -0.25));
TodoSpecifying a transition in the timed point may be useless: layouts are evaluated pretty seldom.
TAlfAnchor aAnchor | Type of the anchor (either EAlfAnchorTopLeft for the top left corner or EAlfAnchorBottomRight for bottom right corner). |
TInt aOrdinal | Ordinal of the child visual that this anchor applies to. |
TAlfAnchorOrigin aHorizOrigin | Horizontal origin for the anchor position (aPosition). Defines the point inside the layout on which the evaluation of the child's placement is based. May be EAlfAnchorOriginLeft (left edge), EAlfAnchorOriginHCenter (center) or EAlfAnchorOriginRight (right edge). |
TAlfAnchorOrigin aVertOrigin | Vertical origin for the anchor position (aPosition). Defines the point inside the layout on which the evaluation of the child's placement is based. Possible options are EAlfAnchorOriginTop (top), EAlfAnchorOriginVCenter (center) and EAlfAnchorOriginBottom (bottom). |
TAlfAnchorMetric aHorizMetric | Specifies the metric to use to define the horizontal position: EAlfAnchorMetricAbsolute to use absolute pixels or EAlfAnchorMetricRelativeToSize to use normalized values relative to layout size. |
TAlfAnchorMetric aVertMetric | Specifies the metric used in the vertical position: EAlfAnchorMetricAbsolute to use absolute pixels or EAlfAnchorMetricRelativeToSize to use normalized values relative to layout size. |
const TAlfTimedPoint & aOffset |
IMPORT_C TInt | SetRelativeAnchorRect | ( | TInt | aOrdinal, |
TAlfAnchorOrigin | aTlHorizOrigin, | |||
TAlfAnchorOrigin | aTlVertOrigin, | |||
const TAlfRealPoint & | aTopLeftOffset, | |||
TAlfAnchorOrigin | aBrHorizOrigin, | |||
TAlfAnchorOrigin | aBrVertOrigin, | |||
const TAlfRealPoint & | aBottomRightOffset | |||
) |
Convenience method for setting top left and bottom right anchors in a single call.
This method sets size-relative anchors for a single child visual.
CAlfAnchorLayout::SetAnchor() for more information about anchors.
TInt aOrdinal | Ordinal of child visual to set anchors for. |
TAlfAnchorOrigin aTlHorizOrigin | Horizontal origin for the top left anchor position (aPosition). Defines the point inside the layout on which the evaluation of the child's placement is based. May be EAlfAnchorOriginLeft (left edge), EAlfAnchorOriginHCenter (center) or EAlfAnchorOriginRight (right edge). |
TAlfAnchorOrigin aTlVertOrigin | Vertical origin for the top left anchor position (aPosition). Defines the point inside the layout on which the evaluation of the child's placement is based. Possible options are EAlfAnchorOriginTop (top), EAlfAnchorOriginVCenter (center) and EAlfAnchorOriginBottom (bottom). |
const TAlfRealPoint & aTopLeftOffset | The achor position as an offset from the origin point, |
TAlfAnchorOrigin aBrHorizOrigin | Horizontal origin for the bottom right anchor position (aPosition). Defines the point inside the layout on which the evaluation of the child's placement is based. May be EAlfAnchorOriginLeft (left edge), EAlfAnchorOriginHCenter (center) or EAlfAnchorOriginRight (right edge). |
TAlfAnchorOrigin aBrVertOrigin | Vertical origin for the bottom right anchor position (aPosition). Defines the point inside the layout on which the evaluation of the child's placement is based. Possible options are EAlfAnchorOriginTop (top), EAlfAnchorOriginVCenter (center) and EAlfAnchorOriginBottom (bottom). |
const TAlfRealPoint & aBottomRightOffset | The achor position as an offset from the origin point, |
IMPORT_C void | UpdateChildrenLayout | ( | TInt | aTransitionTime = 0 | ) | [virtual] |
CAlfVisual Update the layout of all children. Subclasses can call this to recalculate the layout of all children.
TInt aTransitionTime = 0 | Time for layout transition in milliseconds. Any negative value uses value given in CAlfEnv::StaticSetLayoutTransitionTime() |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.