- // Operations that need to be done if the size changes.
- mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
- LAYOUT |
- ALIGN |
- UPDATE_ACTUAL_SIZE |
- REORDER );
-
- mImpl->mControlSize = size;
- }
-
- // Make sure the model is up-to-date before layouting
- ProcessModifyEvents();
- UpdateModel( mImpl->mOperationsPending );
-
- Size layoutSize;
- bool updated = DoRelayout( mImpl->mControlSize,
- mImpl->mOperationsPending,
- layoutSize );
-
- // Do not re-do any operation until something changes.
- mImpl->mOperationsPending = NO_OPERATION;
-
- // After doing the text layout, the alignment offset to place the actor in the desired position can be calculated.
- CalculateTextAlignment( size );
-
- if( mImpl->mTextInput )
- {
- // Move the cursor, grab handle etc.
- updated = mImpl->mTextInput->ProcessInputEvents( mImpl->mControlSize, mImpl->mAlignmentOffset ) || updated;
- }
-
- return updated;
-}
-
-void Controller::ProcessModifyEvents()
-{
- std::vector<ModifyEvent>& events = mImpl->mModifyEvents;
-
- for( unsigned int i=0; i<events.size(); ++i )
- {
- if( REPLACE_TEXT == events[0].type )
- {
- // A (single) replace event should come first, otherwise we wasted time processing NOOP events
- DALI_ASSERT_DEBUG( 0 == i && "Unexpected REPLACE event" );
-
- ReplaceTextEvent( events[0].text );
- }
- else if( INSERT_TEXT == events[0].type )
- {
- InsertTextEvent( events[0].text );
- }
- else if( DELETE_TEXT == events[0].type )
- {
- DeleteTextEvent();
- }
- }
-
- // Discard temporary text
- events.clear();
-}
-
-void Controller::ReplaceTextEvent( const std::string& text )
-{
- // Reset buffers.
- mImpl->mLogicalModel->mText.Clear();
- mImpl->mLogicalModel->mScriptRuns.Clear();
- mImpl->mLogicalModel->mFontRuns.Clear();
- mImpl->mLogicalModel->mLineBreakInfo.Clear();
- mImpl->mLogicalModel->mWordBreakInfo.Clear();
- mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
- mImpl->mLogicalModel->mCharacterDirections.Clear();
- mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
- mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
- mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
- mImpl->mVisualModel->mGlyphs.Clear();
- mImpl->mVisualModel->mGlyphsToCharacters.Clear();
- mImpl->mVisualModel->mCharactersToGlyph.Clear();
- mImpl->mVisualModel->mCharactersPerGlyph.Clear();
- mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
- mImpl->mVisualModel->mGlyphPositions.Clear();
- mImpl->mVisualModel->mLines.Clear();
- mImpl->mVisualModel->ClearCaches();
-
- // Convert text into UTF-32
- Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
- utf32Characters.Resize( text.size() );
-
- // This is a bit horrible but std::string returns a (signed) char*
- const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );