const unsigned int POINTS_PER_INCH = 72;
const std::string EMPTY_STRING("");
-const unsigned int ZERO = 0u;
float ConvertToEven( float value )
{
}
}
-void Controller::SetMaximumNumberOfCharacters( int maxCharacters )
+void Controller::SetMaximumNumberOfCharacters( Length maxCharacters )
{
- if( maxCharacters >= 0 )
- {
- mImpl->mMaximumNumberOfCharacters = maxCharacters;
- }
+ mImpl->mMaximumNumberOfCharacters = maxCharacters;
}
int Controller::GetMaximumNumberOfCharacters()
}
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 )
if( 0u == numberOfGlyphs )
{
+ if( UPDATE_ACTUAL_SIZE & operations )
+ {
+ mImpl->mVisualModel->SetLayoutSize( Size::ZERO );
+ }
+
// Nothing else to do if there is no glyphs.
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
return true;
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,
if( REORDER & operations )
{
Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
+ Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = mImpl->mLogicalModel->mBidirectionalLineInfo;
// Check first if there are paragraphs with bidirectional info.
if( 0u != bidirectionalInfo.Count() )
{
// Get the lines
const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
+ const CharacterIndex startIndex = 0u;
+ const Length requestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
// Reorder the lines.
- Vector<BidirectionalLineInfoRun> lineBidirectionalInfoRuns;
- lineBidirectionalInfoRuns.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
+ bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
ReorderLines( bidirectionalInfo,
+ startIndex,
+ requestedNumberOfCharacters,
lines,
- lineBidirectionalInfoRuns );
-
- // Set the bidirectional info into the model.
- const Length numberOfBidirectionalInfoRuns = lineBidirectionalInfoRuns.Count();
- mImpl->mLogicalModel->SetVisualToLogicalMap( lineBidirectionalInfoRuns.Begin(),
- numberOfBidirectionalInfoRuns );
+ bidirectionalLineInfo );
// Set the bidirectional info per line into the layout parameters.
- layoutParameters.lineBidirectionalInfoRunsBuffer = lineBidirectionalInfoRuns.Begin();
- layoutParameters.numberOfBidirectionalInfoRuns = numberOfBidirectionalInfoRuns;
+ layoutParameters.lineBidirectionalInfoRunsBuffer = bidirectionalLineInfo.Begin();
+ layoutParameters.numberOfBidirectionalInfoRuns = bidirectionalLineInfo.Count();
- // 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();
+ // Set the bidirectional info into the model.
+ mImpl->mLogicalModel->SetVisualToLogicalMap( layoutParameters.lineBidirectionalInfoRunsBuffer,
+ layoutParameters.numberOfBidirectionalInfoRuns,
+ startIndex,
+ requestedNumberOfCharacters );
// 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.
- for( Vector<BidirectionalLineInfoRun>::Iterator it = lineBidirectionalInfoRuns.Begin(),
- endIt = lineBidirectionalInfoRuns.End();
+ for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfo.Begin(),
+ endIt = bidirectionalLineInfo.End();
it != endIt;
++it )
{
BidirectionalLineInfoRun& bidiLineInfo = *it;
free( bidiLineInfo.visualToLogicalMap );
+ bidiLineInfo.visualToLogicalMap = NULL;
}
+
+ bidirectionalLineInfo.Clear();
}
} // REORDER
// 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:
+ // 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 = 0.f;
- break;
- }
- case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
- {
- 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.