mImpl->mControlSize = size;
}
+ // Make sure the model is up-to-date before layouting
+ ReplaceText( mImpl->mOperationsPending );
+
Size layoutSize;
bool updated = DoRelayout( mImpl->mControlSize,
mImpl->mOperationsPending,
return updated;
}
-bool Controller::DoRelayout( const Vector2& size,
- OperationsMask operationsRequired,
- Size& layoutSize )
+void Controller::ReplaceText( OperationsMask operationsRequired )
{
- bool viewUpdated( false );
-
// Calculate the operations to be done.
const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
}
}
- Vector<BidirectionalParagraphInfoRun> bidirectionalInfo;
if( BIDI_INFO & operations )
{
// Some vectors with data needed to get the paragraph's bidirectional info may be void
}
}
+ Vector<BidirectionalParagraphInfoRun> bidirectionalInfo;
bidirectionalInfo.Reserve( numberOfParagraphs );
// Calculates the bidirectional info for the whole paragraph if it contains right to left scripts.
charactersPerGlyph.Begin(),
numberOfGlyphs );
}
+}
+
+bool Controller::DoRelayout( const Vector2& size,
+ OperationsMask operationsRequired,
+ Size& layoutSize )
+{
+ bool viewUpdated( false );
+
+ // Calculate the operations to be done.
+ const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
if( LAYOUT & operations )
{
// Fill the vectors again.
const Length numberOfCharacters = mImpl->mLogicalModel->GetNumberOfCharacters();
- numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
+ Length numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
- if( 0u == lineBreakInfo.Count() )
- {
- lineBreakInfo.Resize( numberOfCharacters );
- mImpl->mLogicalModel->GetLineBreakInfo( lineBreakInfo.Begin(),
- 0u,
- numberOfCharacters );
- }
+ Vector<LineBreakInfo> lineBreakInfo;
+ lineBreakInfo.Resize( numberOfCharacters );
+ mImpl->mLogicalModel->GetLineBreakInfo( lineBreakInfo.Begin(),
+ 0u,
+ numberOfCharacters );
- if( 0u == wordBreakInfo.Count() )
- {
- wordBreakInfo.Resize( numberOfCharacters );
- mImpl->mLogicalModel->GetWordBreakInfo( wordBreakInfo.Begin(),
- 0u,
- numberOfCharacters );
- }
+ Vector<WordBreakInfo> wordBreakInfo;
+ wordBreakInfo.Resize( numberOfCharacters );
+ mImpl->mLogicalModel->GetWordBreakInfo( wordBreakInfo.Begin(),
+ 0u,
+ numberOfCharacters );
- if( 0u == glyphs.Count() )
- {
- glyphs.Resize( numberOfGlyphs );
- mImpl->mVisualModel->GetGlyphs( glyphs.Begin(),
- 0u,
- numberOfGlyphs );
- }
+ Vector<GlyphInfo> glyphs;
+ glyphs.Resize( numberOfGlyphs );
+ mImpl->mVisualModel->GetGlyphs( glyphs.Begin(),
+ 0u,
+ numberOfGlyphs );
- if( 0u == glyphsToCharactersMap.Count() )
- {
- glyphsToCharactersMap.Resize( numberOfGlyphs );
- mImpl->mVisualModel->GetGlyphToCharacterMap( glyphsToCharactersMap.Begin(),
+ Vector<CharacterIndex> glyphsToCharactersMap;
+ glyphsToCharactersMap.Resize( numberOfGlyphs );
+ mImpl->mVisualModel->GetGlyphToCharacterMap( glyphsToCharactersMap.Begin(),
+ 0u,
+ numberOfGlyphs );
+
+ Vector<Length> charactersPerGlyph;
+ charactersPerGlyph.Resize( numberOfGlyphs );
+ mImpl->mVisualModel->GetCharactersPerGlyphMap( charactersPerGlyph.Begin(),
0u,
numberOfGlyphs );
- }
-
- if( 0u == charactersPerGlyph.Count() )
- {
- charactersPerGlyph.Resize( numberOfGlyphs );
- mImpl->mVisualModel->GetCharactersPerGlyphMap( charactersPerGlyph.Begin(),
- 0u,
- numberOfGlyphs );
- }
// Set the layout parameters.
LayoutParameters layoutParameters( size,
{
const Length numberOfBidiParagraphs = mImpl->mLogicalModel->GetNumberOfBidirectionalInfoRuns( 0u, numberOfCharacters );
- if( 0u == bidirectionalInfo.Count() )
- {
- bidirectionalInfo.Resize( numberOfBidiParagraphs );
- mImpl->mLogicalModel->GetBidirectionalInfo( bidirectionalInfo.Begin(),
- 0u,
- numberOfCharacters );
- }
+ Vector<BidirectionalParagraphInfoRun> bidirectionalInfo;
+ bidirectionalInfo.Resize( numberOfBidiParagraphs );
+ mImpl->mLogicalModel->GetBidirectionalInfo( bidirectionalInfo.Begin(),
+ 0u,
+ numberOfCharacters );
// Check first if there are paragraphs with bidirectional info.
if( 0u != bidirectionalInfo.Count() )
GET_WORD_BREAKS |
SHAPE_TEXT |
GET_GLYPH_METRICS );
+ // Make sure the model is up-to-date before layouting
+ ReplaceText( onlyOnceOperations );
// Operations that need to be done if the size changes.
const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
SHAPE_TEXT |
GET_GLYPH_METRICS );
+ // Make sure the model is up-to-date before layouting
+ ReplaceText( onlyOnceOperations );
+
// Operations that need to be done if the size changes.
const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
REORDER );