2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/text-controller.h>
24 #include <dali/public-api/adaptor-framework/key.h>
25 #include <dali/integration-api/debug.h>
28 #include <dali-toolkit/internal/text/bidirectional-support.h>
29 #include <dali-toolkit/internal/text/character-set-conversion.h>
30 #include <dali-toolkit/internal/text/layouts/layout-parameters.h>
31 #include <dali-toolkit/internal/text/multi-language-support.h>
32 #include <dali-toolkit/internal/text/script-run.h>
33 #include <dali-toolkit/internal/text/segmentation.h>
34 #include <dali-toolkit/internal/text/shaper.h>
35 #include <dali-toolkit/internal/text/text-controller-impl.h>
36 #include <dali-toolkit/internal/text/text-io.h>
37 #include <dali-toolkit/internal/text/text-view.h>
42 #if defined(DEBUG_ENABLED)
43 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
46 const float MAX_FLOAT = std::numeric_limits<float>::max();
48 const std::string EMPTY_STRING("");
61 ControllerPtr Controller::New( ControlInterface& controlInterface )
63 return ControllerPtr( new Controller( controlInterface ) );
66 void Controller::EnableTextInput( DecoratorPtr decorator )
68 if( !mImpl->mEventData )
70 mImpl->mEventData = new EventData( decorator );
74 void Controller::SetText( const std::string& text )
76 // Remove the previously set text
79 CharacterIndex lastCursorIndex = 0u;
83 // Convert text into UTF-32
84 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
85 utf32Characters.Resize( text.size() );
87 // This is a bit horrible but std::string returns a (signed) char*
88 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
90 // Transform a text array encoded in utf8 into an array encoded in utf32.
91 // It returns the actual number of characters.
92 Length characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
93 utf32Characters.Resize( characterCount );
95 DALI_ASSERT_DEBUG( text.size() >= characterCount && "Invalid UTF32 conversion length" );
96 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, text.size(), mImpl->mLogicalModel->mText.Count() );
98 // To reset the cursor position
99 lastCursorIndex = characterCount;
101 // Update the rest of the model during size negotiation
102 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
104 // The natural size needs to be re-calculated.
105 mImpl->mRecalculateNaturalSize = true;
107 // Apply modifications to the model
108 mImpl->mOperationsPending = ALL_OPERATIONS;
112 ShowPlaceholderText();
115 // Resets the cursor position.
116 ResetCursorPosition( lastCursorIndex );
118 // Scrolls the text to make the cursor visible.
119 ResetScrollPosition();
121 mImpl->RequestRelayout();
123 if( mImpl->mEventData )
125 // Cancel previously queued events
126 mImpl->mEventData->mEventQueue.clear();
129 // Reset keyboard as text changed
130 mImpl->ResetImfManager();
132 // Do this last since it provides callbacks into application code
133 mImpl->mControlInterface.TextChanged();
136 void Controller::GetText( std::string& text ) const
138 if( ! mImpl->IsShowingPlaceholderText() )
140 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
142 if( 0u != utf32Characters.Count() )
144 Utf32ToUtf8( &utf32Characters[0], utf32Characters.Count(), text );
149 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::GetText %p empty (but showing placeholder)\n", this );
153 unsigned int Controller::GetLogicalCursorPosition() const
155 if( mImpl->mEventData )
157 return mImpl->mEventData->mPrimaryCursorPosition;
163 void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
165 if( mImpl->mEventData )
167 if( PLACEHOLDER_TYPE_INACTIVE == type )
169 mImpl->mEventData->mPlaceholderTextInactive = text;
173 mImpl->mEventData->mPlaceholderTextActive = text;
176 // Update placeholder if there is no text
177 if( mImpl->IsShowingPlaceholderText() ||
178 0u == mImpl->mLogicalModel->mText.Count() )
180 ShowPlaceholderText();
185 void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
187 if( mImpl->mEventData )
189 if( PLACEHOLDER_TYPE_INACTIVE == type )
191 text = mImpl->mEventData->mPlaceholderTextInactive;
195 text = mImpl->mEventData->mPlaceholderTextActive;
200 void Controller::SetMaximumNumberOfCharacters( int maxCharacters )
202 if ( maxCharacters >= 0 )
204 mImpl->mMaximumNumberOfCharacters = maxCharacters;
208 int Controller::GetMaximumNumberOfCharacters()
210 return mImpl->mMaximumNumberOfCharacters;
213 void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
215 if( !mImpl->mFontDefaults )
217 mImpl->mFontDefaults = new FontDefaults();
220 mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily;
222 // Clear the font-specific data
225 mImpl->mOperationsPending = ALL_OPERATIONS;
226 mImpl->mRecalculateNaturalSize = true;
228 mImpl->RequestRelayout();
231 const std::string& Controller::GetDefaultFontFamily() const
233 if( mImpl->mFontDefaults )
235 return mImpl->mFontDefaults->mDefaultFontFamily;
241 void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle )
243 if( !mImpl->mFontDefaults )
245 mImpl->mFontDefaults = new FontDefaults();
248 mImpl->mFontDefaults->mDefaultFontStyle = defaultFontStyle;
250 // Clear the font-specific data
253 mImpl->mOperationsPending = ALL_OPERATIONS;
254 mImpl->mRecalculateNaturalSize = true;
256 mImpl->RequestRelayout();
259 const std::string& Controller::GetDefaultFontStyle() const
261 if( mImpl->mFontDefaults )
263 return mImpl->mFontDefaults->mDefaultFontStyle;
269 void Controller::SetDefaultPointSize( float pointSize )
271 if( !mImpl->mFontDefaults )
273 mImpl->mFontDefaults = new FontDefaults();
276 mImpl->mFontDefaults->mDefaultPointSize = pointSize;
278 // Clear the font-specific data
281 mImpl->mOperationsPending = ALL_OPERATIONS;
282 mImpl->mRecalculateNaturalSize = true;
284 mImpl->RequestRelayout();
287 float Controller::GetDefaultPointSize() const
289 if( mImpl->mFontDefaults )
291 return mImpl->mFontDefaults->mDefaultPointSize;
297 void Controller::SetTextColor( const Vector4& textColor )
299 mImpl->mTextColor = textColor;
301 if( !mImpl->IsShowingPlaceholderText() )
303 mImpl->mVisualModel->SetTextColor( textColor );
305 mImpl->RequestRelayout();
309 const Vector4& Controller::GetTextColor() const
311 return mImpl->mTextColor;
314 bool Controller::RemoveText( int cursorOffset, int numberOfChars )
316 bool removed( false );
318 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfChars %d\n",
319 this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfChars );
321 if( ! mImpl->IsShowingPlaceholderText() )
323 // Delete at current cursor position
324 Vector<Character>& currentText = mImpl->mLogicalModel->mText;
325 CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
327 CharacterIndex cursorIndex = oldCursorIndex;
329 // Validate the cursor position & number of characters
330 if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex )
332 cursorIndex = oldCursorIndex + cursorOffset;
335 if( (cursorIndex + numberOfChars) > currentText.Count() )
337 numberOfChars = currentText.Count() - cursorIndex;
340 if( (cursorIndex + numberOfChars) <= currentText.Count() )
342 Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
343 Vector<Character>::Iterator last = first + numberOfChars;
345 currentText.Erase( first, last );
347 // Cursor position retreat
348 oldCursorIndex = cursorIndex;
350 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfChars );
358 void Controller::SetPlaceholderTextColor( const Vector4& textColor )
360 if( mImpl->mEventData )
362 mImpl->mEventData->mPlaceholderTextColor = textColor;
365 if( mImpl->IsShowingPlaceholderText() )
367 mImpl->mVisualModel->SetTextColor( textColor );
368 mImpl->RequestRelayout();
372 const Vector4& Controller::GetPlaceholderTextColor() const
374 if( mImpl->mEventData )
376 return mImpl->mEventData->mPlaceholderTextColor;
382 void Controller::SetShadowOffset( const Vector2& shadowOffset )
384 mImpl->mVisualModel->SetShadowOffset( shadowOffset );
386 mImpl->RequestRelayout();
389 const Vector2& Controller::GetShadowOffset() const
391 return mImpl->mVisualModel->GetShadowOffset();
394 void Controller::SetShadowColor( const Vector4& shadowColor )
396 mImpl->mVisualModel->SetShadowColor( shadowColor );
398 mImpl->RequestRelayout();
401 const Vector4& Controller::GetShadowColor() const
403 return mImpl->mVisualModel->GetShadowColor();
406 void Controller::SetUnderlineColor( const Vector4& color )
408 mImpl->mVisualModel->SetUnderlineColor( color );
410 mImpl->RequestRelayout();
413 const Vector4& Controller::GetUnderlineColor() const
415 return mImpl->mVisualModel->GetUnderlineColor();
418 void Controller::SetUnderlineEnabled( bool enabled )
420 mImpl->mVisualModel->SetUnderlineEnabled( enabled );
422 mImpl->RequestRelayout();
425 bool Controller::IsUnderlineEnabled() const
427 return mImpl->mVisualModel->IsUnderlineEnabled();
430 void Controller::SetUnderlineHeight( float height )
432 mImpl->mVisualModel->SetUnderlineHeight( height );
434 mImpl->RequestRelayout();
437 float Controller::GetUnderlineHeight() const
439 return mImpl->mVisualModel->GetUnderlineHeight();
442 void Controller::SetEnableCursorBlink( bool enable )
444 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
446 if( mImpl->mEventData )
448 mImpl->mEventData->mCursorBlinkEnabled = enable;
451 mImpl->mEventData->mDecorator )
453 mImpl->mEventData->mDecorator->StopCursorBlink();
458 bool Controller::GetEnableCursorBlink() const
460 if( mImpl->mEventData )
462 return mImpl->mEventData->mCursorBlinkEnabled;
468 const Vector2& Controller::GetScrollPosition() const
470 if( mImpl->mEventData )
472 return mImpl->mEventData->mScrollPosition;
475 return Vector2::ZERO;
478 const Vector2& Controller::GetAlignmentOffset() const
480 return mImpl->mAlignmentOffset;
483 Vector3 Controller::GetNaturalSize()
485 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
488 // Make sure the model is up-to-date before layouting
489 ProcessModifyEvents();
491 if( mImpl->mRecalculateNaturalSize )
493 // Operations that can be done only once until the text changes.
494 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
502 // Make sure the model is up-to-date before layouting
503 mImpl->UpdateModel( onlyOnceOperations );
505 // Operations that need to be done if the size changes.
506 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
510 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
511 static_cast<OperationsMask>( onlyOnceOperations |
513 naturalSize.GetVectorXY() );
515 // Do not do again the only once operations.
516 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
518 // Do the size related operations again.
519 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
521 // Stores the natural size to avoid recalculate it again
522 // unless the text/style changes.
523 mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
525 mImpl->mRecalculateNaturalSize = false;
527 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
531 naturalSize = mImpl->mVisualModel->GetNaturalSize();
533 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
539 float Controller::GetHeightForWidth( float width )
541 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", this, width );
542 // Make sure the model is up-to-date before layouting
543 ProcessModifyEvents();
546 if( width != mImpl->mControlSize.width )
548 // Operations that can be done only once until the text changes.
549 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
557 // Make sure the model is up-to-date before layouting
558 mImpl->UpdateModel( onlyOnceOperations );
560 // Operations that need to be done if the size changes.
561 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
565 DoRelayout( Size( width, MAX_FLOAT ),
566 static_cast<OperationsMask>( onlyOnceOperations |
570 // Do not do again the only once operations.
571 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
573 // Do the size related operations again.
574 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
575 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
579 layoutSize = mImpl->mVisualModel->GetActualSize();
580 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
583 return layoutSize.height;
586 bool Controller::Relayout( const Size& size )
588 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f\n", this, size.width, size.height );
590 if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
592 bool glyphsRemoved( false );
593 if( 0u != mImpl->mVisualModel->GetNumberOfGlyphPositions() )
595 mImpl->mVisualModel->SetGlyphPositions( NULL, 0u );
596 glyphsRemoved = true;
598 // Not worth to relayout if width or height is equal to zero.
599 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
600 return glyphsRemoved;
603 if( size != mImpl->mControlSize )
605 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mControlSize.width, mImpl->mControlSize.height );
607 // Operations that need to be done if the size changes.
608 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
614 mImpl->mControlSize = size;
617 // Make sure the model is up-to-date before layouting
618 ProcessModifyEvents();
619 mImpl->UpdateModel( mImpl->mOperationsPending );
622 bool updated = DoRelayout( mImpl->mControlSize,
623 mImpl->mOperationsPending,
626 // Do not re-do any operation until something changes.
627 mImpl->mOperationsPending = NO_OPERATION;
629 // After doing the text layout, the alignment offset to place the actor in the desired position can be calculated.
630 CalculateTextAlignment( size );
632 if( mImpl->mEventData )
634 // Move the cursor, grab handle etc.
635 updated = mImpl->ProcessInputEvents() || updated;
638 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
642 void Controller::ProcessModifyEvents()
644 std::vector<ModifyEvent>& events = mImpl->mModifyEvents;
646 for( unsigned int i=0; i<events.size(); ++i )
648 if( ModifyEvent::TEXT_REPLACED == events[0].type )
650 // A (single) replace event should come first, otherwise we wasted time processing NOOP events
651 DALI_ASSERT_DEBUG( 0 == i && "Unexpected TEXT_REPLACED event" );
655 else if( ModifyEvent::TEXT_INSERTED == events[0].type )
659 else if( ModifyEvent::TEXT_DELETED == events[0].type )
661 // Placeholder-text cannot be deleted
662 if( !mImpl->IsShowingPlaceholderText() )
669 // Discard temporary text
673 void Controller::ResetText()
676 mImpl->mLogicalModel->mText.Clear();
679 // We have cleared everything including the placeholder-text
680 mImpl->PlaceholderCleared();
682 // The natural size needs to be re-calculated.
683 mImpl->mRecalculateNaturalSize = true;
685 // Apply modifications to the model
686 mImpl->mOperationsPending = ALL_OPERATIONS;
689 void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
691 // Reset the cursor position
692 if( NULL != mImpl->mEventData )
694 mImpl->mEventData->mPrimaryCursorPosition = cursorIndex;
696 // Update the cursor if it's in editing mode.
697 if( ( EventData::EDITING == mImpl->mEventData->mState ) ||
698 ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) )
700 mImpl->mEventData->mUpdateCursorPosition = true;
705 void Controller::ResetScrollPosition()
707 if( NULL != mImpl->mEventData )
709 // Reset the scroll position.
710 mImpl->mEventData->mScrollPosition = Vector2::ZERO;
711 mImpl->mEventData->mScrollAfterUpdatePosition = true;
715 void Controller::TextReplacedEvent()
720 // The natural size needs to be re-calculated.
721 mImpl->mRecalculateNaturalSize = true;
723 // Apply modifications to the model
724 mImpl->mOperationsPending = ALL_OPERATIONS;
725 mImpl->UpdateModel( ALL_OPERATIONS );
726 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
732 void Controller::TextInsertedEvent()
734 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
736 // TODO - Optimize this
739 // The natural size needs to be re-calculated.
740 mImpl->mRecalculateNaturalSize = true;
742 // Apply modifications to the model; TODO - Optimize this
743 mImpl->mOperationsPending = ALL_OPERATIONS;
744 mImpl->UpdateModel( ALL_OPERATIONS );
745 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
750 // Queue a cursor reposition event; this must wait until after DoRelayout()
751 mImpl->mEventData->mUpdateCursorPosition = true;
752 mImpl->mEventData->mScrollAfterUpdatePosition = true;
755 void Controller::TextDeletedEvent()
757 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
759 // TODO - Optimize this
762 // The natural size needs to be re-calculated.
763 mImpl->mRecalculateNaturalSize = true;
765 // Apply modifications to the model; TODO - Optimize this
766 mImpl->mOperationsPending = ALL_OPERATIONS;
767 mImpl->UpdateModel( ALL_OPERATIONS );
768 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
773 // Queue a cursor reposition event; this must wait until after DoRelayout()
774 mImpl->mEventData->mScrollAfterDelete = true;
777 bool Controller::DoRelayout( const Size& size,
778 OperationsMask operationsRequired,
781 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
782 bool viewUpdated( false );
784 // Calculate the operations to be done.
785 const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
787 if( LAYOUT & operations )
789 // Some vectors with data needed to layout and reorder may be void
790 // after the first time the text has been laid out.
791 // Fill the vectors again.
793 Length numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
795 if( 0u == numberOfGlyphs )
797 // Nothing else to do if there is no glyphs.
798 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
802 Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
803 Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
804 Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
805 Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
806 Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
807 Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
809 // Set the layout parameters.
810 LayoutParameters layoutParameters( size,
811 mImpl->mLogicalModel->mText.Begin(),
812 lineBreakInfo.Begin(),
813 wordBreakInfo.Begin(),
814 ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
817 glyphsToCharactersMap.Begin(),
818 charactersPerGlyph.Begin() );
820 // The laid-out lines.
821 // It's not possible to know in how many lines the text is going to be laid-out,
822 // but it can be resized at least with the number of 'paragraphs' to avoid
823 // some re-allocations.
824 Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
826 // Delete any previous laid out lines before setting the new ones.
829 // The capacity of the bidirectional paragraph info is the number of paragraphs.
830 lines.Reserve( mImpl->mLogicalModel->mBidirectionalParagraphInfo.Capacity() );
832 // Resize the vector of positions to have the same size than the vector of glyphs.
833 Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
834 glyphPositions.Resize( numberOfGlyphs );
836 // Update the visual model.
837 viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
845 if( REORDER & operations )
847 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
849 // Check first if there are paragraphs with bidirectional info.
850 if( 0u != bidirectionalInfo.Count() )
853 const Length numberOfLines = mImpl->mVisualModel->GetNumberOfLines();
855 // Reorder the lines.
856 Vector<BidirectionalLineInfoRun> lineBidirectionalInfoRuns;
857 lineBidirectionalInfoRuns.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
858 ReorderLines( bidirectionalInfo,
860 lineBidirectionalInfoRuns );
862 // Set the bidirectional info into the model.
863 const Length numberOfBidirectionalInfoRuns = lineBidirectionalInfoRuns.Count();
864 mImpl->mLogicalModel->SetVisualToLogicalMap( lineBidirectionalInfoRuns.Begin(),
865 numberOfBidirectionalInfoRuns );
867 // Set the bidirectional info per line into the layout parameters.
868 layoutParameters.lineBidirectionalInfoRunsBuffer = lineBidirectionalInfoRuns.Begin();
869 layoutParameters.numberOfBidirectionalInfoRuns = numberOfBidirectionalInfoRuns;
871 // Get the character to glyph conversion table and set into the layout.
872 layoutParameters.charactersToGlyphsBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin();
874 // Get the glyphs per character table and set into the layout.
875 layoutParameters.glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin();
877 // Re-layout the text. Reorder those lines with right to left characters.
878 mImpl->mLayoutEngine.ReLayoutRightToLeftLines( layoutParameters,
881 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
882 for( Vector<BidirectionalLineInfoRun>::Iterator it = lineBidirectionalInfoRuns.Begin(),
883 endIt = lineBidirectionalInfoRuns.End();
887 BidirectionalLineInfoRun& bidiLineInfo = *it;
889 free( bidiLineInfo.visualToLogicalMap );
894 // Sets the actual size.
895 if( UPDATE_ACTUAL_SIZE & operations )
897 mImpl->mVisualModel->SetActualSize( layoutSize );
903 layoutSize = mImpl->mVisualModel->GetActualSize();
906 if( ALIGN & operations )
908 // The laid-out lines.
909 Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
911 mImpl->mLayoutEngine.Align( layoutSize,
917 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
921 void Controller::SetMultiLineEnabled( bool enable )
923 const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
925 if( layout != mImpl->mLayoutEngine.GetLayout() )
927 // Set the layout type.
928 mImpl->mLayoutEngine.SetLayout( layout );
930 // Set the flags to redo the layout operations
931 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
936 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
938 mImpl->RequestRelayout();
942 bool Controller::IsMultiLineEnabled() const
944 return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
947 void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
949 if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
951 // Set the alignment.
952 mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
954 // Set the flag to redo the alignment operation.
955 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
957 mImpl->RequestRelayout();
961 LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
963 return mImpl->mLayoutEngine.GetHorizontalAlignment();
966 void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
968 if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
970 // Set the alignment.
971 mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
973 // Set the flag to redo the alignment operation.
974 // TODO : Is not needed re-layout and reorder again but with the current implementation it is.
975 // Im working on a different patch to fix an issue with the alignment. When that patch
976 // is in, this issue can be fixed.
977 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
982 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
984 mImpl->RequestRelayout();
988 LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
990 return mImpl->mLayoutEngine.GetVerticalAlignment();
993 void Controller::CalculateTextAlignment( const Size& size )
995 // Get the direction of the first character.
996 const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
998 const Size& actualSize = mImpl->mVisualModel->GetActualSize();
1000 // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
1001 LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
1002 if( firstParagraphDirection &&
1003 ( LayoutEngine::HORIZONTAL_ALIGN_CENTER != horizontalAlignment ) )
1005 if( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == horizontalAlignment )
1007 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_END;
1011 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_BEGIN;
1015 switch( horizontalAlignment )
1017 case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
1019 mImpl->mAlignmentOffset.x = 0.f;
1022 case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
1024 const int intOffset = static_cast<int>( 0.5f * ( size.width - actualSize.width ) ); // try to avoid pixel alignment.
1025 mImpl->mAlignmentOffset.x = static_cast<float>( intOffset );
1028 case LayoutEngine::HORIZONTAL_ALIGN_END:
1030 mImpl->mAlignmentOffset.x = size.width - actualSize.width;
1035 const LayoutEngine::VerticalAlignment verticalAlignment = mImpl->mLayoutEngine.GetVerticalAlignment();
1036 switch( verticalAlignment )
1038 case LayoutEngine::VERTICAL_ALIGN_TOP:
1040 mImpl->mAlignmentOffset.y = 0.f;
1043 case LayoutEngine::VERTICAL_ALIGN_CENTER:
1045 const int intOffset = static_cast<int>( 0.5f * ( size.height - actualSize.height ) ); // try to avoid pixel alignment.
1046 mImpl->mAlignmentOffset.y = static_cast<float>( intOffset );
1049 case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
1051 mImpl->mAlignmentOffset.y = size.height - actualSize.height;
1057 LayoutEngine& Controller::GetLayoutEngine()
1059 return mImpl->mLayoutEngine;
1062 View& Controller::GetView()
1064 return mImpl->mView;
1067 void Controller::KeyboardFocusGainEvent()
1069 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
1071 if( mImpl->mEventData )
1073 mImpl->ChangeState( EventData::EDITING );
1075 if( mImpl->IsShowingPlaceholderText() )
1077 // Show alternative placeholder-text when editing
1078 ShowPlaceholderText();
1081 mImpl->RequestRelayout();
1085 void Controller::KeyboardFocusLostEvent()
1087 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
1089 if( mImpl->mEventData )
1091 mImpl->ChangeState( EventData::INACTIVE );
1093 if( mImpl->IsShowingPlaceholderText() )
1095 // Revert to regular placeholder-text when not editing
1096 ShowPlaceholderText();
1099 mImpl->RequestRelayout();
1103 bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
1105 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
1107 bool textChanged( false );
1109 if( mImpl->mEventData &&
1110 keyEvent.state == KeyEvent::Down )
1112 int keyCode = keyEvent.keyCode;
1113 const std::string& keyString = keyEvent.keyPressed;
1115 // Hide the grab handle.
1116 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
1118 // Pre-process to separate modifying events from non-modifying input events.
1119 if( Dali::DALI_KEY_ESCAPE == keyCode )
1121 // Escape key is a special case which causes focus loss
1122 KeyboardFocusLostEvent();
1124 else if( Dali::DALI_KEY_CURSOR_LEFT == keyCode ||
1125 Dali::DALI_KEY_CURSOR_RIGHT == keyCode ||
1126 Dali::DALI_KEY_CURSOR_UP == keyCode ||
1127 Dali::DALI_KEY_CURSOR_DOWN == keyCode )
1129 Event event( Event::CURSOR_KEY_EVENT );
1130 event.p1.mInt = keyCode;
1131 mImpl->mEventData->mEventQueue.push_back( event );
1133 else if( Dali::DALI_KEY_BACKSPACE == keyCode )
1135 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE\n", this );
1137 // IMF manager is no longer handling key-events
1138 mImpl->ClearPreEditFlag();
1140 // Remove the character before the current cursor position
1141 bool removed = RemoveText( -1, 1 );
1145 if( 0u != mImpl->mLogicalModel->mText.Count() ||
1146 !mImpl->IsPlaceholderAvailable() )
1148 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
1152 ShowPlaceholderText();
1153 mImpl->mEventData->mUpdateCursorPosition = true;
1161 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
1163 // IMF manager is no longer handling key-events
1164 mImpl->ClearPreEditFlag();
1166 InsertText( keyString, COMMIT );
1171 mImpl->ChangeState( EventData::EDITING ); // todo Confirm this is the best place to change the state of
1173 mImpl->RequestRelayout();
1178 // Do this last since it provides callbacks into application code
1179 mImpl->mControlInterface.TextChanged();
1185 void Controller::InsertText( const std::string& text, Controller::InsertType type )
1187 bool removedPreEdit( false );
1188 bool maxLengthReached( false );
1190 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" )
1191 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n",
1192 this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
1193 mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1195 Vector<Character> utf32Characters;
1196 Length characterCount( 0u );
1198 if( ! text.empty() )
1200 // The placeholder text is no longer needed
1201 if( mImpl->IsShowingPlaceholderText() )
1206 // Convert text into UTF-32
1207 utf32Characters.Resize( text.size() );
1209 // This is a bit horrible but std::string returns a (signed) char*
1210 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
1212 // Transform a text array encoded in utf8 into an array encoded in utf32.
1213 // It returns the actual number of characters.
1214 characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
1215 utf32Characters.Resize( characterCount );
1217 DALI_ASSERT_DEBUG( text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length" );
1218 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count() );
1221 if( 0u != utf32Characters.Count() )
1223 // Handle the IMF (predicitive text) state changes
1224 if( mImpl->mEventData )
1226 if( mImpl->mEventData->mPreEditFlag &&
1227 0 != mImpl->mEventData->mPreEditLength )
1229 // Remove previous pre-edit text
1230 CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
1231 removedPreEdit = RemoveText( -static_cast<int>(offset), mImpl->mEventData->mPreEditLength );
1233 mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
1234 mImpl->mEventData->mPreEditLength = 0;
1237 if( COMMIT == type )
1239 // IMF manager is no longer handling key-events
1240 mImpl->ClearPreEditFlag();
1244 if( ! mImpl->mEventData->mPreEditFlag )
1246 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state" );
1248 // Record the start of the pre-edit text
1249 mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
1252 mImpl->mEventData->mPreEditLength = utf32Characters.Count();
1253 mImpl->mEventData->mPreEditFlag = true;
1255 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1259 const Length numberOfCharactersInModel = mImpl->mLogicalModel->GetNumberOfCharacters();
1261 // Restrict new text to fit within Maximum characters setting
1262 Length maxSizeOfNewText = std::min ( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
1263 maxLengthReached = ( characterCount > maxSizeOfNewText );
1265 // Insert at current cursor position
1266 CharacterIndex& cursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
1268 Vector<Character>& modifyText = mImpl->mLogicalModel->mText;
1270 if( cursorIndex < numberOfCharactersInModel )
1272 modifyText.Insert( modifyText.Begin() + cursorIndex, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1276 modifyText.Insert( modifyText.End(), utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1279 cursorIndex += maxSizeOfNewText;
1281 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
1284 if( removedPreEdit ||
1285 0 != utf32Characters.Count() )
1287 // Queue an inserted event
1288 mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
1291 if( maxLengthReached )
1293 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mLogicalModel->mText.Count() );
1295 mImpl->ResetImfManager();
1297 // Do this last since it provides callbacks into application code
1298 mImpl->mControlInterface.MaxLengthReached();
1302 void Controller::TapEvent( unsigned int tapCount, float x, float y )
1304 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
1306 if( NULL != mImpl->mEventData )
1308 const bool isShowingPlaceholderText = mImpl->IsShowingPlaceholderText();
1309 if( 1u == tapCount )
1311 bool tapDuringEditMode( EventData::EDITING == mImpl->mEventData->mState );
1313 if( !isShowingPlaceholderText && tapDuringEditMode )
1315 // Grab handle is not shown until a tap is received whilst EDITING
1316 if( tapDuringEditMode )
1318 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
1320 mImpl->mEventData->mDecorator->SetPopupActive( false );
1323 mImpl->ChangeState( EventData::EDITING );
1325 else if( !isShowingPlaceholderText &&
1326 mImpl->mEventData->mSelectionEnabled &&
1327 ( 2u == tapCount ) )
1329 mImpl->ChangeState( EventData::SELECTING );
1333 // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
1334 if( mImpl->mEventData )
1336 Event event( Event::TAP_EVENT );
1337 event.p1.mUint = tapCount;
1338 event.p2.mFloat = x;
1339 event.p3.mFloat = y;
1340 mImpl->mEventData->mEventQueue.push_back( event );
1342 mImpl->RequestRelayout();
1345 // Reset keyboard as tap event has occurred.
1346 mImpl->ResetImfManager();
1349 void Controller::PanEvent( Gesture::State state, const Vector2& displacement )
1351 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
1353 if( mImpl->mEventData )
1355 Event event( Event::PAN_EVENT );
1356 event.p1.mInt = state;
1357 event.p2.mFloat = displacement.x;
1358 event.p3.mFloat = displacement.y;
1359 mImpl->mEventData->mEventQueue.push_back( event );
1361 mImpl->RequestRelayout();
1365 void Controller::GetTargetSize( Vector2& targetSize )
1367 targetSize = mImpl->mControlSize;
1370 void Controller::AddDecoration( Actor& actor, bool needsClipping )
1372 mImpl->mControlInterface.AddDecoration( actor, needsClipping );
1375 void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
1377 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
1379 if( mImpl->mEventData )
1381 switch( handleType )
1385 Event event( Event::GRAB_HANDLE_EVENT );
1386 event.p1.mUint = state;
1387 event.p2.mFloat = x;
1388 event.p3.mFloat = y;
1390 mImpl->mEventData->mEventQueue.push_back( event );
1393 case LEFT_SELECTION_HANDLE:
1395 Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
1396 event.p1.mUint = state;
1397 event.p2.mFloat = x;
1398 event.p3.mFloat = y;
1400 mImpl->mEventData->mEventQueue.push_back( event );
1403 case RIGHT_SELECTION_HANDLE:
1405 Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
1406 event.p1.mUint = state;
1407 event.p2.mFloat = x;
1408 event.p3.mFloat = y;
1410 mImpl->mEventData->mEventQueue.push_back( event );
1413 case HANDLE_TYPE_COUNT:
1415 DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
1419 mImpl->RequestRelayout();
1423 ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1425 bool update( false );
1426 bool requestRelayout = false;
1429 unsigned int cursorPosition( 0 );
1431 switch ( imfEvent.eventName )
1433 case ImfManager::COMMIT:
1435 InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
1436 requestRelayout = true;
1439 case ImfManager::PREEDIT:
1441 InsertText( imfEvent.predictiveString, Text::Controller::PRE_EDIT );
1443 requestRelayout = true;
1446 case ImfManager::DELETESURROUNDING:
1448 RemoveText( imfEvent.cursorOffset, imfEvent.numberOfChars );
1449 requestRelayout = true;
1452 case ImfManager::GETSURROUNDING:
1455 cursorPosition = GetLogicalCursorPosition();
1457 imfManager.SetSurroundingText( text );
1458 imfManager.SetCursorPosition( cursorPosition );
1461 case ImfManager::VOID:
1468 if( ImfManager::GETSURROUNDING != imfEvent.eventName )
1471 cursorPosition = GetLogicalCursorPosition();
1474 if( requestRelayout )
1476 mImpl->mOperationsPending = ALL_OPERATIONS;
1477 mImpl->RequestRelayout();
1479 // Do this last since it provides callbacks into application code
1480 mImpl->mControlInterface.TextChanged();
1483 ImfManager::ImfCallbackData callbackData( update, cursorPosition, text, false );
1485 return callbackData;
1489 Controller::~Controller()
1494 void Controller::ShowPlaceholderText()
1496 if( mImpl->IsPlaceholderAvailable() )
1498 DALI_ASSERT_DEBUG( mImpl->mEventData && "No placeholder text available" );
1500 mImpl->mEventData->mIsShowingPlaceholderText = true;
1502 // Disable handles when showing place-holder text
1503 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
1504 mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
1505 mImpl->mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
1507 const char* text( NULL );
1510 // TODO - Switch placeholder text styles when changing state
1511 if( EventData::INACTIVE != mImpl->mEventData->mState &&
1512 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() )
1514 text = mImpl->mEventData->mPlaceholderTextActive.c_str();
1515 size = mImpl->mEventData->mPlaceholderTextActive.size();
1519 text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
1520 size = mImpl->mEventData->mPlaceholderTextInactive.size();
1523 // Reset model for showing placeholder.
1524 mImpl->mLogicalModel->mText.Clear();
1526 mImpl->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
1528 // Convert text into UTF-32
1529 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
1530 utf32Characters.Resize( size );
1532 // This is a bit horrible but std::string returns a (signed) char*
1533 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text );
1535 // Transform a text array encoded in utf8 into an array encoded in utf32.
1536 // It returns the actual number of characters.
1537 Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
1538 utf32Characters.Resize( characterCount );
1540 // Reset the cursor position
1541 mImpl->mEventData->mPrimaryCursorPosition = 0;
1543 // The natural size needs to be re-calculated.
1544 mImpl->mRecalculateNaturalSize = true;
1546 // Apply modifications to the model
1547 mImpl->mOperationsPending = ALL_OPERATIONS;
1549 // Update the rest of the model during size negotiation
1550 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
1554 void Controller::ClearModelData()
1556 // n.b. This does not Clear the mText from mLogicalModel
1557 mImpl->mLogicalModel->mScriptRuns.Clear();
1558 mImpl->mLogicalModel->mFontRuns.Clear();
1559 mImpl->mLogicalModel->mLineBreakInfo.Clear();
1560 mImpl->mLogicalModel->mWordBreakInfo.Clear();
1561 mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
1562 mImpl->mLogicalModel->mCharacterDirections.Clear();
1563 mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
1564 mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
1565 mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
1566 mImpl->mVisualModel->mGlyphs.Clear();
1567 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1568 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1569 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1570 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1571 mImpl->mVisualModel->mGlyphPositions.Clear();
1572 mImpl->mVisualModel->mLines.Clear();
1573 mImpl->mVisualModel->ClearCaches();
1576 void Controller::ClearFontData()
1578 mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
1579 mImpl->mLogicalModel->mFontRuns.Clear();
1580 mImpl->mVisualModel->mGlyphs.Clear();
1581 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1582 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1583 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1584 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1585 mImpl->mVisualModel->mGlyphPositions.Clear();
1586 mImpl->mVisualModel->mLines.Clear();
1587 mImpl->mVisualModel->ClearCaches();
1590 Controller::Controller( ControlInterface& controlInterface )
1593 mImpl = new Controller::Impl( controlInterface );
1598 } // namespace Toolkit