{
Impl()
: mLayout( LayoutEngine::SINGLE_LINE_BOX ),
- mAlignment( LayoutEngine::ALIGN_BEGIN )
+ mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ),
+ mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP )
{
mFontClient = TextAbstraction::FontClient::Get();
}
void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
Vector<Vector2>& glyphPositions )
{
+ // Traverses the paragraphs with right to left characters.
for( LineIndex lineIndex = 0u; lineIndex < layoutParameters.numberOfBidirectionalInfoRuns; ++lineIndex )
{
- const BidirectionalLineInfoRun& bidiLine = *( layoutParameters.lineBidirectionalInfoRunsBuffer +lineIndex );
+ const BidirectionalLineInfoRun& bidiLine = *( layoutParameters.lineBidirectionalInfoRunsBuffer + lineIndex );
float penX = 0.f;
Vector2* glyphPositionsBuffer = glyphPositions.Begin();
+ // Traverses the characters of the right to left paragraph.
for( CharacterIndex characterLogicalIndex = 0u;
characterLogicalIndex < bidiLine.characterRun.numberOfCharacters;
++characterLogicalIndex )
for( GlyphIndex index = 0u; index < numberOfGlyphs; ++index )
{
// Convert the character in the visual order into the glyph in the visual order.
- GlyphIndex glyphIndex = 1u + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex + index ) - numberOfGlyphs;
+ const GlyphIndex glyphIndex = *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) + index;
+
+ DALI_ASSERT_DEBUG( 0u <= glyphIndex && glyphIndex < layoutParameters.totalNumberOfGlyphs );
const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + glyphIndex );
Vector2& position = *( glyphPositionsBuffer + glyphIndex );
// 2) Calculate the alignment offset accordingly with the align option,
// the box width, line length, and the paragraphs direction.
- float alignOffset = CalculateAlignment( layoutSize.width,
- line.lineSize.width,
- line.extraLength,
- paragraphDirection );
+ float alignOffset = CalculateHorizontalAlignment( layoutSize.width,
+ line.lineSize.width,
+ line.extraLength,
+ paragraphDirection );
// 3) Traverse all glyphs and update the 'x' position.
for( GlyphIndex index = line.glyphIndex,
return true;
}
- float CalculateAlignment( float boxWidth,
- float lineLength,
- float extraLength,
- bool paragraphDirection )
+ float CalculateHorizontalAlignment( float boxWidth,
+ float lineLength,
+ float extraLength,
+ bool paragraphDirection )
{
float offset = 0.f;
- Alignment alignment = mAlignment;
+ HorizontalAlignment alignment = mHorizontalAlignment;
if( paragraphDirection &&
- ( ALIGN_CENTER != alignment ) )
+ ( HORIZONTAL_ALIGN_CENTER != alignment ) )
{
- if( ALIGN_BEGIN == alignment )
+ if( HORIZONTAL_ALIGN_BEGIN == alignment )
{
- alignment = ALIGN_END;
+ alignment = HORIZONTAL_ALIGN_END;
}
else
{
- alignment = ALIGN_BEGIN;
+ alignment = HORIZONTAL_ALIGN_BEGIN;
}
}
switch( alignment )
{
- case ALIGN_BEGIN:
+ case HORIZONTAL_ALIGN_BEGIN:
{
offset = 0.f;
break;
}
- case ALIGN_CENTER:
+ case HORIZONTAL_ALIGN_CENTER:
{
offset = 0.5f * ( boxWidth - lineLength );
const int intOffset = static_cast<int>( offset ); // try to avoid pixel alignment.
offset = static_cast<float>( intOffset );
break;
}
- case ALIGN_END:
+ case HORIZONTAL_ALIGN_END:
{
offset = boxWidth - lineLength;
break;
}
LayoutEngine::Layout mLayout;
- LayoutEngine::Alignment mAlignment;
+ LayoutEngine::HorizontalAlignment mHorizontalAlignment;
+ LayoutEngine::VerticalAlignment mVerticalAlignment;
TextAbstraction::FontClient mFontClient;
};
return mImpl->mLayout;
}
-void LayoutEngine::SetAlignment( Alignment alignment )
+void LayoutEngine::SetHorizontalAlignment( HorizontalAlignment alignment )
+{
+ mImpl->mHorizontalAlignment = alignment;
+}
+
+LayoutEngine::HorizontalAlignment LayoutEngine::GetHorizontalAlignment() const
+{
+ return mImpl->mHorizontalAlignment;
+}
+
+void LayoutEngine::SetVerticalAlignment( VerticalAlignment alignment )
{
- mImpl->mAlignment = alignment;
+ mImpl->mVerticalAlignment = alignment;
}
-LayoutEngine::Alignment LayoutEngine::GetAlignment() const
+LayoutEngine::VerticalAlignment LayoutEngine::GetVerticalAlignment() const
{
- return mImpl->mAlignment;
+ return mImpl->mVerticalAlignment;
}
bool LayoutEngine::LayoutText( const LayoutParameters& layoutParameters,