Change-Id: I55ed27274e9665ea0a1421d804cc021993be009a
mImpl->mControlSize = size;
}
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,
Size layoutSize;
bool updated = DoRelayout( mImpl->mControlSize,
mImpl->mOperationsPending,
-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 );
// 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
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.
bidirectionalInfo.Reserve( numberOfParagraphs );
// Calculates the bidirectional info for the whole paragraph if it contains right to left scripts.
charactersPerGlyph.Begin(),
numberOfGlyphs );
}
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 )
{
if( LAYOUT & operations )
{
// Fill the vectors again.
const Length numberOfCharacters = mImpl->mLogicalModel->GetNumberOfCharacters();
// 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(),
- }
-
- if( 0u == charactersPerGlyph.Count() )
- {
- charactersPerGlyph.Resize( numberOfGlyphs );
- mImpl->mVisualModel->GetCharactersPerGlyphMap( charactersPerGlyph.Begin(),
- 0u,
- numberOfGlyphs );
- }
// Set the layout parameters.
LayoutParameters layoutParameters( size,
// Set the layout parameters.
LayoutParameters layoutParameters( size,
{
const Length numberOfBidiParagraphs = mImpl->mLogicalModel->GetNumberOfBidirectionalInfoRuns( 0u, numberOfCharacters );
{
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() )
// Check first if there are paragraphs with bidirectional info.
if( 0u != bidirectionalInfo.Count() )
GET_WORD_BREAKS |
SHAPE_TEXT |
GET_GLYPH_METRICS );
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 |
// Operations that need to be done if the size changes.
const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
SHAPE_TEXT |
GET_GLYPH_METRICS );
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 );
// Operations that need to be done if the size changes.
const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
REORDER );
bool Relayout( const Vector2& size );
/**
bool Relayout( const Vector2& size );
/**
+ * @brief Update the model with new text.
+ *
+ * @param[in] operations The layout operations which need to be done.
+ */
+ void ReplaceText( OperationsMask operations );
+
+ /**
* @brief Lays-out the text.
*
* GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
* @brief Lays-out the text.
*
* GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.