TAlfMetric Struct Reference

struct TAlfMetric

A Metric is used to represent a value in a specified unit type. This is to support the definition of Layouts using screen-size independent as well as screen-size dependent measurements.

The metrics are used for different things in different contexts: coordinate base units, anchor offsets, grid column/row weights, paddings, etc. The interpretation of the units used in the metric depends on the context, the type of Layout in which they are used, etc. Usage:
        TAlfMetric metricX(1.0, EAlfUnitNormalized); 
 TAlfMetric metricY(2.0, EAlfUnitNormalized);
 //Set Layout base unit using Metrc
 layout->SetBaseUnit(metricX);
 
 //Create XYMetric using Metric 
 TAlfXYMetric metricXY(metricX, metricY);
 //Set Layout base unit using XYMetrc
 layout->SetBaseUnit( metricXY );
 
 //Create Anchor offset as boxMetric
 TAlfBoxMetric offset(
       TAlfMetric(0.1, EAlfUnitMySize),
       TAlfMetric(-0.1, EAlfUnitMySize),
       TAlfMetric(0.1, EAlfUnitMySize),
       TAlfMetric(-0.1, EAlfUnitMySize));
 TAlfAnchorAttachmentOrigin attachmentOrigin(EAlfAnchorAttachmentOriginNone);
 TInt attachmentOrdinal(EAlfAnchorAttachToParent);
  
 //Attach anchor origin
 anchorLayout->Attach(ordinal, offset, attachmentOrigin, attachmentOrdinal);
       

Constructor & Destructor Documentation

TAlfMetric(TReal32, TInt, TInt)

IMPORT_C TAlfMetric ( TReal32 aMagnitude = 1.f,
TInt aUnit = EAlfUnitPixel,
TInt aReferenceTextStyleId = EAlfTextStyleNormal
)

Constructor. The constructor defaults to using [1px] units.

Parameters

TReal32 aMagnitude = 1.f the size of the metric value, for example it may represent a length or a scale factor
TInt aUnit = EAlfUnitPixel the unit type in which the metric value is represented
TInt aReferenceTextStyleId = EAlfTextStyleNormal

TAlfMetric(TInt)

IMPORT_C TAlfMetric ( TInt aPixels )

Constructor. Allows the compiler to pass integers instead of TAlfMetric in parameters, in place of pixel metrics.

Parameters

TInt aPixels Number of pixels for the metric.

Member Data Documentation

TReal32 iMagnitude

TReal32 iMagnitude

TInt iReferenceTextStyleId

TInt iReferenceTextStyleId

CAlfTextStyleManager::TextStyle

TInt iUnit

TInt iUnit