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 >= 0 &&
341 (cursorIndex + numberOfChars) <= currentText.Count() )
343 Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
344 Vector<Character>::Iterator last = first + numberOfChars;
346 currentText.Erase( first, last );
348 // Cursor position retreat
349 oldCursorIndex = cursorIndex;
351 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfChars );
359 void Controller::SetPlaceholderTextColor( const Vector4& textColor )
361 if( mImpl->mEventData )
363 mImpl->mEventData->mPlaceholderTextColor = textColor;
366 if( mImpl->IsShowingPlaceholderText() )
368 mImpl->mVisualModel->SetTextColor( textColor );
369 mImpl->RequestRelayout();
373 const Vector4& Controller::GetPlaceholderTextColor() const
375 if( mImpl->mEventData )
377 return mImpl->mEventData->mPlaceholderTextColor;
383 void Controller::SetShadowOffset( const Vector2& shadowOffset )
385 mImpl->mVisualModel->SetShadowOffset( shadowOffset );
387 mImpl->RequestRelayout();
390 const Vector2& Controller::GetShadowOffset() const
392 return mImpl->mVisualModel->GetShadowOffset();
395 void Controller::SetShadowColor( const Vector4& shadowColor )
397 mImpl->mVisualModel->SetShadowColor( shadowColor );
399 mImpl->RequestRelayout();
402 const Vector4& Controller::GetShadowColor() const
404 return mImpl->mVisualModel->GetShadowColor();
407 void Controller::SetUnderlineColor( const Vector4& color )
409 mImpl->mVisualModel->SetUnderlineColor( color );
411 mImpl->RequestRelayout();
414 const Vector4& Controller::GetUnderlineColor() const
416 return mImpl->mVisualModel->GetUnderlineColor();
419 void Controller::SetUnderlineEnabled( bool enabled )
421 mImpl->mVisualModel->SetUnderlineEnabled( enabled );
423 mImpl->RequestRelayout();
426 bool Controller::IsUnderlineEnabled() const
428 return mImpl->mVisualModel->IsUnderlineEnabled();
431 void Controller::SetUnderlineHeight( float height )
433 mImpl->mVisualModel->SetUnderlineHeight( height );
435 mImpl->RequestRelayout();
438 float Controller::GetUnderlineHeight() const
440 return mImpl->mVisualModel->GetUnderlineHeight();
443 void Controller::SetEnableCursorBlink( bool enable )
445 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
447 if( mImpl->mEventData )
449 mImpl->mEventData->mCursorBlinkEnabled = enable;
452 mImpl->mEventData->mDecorator )
454 mImpl->mEventData->mDecorator->StopCursorBlink();
459 bool Controller::GetEnableCursorBlink() const
461 if( mImpl->mEventData )
463 return mImpl->mEventData->mCursorBlinkEnabled;
469 const Vector2& Controller::GetScrollPosition() const
471 if( mImpl->mEventData )
473 return mImpl->mEventData->mScrollPosition;
476 return Vector2::ZERO;
479 const Vector2& Controller::GetAlignmentOffset() const
481 return mImpl->mAlignmentOffset;
484 Vector3 Controller::GetNaturalSize()
486 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
489 // Make sure the model is up-to-date before layouting
490 ProcessModifyEvents();
492 if( mImpl->mRecalculateNaturalSize )
494 // Operations that can be done only once until the text changes.
495 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
503 // Make sure the model is up-to-date before layouting
504 mImpl->UpdateModel( onlyOnceOperations );
506 // Operations that need to be done if the size changes.
507 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
511 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
512 static_cast<OperationsMask>( onlyOnceOperations |
514 naturalSize.GetVectorXY() );
516 // Do not do again the only once operations.
517 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
519 // Do the size related operations again.
520 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
522 // Stores the natural size to avoid recalculate it again
523 // unless the text/style changes.
524 mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
526 mImpl->mRecalculateNaturalSize = false;
528 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
532 naturalSize = mImpl->mVisualModel->GetNaturalSize();
534 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
540 float Controller::GetHeightForWidth( float width )
542 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", this, width );
543 // Make sure the model is up-to-date before layouting
544 ProcessModifyEvents();
547 if( width != mImpl->mControlSize.width )
549 // Operations that can be done only once until the text changes.
550 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
558 // Make sure the model is up-to-date before layouting
559 mImpl->UpdateModel( onlyOnceOperations );
561 // Operations that need to be done if the size changes.
562 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
566 DoRelayout( Size( width, MAX_FLOAT ),
567 static_cast<OperationsMask>( onlyOnceOperations |
571 // Do not do again the only once operations.
572 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
574 // Do the size related operations again.
575 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
576 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
580 layoutSize = mImpl->mVisualModel->GetActualSize();
581 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
584 return layoutSize.height;
587 bool Controller::Relayout( const Size& size )
589 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f\n", this, size.width, size.height );
591 if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
593 bool glyphsRemoved( false );
594 if( 0u != mImpl->mVisualModel->GetNumberOfGlyphPositions() )
596 mImpl->mVisualModel->SetGlyphPositions( NULL, 0u );
597 glyphsRemoved = true;
599 // Not worth to relayout if width or height is equal to zero.
600 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
601 return glyphsRemoved;
604 if( size != mImpl->mControlSize )
606 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mControlSize.width, mImpl->mControlSize.height );
608 // Operations that need to be done if the size changes.
609 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
615 mImpl->mControlSize = size;
618 // Make sure the model is up-to-date before layouting
619 ProcessModifyEvents();
620 mImpl->UpdateModel( mImpl->mOperationsPending );
623 bool updated = DoRelayout( mImpl->mControlSize,
624 mImpl->mOperationsPending,
627 // Do not re-do any operation until something changes.
628 mImpl->mOperationsPending = NO_OPERATION;
630 // After doing the text layout, the alignment offset to place the actor in the desired position can be calculated.
631 CalculateTextAlignment( size );
633 if( mImpl->mEventData )
635 // Move the cursor, grab handle etc.
636 updated = mImpl->ProcessInputEvents() || updated;
639 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
643 void Controller::ProcessModifyEvents()
645 std::vector<ModifyEvent>& events = mImpl->mModifyEvents;
647 for( unsigned int i=0; i<events.size(); ++i )
649 if( ModifyEvent::TEXT_REPLACED == events[0].type )
651 // A (single) replace event should come first, otherwise we wasted time processing NOOP events
652 DALI_ASSERT_DEBUG( 0 == i && "Unexpected TEXT_REPLACED event" );
656 else if( ModifyEvent::TEXT_INSERTED == events[0].type )
660 else if( ModifyEvent::TEXT_DELETED == events[0].type )
662 // Placeholder-text cannot be deleted
663 if( !mImpl->IsShowingPlaceholderText() )
670 // Discard temporary text
674 void Controller::ResetText()
677 mImpl->mLogicalModel->mText.Clear();
680 // We have cleared everything including the placeholder-text
681 mImpl->PlaceholderCleared();
683 // The natural size needs to be re-calculated.
684 mImpl->mRecalculateNaturalSize = true;
686 // Apply modifications to the model
687 mImpl->mOperationsPending = ALL_OPERATIONS;
690 void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
692 // Reset the cursor position
693 if( NULL != mImpl->mEventData )
695 mImpl->mEventData->mPrimaryCursorPosition = cursorIndex;
697 // Update the cursor if it's in editing mode.
698 if( ( EventData::EDITING == mImpl->mEventData->mState ) ||
699 ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) )
701 mImpl->mEventData->mUpdateCursorPosition = true;
706 void Controller::ResetScrollPosition()
708 if( NULL != mImpl->mEventData )
710 // Reset the scroll position.
711 mImpl->mEventData->mScrollPosition = Vector2::ZERO;
712 mImpl->mEventData->mScrollAfterUpdateCursorPosition = true;
716 void Controller::TextReplacedEvent()
721 // The natural size needs to be re-calculated.
722 mImpl->mRecalculateNaturalSize = true;
724 // Apply modifications to the model
725 mImpl->mOperationsPending = ALL_OPERATIONS;
726 mImpl->UpdateModel( ALL_OPERATIONS );
727 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
733 void Controller::TextInsertedEvent()
735 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
737 // TODO - Optimize this
740 // The natural size needs to be re-calculated.
741 mImpl->mRecalculateNaturalSize = true;
743 // Apply modifications to the model; TODO - Optimize this
744 mImpl->mOperationsPending = ALL_OPERATIONS;
745 mImpl->UpdateModel( ALL_OPERATIONS );
746 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
751 // Queue a cursor reposition event; this must wait until after DoRelayout()
752 mImpl->mEventData->mUpdateCursorPosition = true;
753 mImpl->mEventData->mScrollAfterUpdateCursorPosition = true;
756 void Controller::TextDeletedEvent()
758 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
760 // TODO - Optimize this
763 // The natural size needs to be re-calculated.
764 mImpl->mRecalculateNaturalSize = true;
766 // Apply modifications to the model; TODO - Optimize this
767 mImpl->mOperationsPending = ALL_OPERATIONS;
768 mImpl->UpdateModel( ALL_OPERATIONS );
769 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
774 // Queue a cursor reposition event; this must wait until after DoRelayout()
775 mImpl->mEventData->mUpdateCursorPosition = true;
776 mImpl->mEventData->mScrollAfterUpdateCursorPosition = true;
779 bool Controller::DoRelayout( const Size& size,
780 OperationsMask operationsRequired,
783 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
784 bool viewUpdated( false );
786 // Calculate the operations to be done.
787 const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
789 if( LAYOUT & operations )
791 // Some vectors with data needed to layout and reorder may be void
792 // after the first time the text has been laid out.
793 // Fill the vectors again.
795 Length numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
797 if( 0u == numberOfGlyphs )
799 // Nothing else to do if there is no glyphs.
800 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
804 Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
805 Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
806 Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
807 Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
808 Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
809 Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
811 // Set the layout parameters.
812 LayoutParameters layoutParameters( size,
813 mImpl->mLogicalModel->mText.Begin(),
814 lineBreakInfo.Begin(),
815 wordBreakInfo.Begin(),
816 ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
819 glyphsToCharactersMap.Begin(),
820 charactersPerGlyph.Begin() );
822 // The laid-out lines.
823 // It's not possible to know in how many lines the text is going to be laid-out,
824 // but it can be resized at least with the number of 'paragraphs' to avoid
825 // some re-allocations.
826 Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
828 // Delete any previous laid out lines before setting the new ones.
831 // The capacity of the bidirectional paragraph info is the number of paragraphs.
832 lines.Reserve( mImpl->mLogicalModel->mBidirectionalParagraphInfo.Capacity() );
834 // Resize the vector of positions to have the same size than the vector of glyphs.
835 Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
836 glyphPositions.Resize( numberOfGlyphs );
838 // Update the visual model.
839 viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
847 if( REORDER & operations )
849 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
851 // Check first if there are paragraphs with bidirectional info.
852 if( 0u != bidirectionalInfo.Count() )
855 const Length numberOfLines = mImpl->mVisualModel->GetNumberOfLines();
857 // Reorder the lines.
858 Vector<BidirectionalLineInfoRun> lineBidirectionalInfoRuns;
859 lineBidirectionalInfoRuns.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
860 ReorderLines( bidirectionalInfo,
862 lineBidirectionalInfoRuns );
864 // Set the bidirectional info into the model.
865 const Length numberOfBidirectionalInfoRuns = lineBidirectionalInfoRuns.Count();
866 mImpl->mLogicalModel->SetVisualToLogicalMap( lineBidirectionalInfoRuns.Begin(),
867 numberOfBidirectionalInfoRuns );
869 // Set the bidirectional info per line into the layout parameters.
870 layoutParameters.lineBidirectionalInfoRunsBuffer = lineBidirectionalInfoRuns.Begin();
871 layoutParameters.numberOfBidirectionalInfoRuns = numberOfBidirectionalInfoRuns;
873 // Get the character to glyph conversion table and set into the layout.
874 layoutParameters.charactersToGlyphsBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin();
876 // Get the glyphs per character table and set into the layout.
877 layoutParameters.glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin();
879 // Re-layout the text. Reorder those lines with right to left characters.
880 mImpl->mLayoutEngine.ReLayoutRightToLeftLines( layoutParameters,
883 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
884 for( Vector<BidirectionalLineInfoRun>::Iterator it = lineBidirectionalInfoRuns.Begin(),
885 endIt = lineBidirectionalInfoRuns.End();
889 BidirectionalLineInfoRun& bidiLineInfo = *it;
891 free( bidiLineInfo.visualToLogicalMap );
896 // TODO: I'm working on a patch that changes the LayoutEngine::Align() method.
897 // The layoutParameters is not needed and this call can be moved outside the if().
898 // Then there is no need to do the layout again to change the alignment.
899 if( ALIGN & operations )
901 mImpl->mLayoutEngine.Align( layoutParameters,
907 // Sets the actual size.
908 if( UPDATE_ACTUAL_SIZE & operations )
910 mImpl->mVisualModel->SetActualSize( layoutSize );
916 layoutSize = mImpl->mVisualModel->GetActualSize();
919 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
923 void Controller::SetMultiLineEnabled( bool enable )
925 const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
927 if( layout != mImpl->mLayoutEngine.GetLayout() )
929 // Set the layout type.
930 mImpl->mLayoutEngine.SetLayout( layout );
932 // Set the flags to redo the layout operations
933 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
938 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
940 mImpl->RequestRelayout();
944 bool Controller::IsMultiLineEnabled() const
946 return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
949 void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
951 if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
953 // Set the alignment.
954 mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
956 // Set the flag to redo the alignment operation.
957 // TODO : Is not needed re-layout and reorder again but with the current implementation it is.
958 // Im working on a different patch to fix an issue with the alignment. When that patch
959 // is in, this issue can be fixed.
960 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
965 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
967 mImpl->RequestRelayout();
971 LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
973 return mImpl->mLayoutEngine.GetHorizontalAlignment();
976 void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
978 if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
980 // Set the alignment.
981 mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
983 // Set the flag to redo the alignment operation.
984 // TODO : Is not needed re-layout and reorder again but with the current implementation it is.
985 // Im working on a different patch to fix an issue with the alignment. When that patch
986 // is in, this issue can be fixed.
987 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
992 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
994 mImpl->RequestRelayout();
998 LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
1000 return mImpl->mLayoutEngine.GetVerticalAlignment();
1003 void Controller::CalculateTextAlignment( const Size& size )
1005 // Get the direction of the first character.
1006 const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
1008 const Size& actualSize = mImpl->mVisualModel->GetActualSize();
1010 // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
1011 LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
1012 if( firstParagraphDirection &&
1013 ( LayoutEngine::HORIZONTAL_ALIGN_CENTER != horizontalAlignment ) )
1015 if( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == horizontalAlignment )
1017 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_END;
1021 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_BEGIN;
1025 switch( horizontalAlignment )
1027 case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
1029 mImpl->mAlignmentOffset.x = 0.f;
1032 case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
1034 const int intOffset = static_cast<int>( 0.5f * ( size.width - actualSize.width ) ); // try to avoid pixel alignment.
1035 mImpl->mAlignmentOffset.x = static_cast<float>( intOffset );
1038 case LayoutEngine::HORIZONTAL_ALIGN_END:
1040 mImpl->mAlignmentOffset.x = size.width - actualSize.width;
1045 const LayoutEngine::VerticalAlignment verticalAlignment = mImpl->mLayoutEngine.GetVerticalAlignment();
1046 switch( verticalAlignment )
1048 case LayoutEngine::VERTICAL_ALIGN_TOP:
1050 mImpl->mAlignmentOffset.y = 0.f;
1053 case LayoutEngine::VERTICAL_ALIGN_CENTER:
1055 const int intOffset = static_cast<int>( 0.5f * ( size.height - actualSize.height ) ); // try to avoid pixel alignment.
1056 mImpl->mAlignmentOffset.y = static_cast<float>( intOffset );
1059 case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
1061 mImpl->mAlignmentOffset.y = size.height - actualSize.height;
1067 LayoutEngine& Controller::GetLayoutEngine()
1069 return mImpl->mLayoutEngine;
1072 View& Controller::GetView()
1074 return mImpl->mView;
1077 void Controller::KeyboardFocusGainEvent()
1079 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
1081 if( mImpl->mEventData )
1083 mImpl->ChangeState( EventData::EDITING );
1085 if( mImpl->IsShowingPlaceholderText() )
1087 // Show alternative placeholder-text when editing
1088 ShowPlaceholderText();
1091 mImpl->RequestRelayout();
1095 void Controller::KeyboardFocusLostEvent()
1097 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
1099 if( mImpl->mEventData )
1101 mImpl->ChangeState( EventData::INACTIVE );
1103 if( mImpl->IsShowingPlaceholderText() )
1105 // Revert to regular placeholder-text when not editing
1106 ShowPlaceholderText();
1109 mImpl->RequestRelayout();
1113 bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
1115 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
1117 bool textChanged( false );
1119 if( mImpl->mEventData &&
1120 keyEvent.state == KeyEvent::Down )
1122 int keyCode = keyEvent.keyCode;
1123 const std::string& keyString = keyEvent.keyPressed;
1125 // Pre-process to separate modifying events from non-modifying input events.
1126 if( Dali::DALI_KEY_ESCAPE == keyCode )
1128 // Escape key is a special case which causes focus loss
1129 KeyboardFocusLostEvent();
1131 else if( Dali::DALI_KEY_CURSOR_LEFT == keyCode ||
1132 Dali::DALI_KEY_CURSOR_RIGHT == keyCode ||
1133 Dali::DALI_KEY_CURSOR_UP == keyCode ||
1134 Dali::DALI_KEY_CURSOR_DOWN == keyCode )
1136 Event event( Event::CURSOR_KEY_EVENT );
1137 event.p1.mInt = keyCode;
1138 mImpl->mEventData->mEventQueue.push_back( event );
1140 else if( Dali::DALI_KEY_BACKSPACE == keyCode )
1142 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE\n", this );
1144 // IMF manager is no longer handling key-events
1145 mImpl->ClearPreEditFlag();
1147 // Remove the character before the current cursor position
1148 bool removed = RemoveText( -1, 1 );
1152 if( 0u == mImpl->mLogicalModel->mText.Count() )
1154 ShowPlaceholderText();
1155 mImpl->mEventData->mUpdateCursorPosition = true;
1159 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
1167 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
1169 // IMF manager is no longer handling key-events
1170 mImpl->ClearPreEditFlag();
1172 InsertText( keyString, COMMIT );
1177 mImpl->ChangeState( EventData::EDITING ); // todo Confirm this is the best place to change the state of
1179 mImpl->RequestRelayout();
1184 // Do this last since it provides callbacks into application code
1185 mImpl->mControlInterface.TextChanged();
1191 void Controller::InsertText( const std::string& text, Controller::InsertType type )
1193 bool removedPreEdit( false );
1194 bool maxLengthReached( false );
1196 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" )
1197 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n",
1198 this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
1199 mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1201 Vector<Character> utf32Characters;
1202 Length characterCount( 0u );
1204 if( ! text.empty() )
1206 // The placeholder text is no longer needed
1207 if( mImpl->IsShowingPlaceholderText() )
1212 // Convert text into UTF-32
1213 utf32Characters.Resize( text.size() );
1215 // This is a bit horrible but std::string returns a (signed) char*
1216 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
1218 // Transform a text array encoded in utf8 into an array encoded in utf32.
1219 // It returns the actual number of characters.
1220 characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
1221 utf32Characters.Resize( characterCount );
1223 DALI_ASSERT_DEBUG( text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length" );
1224 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count() );
1227 if( 0u != utf32Characters.Count() )
1229 // Handle the IMF (predicitive text) state changes
1230 if( mImpl->mEventData )
1232 if( mImpl->mEventData->mPreEditFlag &&
1233 0 != mImpl->mEventData->mPreEditLength )
1235 // Remove previous pre-edit text
1236 CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
1237 removedPreEdit = RemoveText( -static_cast<int>(offset), mImpl->mEventData->mPreEditLength );
1239 mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
1240 mImpl->mEventData->mPreEditLength = 0;
1243 if( COMMIT == type )
1245 // IMF manager is no longer handling key-events
1246 mImpl->ClearPreEditFlag();
1250 if( ! mImpl->mEventData->mPreEditFlag )
1252 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state" );
1254 // Record the start of the pre-edit text
1255 mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
1258 mImpl->mEventData->mPreEditLength = utf32Characters.Count();
1259 mImpl->mEventData->mPreEditFlag = true;
1261 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1265 const Length numberOfCharactersInModel = mImpl->mLogicalModel->GetNumberOfCharacters();
1267 // Restrict new text to fit within Maximum characters setting
1268 Length maxSizeOfNewText = std::min ( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
1269 maxLengthReached = ( characterCount > maxSizeOfNewText );
1271 // Insert at current cursor position
1272 CharacterIndex& cursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
1274 Vector<Character>& modifyText = mImpl->mLogicalModel->mText;
1276 if( cursorIndex < numberOfCharactersInModel )
1278 modifyText.Insert( modifyText.Begin() + cursorIndex, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1282 modifyText.Insert( modifyText.End(), utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1285 cursorIndex += maxSizeOfNewText;
1287 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
1290 if( removedPreEdit ||
1291 0 != utf32Characters.Count() )
1293 // Queue an inserted event
1294 mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
1297 if( maxLengthReached )
1299 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mLogicalModel->mText.Count() );
1301 mImpl->ResetImfManager();
1303 // Do this last since it provides callbacks into application code
1304 mImpl->mControlInterface.MaxLengthReached();
1308 void Controller::TapEvent( unsigned int tapCount, float x, float y )
1310 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
1312 if( NULL != mImpl->mEventData )
1314 if( 1u == tapCount )
1316 bool tapDuringEditMode( EventData::EDITING == mImpl->mEventData->mState );
1318 if( ! mImpl->IsShowingPlaceholderText() &&
1319 EventData::EDITING == mImpl->mEventData->mState )
1321 // Grab handle is not shown until a tap is received whilst EDITING
1322 if( tapDuringEditMode )
1324 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
1326 mImpl->mEventData->mDecorator->SetPopupActive( false );
1329 mImpl->ChangeState( EventData::EDITING );
1331 else if( mImpl->mEventData->mSelectionEnabled &&
1332 ( 2u == tapCount ) )
1334 mImpl->ChangeState( EventData::SELECTING );
1338 // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
1339 if( mImpl->mEventData )
1341 Event event( Event::TAP_EVENT );
1342 event.p1.mUint = tapCount;
1343 event.p2.mFloat = x;
1344 event.p3.mFloat = y;
1345 mImpl->mEventData->mEventQueue.push_back( event );
1347 mImpl->RequestRelayout();
1350 // Reset keyboard as tap event has occurred.
1351 mImpl->ResetImfManager();
1354 void Controller::PanEvent( Gesture::State state, const Vector2& displacement )
1356 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
1358 if( mImpl->mEventData )
1360 Event event( Event::PAN_EVENT );
1361 event.p1.mInt = state;
1362 event.p2.mFloat = displacement.x;
1363 event.p3.mFloat = displacement.y;
1364 mImpl->mEventData->mEventQueue.push_back( event );
1366 mImpl->RequestRelayout();
1370 void Controller::GetTargetSize( Vector2& targetSize )
1372 targetSize = mImpl->mControlSize;
1375 void Controller::AddDecoration( Actor& actor )
1377 mImpl->mControlInterface.AddDecoration( actor );
1380 void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
1382 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
1384 if( mImpl->mEventData )
1386 switch( handleType )
1390 Event event( Event::GRAB_HANDLE_EVENT );
1391 event.p1.mUint = state;
1392 event.p2.mFloat = x;
1393 event.p3.mFloat = y;
1395 mImpl->mEventData->mEventQueue.push_back( event );
1398 case LEFT_SELECTION_HANDLE:
1400 Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
1401 event.p1.mUint = state;
1402 event.p2.mFloat = x;
1403 event.p3.mFloat = y;
1405 mImpl->mEventData->mEventQueue.push_back( event );
1408 case RIGHT_SELECTION_HANDLE:
1410 Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
1411 event.p1.mUint = state;
1412 event.p2.mFloat = x;
1413 event.p3.mFloat = y;
1415 mImpl->mEventData->mEventQueue.push_back( event );
1418 case HANDLE_TYPE_COUNT:
1420 DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
1424 mImpl->RequestRelayout();
1428 ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1430 bool update( false );
1431 bool requestRelayout = false;
1434 unsigned int cursorPosition( 0 );
1436 switch ( imfEvent.eventName )
1438 case ImfManager::COMMIT:
1440 InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
1441 requestRelayout = true;
1444 case ImfManager::PREEDIT:
1446 InsertText( imfEvent.predictiveString, Text::Controller::PRE_EDIT );
1448 requestRelayout = true;
1451 case ImfManager::DELETESURROUNDING:
1453 RemoveText( imfEvent.cursorOffset, imfEvent.numberOfChars );
1454 requestRelayout = true;
1457 case ImfManager::GETSURROUNDING:
1460 cursorPosition = GetLogicalCursorPosition();
1462 imfManager.SetSurroundingText( text );
1463 imfManager.SetCursorPosition( cursorPosition );
1466 case ImfManager::VOID:
1473 if( ImfManager::GETSURROUNDING != imfEvent.eventName )
1476 cursorPosition = GetLogicalCursorPosition();
1479 if( requestRelayout )
1481 mImpl->mOperationsPending = ALL_OPERATIONS;
1482 mImpl->RequestRelayout();
1484 // Do this last since it provides callbacks into application code
1485 mImpl->mControlInterface.TextChanged();
1488 ImfManager::ImfCallbackData callbackData( update, cursorPosition, text, false );
1490 return callbackData;
1494 Controller::~Controller()
1499 void Controller::ShowPlaceholderText()
1501 if( mImpl->IsPlaceholderAvailable() )
1503 DALI_ASSERT_DEBUG( mImpl->mEventData && "No placeholder text available" );
1505 mImpl->mEventData->mIsShowingPlaceholderText = true;
1507 // Disable handles when showing place-holder text
1508 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
1509 mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
1510 mImpl->mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
1512 const char* text( NULL );
1515 // TODO - Switch placeholder text styles when changing state
1516 if( EventData::INACTIVE != mImpl->mEventData->mState &&
1517 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() )
1519 text = mImpl->mEventData->mPlaceholderTextActive.c_str();
1520 size = mImpl->mEventData->mPlaceholderTextActive.size();
1524 text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
1525 size = mImpl->mEventData->mPlaceholderTextInactive.size();
1528 // Reset model for showing placeholder.
1529 mImpl->mLogicalModel->mText.Clear();
1531 mImpl->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
1533 // Convert text into UTF-32
1534 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
1535 utf32Characters.Resize( size );
1537 // This is a bit horrible but std::string returns a (signed) char*
1538 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text );
1540 // Transform a text array encoded in utf8 into an array encoded in utf32.
1541 // It returns the actual number of characters.
1542 Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
1543 utf32Characters.Resize( characterCount );
1545 // Reset the cursor position
1546 mImpl->mEventData->mPrimaryCursorPosition = 0;
1548 // The natural size needs to be re-calculated.
1549 mImpl->mRecalculateNaturalSize = true;
1551 // Apply modifications to the model
1552 mImpl->mOperationsPending = ALL_OPERATIONS;
1554 // Update the rest of the model during size negotiation
1555 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
1559 void Controller::ClearModelData()
1561 // n.b. This does not Clear the mText from mLogicalModel
1562 mImpl->mLogicalModel->mScriptRuns.Clear();
1563 mImpl->mLogicalModel->mFontRuns.Clear();
1564 mImpl->mLogicalModel->mLineBreakInfo.Clear();
1565 mImpl->mLogicalModel->mWordBreakInfo.Clear();
1566 mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
1567 mImpl->mLogicalModel->mCharacterDirections.Clear();
1568 mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
1569 mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
1570 mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
1571 mImpl->mVisualModel->mGlyphs.Clear();
1572 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1573 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1574 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1575 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1576 mImpl->mVisualModel->mGlyphPositions.Clear();
1577 mImpl->mVisualModel->mLines.Clear();
1578 mImpl->mVisualModel->ClearCaches();
1581 void Controller::ClearFontData()
1583 mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
1584 mImpl->mLogicalModel->mFontRuns.Clear();
1585 mImpl->mVisualModel->mGlyphs.Clear();
1586 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1587 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1588 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1589 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1590 mImpl->mVisualModel->mGlyphPositions.Clear();
1591 mImpl->mVisualModel->mLines.Clear();
1592 mImpl->mVisualModel->ClearCaches();
1595 Controller::Controller( ControlInterface& controlInterface )
1598 mImpl = new Controller::Impl( controlInterface );
1603 } // namespace Toolkit