const unsigned int POINTS_PER_INCH = 72;
const std::string EMPTY_STRING("");
-const unsigned int ZERO = 0u;
float ConvertToEven( float value )
{
}
else
{
- layoutSize = mImpl->mVisualModel->GetActualSize();
+ layoutSize = mImpl->mVisualModel->GetLayoutSize();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
}
return glyphsRemoved;
}
+ // Whether a new size has been set.
const bool newSize = ( size != mImpl->mVisualModel->mControlSize );
if( newSize )
const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
const Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
const Character* const textBuffer = mImpl->mLogicalModel->mText.Begin();
+ const Vector<GlyphIndex>& charactersToGlyph = mImpl->mVisualModel->mCharactersToGlyph;
+ const Vector<Length>& glyphsPerCharacter = mImpl->mVisualModel->mGlyphsPerCharacter;
// Set the layout parameters.
LayoutParameters layoutParameters( size,
lineBreakInfo.Begin(),
wordBreakInfo.Begin(),
( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
- numberOfGlyphs,
glyphs.Begin(),
glyphsToCharactersMap.Begin(),
- charactersPerGlyph.Begin() );
+ charactersPerGlyph.Begin(),
+ charactersToGlyph.Begin(),
+ glyphsPerCharacter.Begin(),
+ numberOfGlyphs );
// The laid-out lines.
// It's not possible to know in how many lines the text is going to be laid-out,
// Whether the last character is a new paragraph character.
layoutParameters.isLastNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mLogicalModel->mText.Count() - 1u ) ) );
+ // The initial glyph and the number of glyphs to layout.
+ layoutParameters.startGlyphIndex = 0u;
+ layoutParameters.numberOfGlyphs = numberOfGlyphs;
+
// Update the visual model.
viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
glyphPositions,
// Get the lines
const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
const CharacterIndex startIndex = 0u;
- Length requestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
+ const Length requestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
// Reorder the lines.
bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
startIndex,
requestedNumberOfCharacters );
- // Get the character to glyph conversion table and set into the layout.
- layoutParameters.charactersToGlyphsBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin();
- // Get the glyphs per character table and set into the layout.
- layoutParameters.glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin();
-
// Re-layout the text. Reorder those lines with right to left characters.
mImpl->mLayoutEngine.ReLayoutRightToLeftLines( layoutParameters,
+ startIndex,
+ requestedNumberOfCharacters,
glyphPositions );
// Free the allocated memory used to store the conversion table in the bidirectional line info run.
// Sets the actual size.
if( UPDATE_ACTUAL_SIZE & operations )
{
- mImpl->mVisualModel->SetActualSize( layoutSize );
+ mImpl->mVisualModel->SetLayoutSize( layoutSize );
}
} // view updated
}
else
{
- layoutSize = mImpl->mVisualModel->GetActualSize();
+ layoutSize = mImpl->mVisualModel->GetLayoutSize();
}
if( ALIGN & operations )
// The laid-out lines.
Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
- mImpl->mLayoutEngine.Align( layoutSize,
+ const CharacterIndex startIndex = 0u;
+ const Length requestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
+
+ mImpl->mLayoutEngine.Align( size,
+ startIndex,
+ requestedNumberOfCharacters,
lines );
viewUpdated = true;
return mImpl->mLayoutEngine.GetVerticalAlignment();
}
-void Controller::CalculateTextAlignment( const Size& size )
+void Controller::CalculateTextAlignment( const Size& controlSize )
{
- // Get the direction of the first character.
- const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
+ Size layoutSize = mImpl->mVisualModel->GetLayoutSize();
- Size actualSize = mImpl->mVisualModel->GetActualSize();
- if( fabsf( actualSize.height ) < Math::MACHINE_EPSILON_1000 )
+ if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 )
{
// Get the line height of the default font.
- actualSize.height = mImpl->GetDefaultFontLineHeight();
+ layoutSize.height = mImpl->GetDefaultFontLineHeight();
}
- // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
- LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
- if( firstParagraphDirection &&
- ( LayoutEngine::HORIZONTAL_ALIGN_CENTER != horizontalAlignment ) )
+ if( LayoutEngine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() )
{
- if( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == horizontalAlignment )
- {
- horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_END;
- }
- else
- {
- horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_BEGIN;
- }
- }
+ // Get the direction of the first character.
+ const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
- switch( horizontalAlignment )
- {
- case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
- {
- mImpl->mAlignmentOffset.x = 0.f;
- break;
- }
- case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
+ // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
+ LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
+ if( firstParagraphDirection )
{
- mImpl->mAlignmentOffset.x = floorf( 0.5f * ( size.width - actualSize.width ) ); // try to avoid pixel alignment.
- break;
+ switch( horizontalAlignment )
+ {
+ case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
+ {
+ horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_END;
+ break;
+ }
+ case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
+ {
+ // Nothing to do.
+ break;
+ }
+ case LayoutEngine::HORIZONTAL_ALIGN_END:
+ {
+ horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_BEGIN;
+ break;
+ }
+ }
}
- case LayoutEngine::HORIZONTAL_ALIGN_END:
+
+ switch( horizontalAlignment )
{
- mImpl->mAlignmentOffset.x = size.width - actualSize.width;
- break;
+ case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
+ {
+ mImpl->mAlignmentOffset.x = 0.f;
+ break;
+ }
+ case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
+ {
+ mImpl->mAlignmentOffset.x = floorf( 0.5f * ( controlSize.width - layoutSize.width ) ); // try to avoid pixel alignment.
+ break;
+ }
+ case LayoutEngine::HORIZONTAL_ALIGN_END:
+ {
+ mImpl->mAlignmentOffset.x = controlSize.width - layoutSize.width;
+ break;
+ }
}
}
}
case LayoutEngine::VERTICAL_ALIGN_CENTER:
{
- mImpl->mAlignmentOffset.y = floorf( 0.5f * ( size.height - actualSize.height ) ); // try to avoid pixel alignment.
+ mImpl->mAlignmentOffset.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
break;
}
case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
{
- mImpl->mAlignmentOffset.y = size.height - actualSize.height;
+ mImpl->mAlignmentOffset.y = controlSize.height - layoutSize.height;
break;
}
}
const Length numberOfCharactersInModel = mImpl->mLogicalModel->mText.Count();
// Restrict new text to fit within Maximum characters setting
- Length maxSizeOfNewText = std::min ( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
+ Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
maxLengthReached = ( characterCount > maxSizeOfNewText );
// The cursor position.