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("");
50 float ConvertToEven( float value )
52 int intValue(static_cast<int>( value ));
53 return static_cast<float>(intValue % 2 == 0) ? intValue : (intValue + 1);
67 ControllerPtr Controller::New( ControlInterface& controlInterface )
69 return ControllerPtr( new Controller( controlInterface ) );
72 void Controller::EnableTextInput( DecoratorPtr decorator )
74 if( !mImpl->mEventData )
76 mImpl->mEventData = new EventData( decorator );
80 void Controller::SetText( const std::string& text )
82 // Remove the previously set text
85 CharacterIndex lastCursorIndex = 0u;
89 // Convert text into UTF-32
90 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
91 utf32Characters.Resize( text.size() );
93 // This is a bit horrible but std::string returns a (signed) char*
94 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
96 // Transform a text array encoded in utf8 into an array encoded in utf32.
97 // It returns the actual number of characters.
98 Length characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
99 utf32Characters.Resize( characterCount );
101 DALI_ASSERT_DEBUG( text.size() >= characterCount && "Invalid UTF32 conversion length" );
102 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, text.size(), mImpl->mLogicalModel->mText.Count() );
104 // To reset the cursor position
105 lastCursorIndex = characterCount;
107 // Update the rest of the model during size negotiation
108 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
110 // The natural size needs to be re-calculated.
111 mImpl->mRecalculateNaturalSize = true;
113 // Apply modifications to the model
114 mImpl->mOperationsPending = ALL_OPERATIONS;
118 ShowPlaceholderText();
121 // Resets the cursor position.
122 ResetCursorPosition( lastCursorIndex );
124 // Scrolls the text to make the cursor visible.
125 ResetScrollPosition();
127 mImpl->RequestRelayout();
129 if( mImpl->mEventData )
131 // Cancel previously queued events
132 mImpl->mEventData->mEventQueue.clear();
135 // Reset keyboard as text changed
136 mImpl->ResetImfManager();
138 // Do this last since it provides callbacks into application code
139 mImpl->mControlInterface.TextChanged();
142 void Controller::GetText( std::string& text ) const
144 if( ! mImpl->IsShowingPlaceholderText() )
146 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
148 if( 0u != utf32Characters.Count() )
150 Utf32ToUtf8( &utf32Characters[0], utf32Characters.Count(), text );
155 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::GetText %p empty (but showing placeholder)\n", this );
159 unsigned int Controller::GetLogicalCursorPosition() const
161 if( mImpl->mEventData )
163 return mImpl->mEventData->mPrimaryCursorPosition;
169 void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
171 if( mImpl->mEventData )
173 if( PLACEHOLDER_TYPE_INACTIVE == type )
175 mImpl->mEventData->mPlaceholderTextInactive = text;
179 mImpl->mEventData->mPlaceholderTextActive = text;
182 // Update placeholder if there is no text
183 if( mImpl->IsShowingPlaceholderText() ||
184 0u == mImpl->mLogicalModel->mText.Count() )
186 ShowPlaceholderText();
191 void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
193 if( mImpl->mEventData )
195 if( PLACEHOLDER_TYPE_INACTIVE == type )
197 text = mImpl->mEventData->mPlaceholderTextInactive;
201 text = mImpl->mEventData->mPlaceholderTextActive;
206 void Controller::SetMaximumNumberOfCharacters( int maxCharacters )
208 if ( maxCharacters >= 0 )
210 mImpl->mMaximumNumberOfCharacters = maxCharacters;
214 int Controller::GetMaximumNumberOfCharacters()
216 return mImpl->mMaximumNumberOfCharacters;
219 void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
221 if( !mImpl->mFontDefaults )
223 mImpl->mFontDefaults = new FontDefaults();
226 mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily;
228 // Clear the font-specific data
231 mImpl->mOperationsPending = ALL_OPERATIONS;
232 mImpl->mRecalculateNaturalSize = true;
234 mImpl->RequestRelayout();
237 const std::string& Controller::GetDefaultFontFamily() const
239 if( mImpl->mFontDefaults )
241 return mImpl->mFontDefaults->mDefaultFontFamily;
247 void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle )
249 if( !mImpl->mFontDefaults )
251 mImpl->mFontDefaults = new FontDefaults();
254 mImpl->mFontDefaults->mDefaultFontStyle = defaultFontStyle;
256 // Clear the font-specific data
259 mImpl->mOperationsPending = ALL_OPERATIONS;
260 mImpl->mRecalculateNaturalSize = true;
262 mImpl->RequestRelayout();
265 const std::string& Controller::GetDefaultFontStyle() const
267 if( mImpl->mFontDefaults )
269 return mImpl->mFontDefaults->mDefaultFontStyle;
275 void Controller::SetDefaultPointSize( float pointSize )
277 if( !mImpl->mFontDefaults )
279 mImpl->mFontDefaults = new FontDefaults();
282 mImpl->mFontDefaults->mDefaultPointSize = pointSize;
284 // Clear the font-specific data
287 mImpl->mOperationsPending = ALL_OPERATIONS;
288 mImpl->mRecalculateNaturalSize = true;
290 mImpl->RequestRelayout();
293 float Controller::GetDefaultPointSize() const
295 if( mImpl->mFontDefaults )
297 return mImpl->mFontDefaults->mDefaultPointSize;
303 void Controller::SetTextColor( const Vector4& textColor )
305 mImpl->mTextColor = textColor;
307 if( !mImpl->IsShowingPlaceholderText() )
309 mImpl->mVisualModel->SetTextColor( textColor );
311 mImpl->RequestRelayout();
315 const Vector4& Controller::GetTextColor() const
317 return mImpl->mTextColor;
320 bool Controller::RemoveText( int cursorOffset, int numberOfChars )
322 bool removed( false );
324 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfChars %d\n",
325 this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfChars );
327 if( ! mImpl->IsShowingPlaceholderText() )
329 // Delete at current cursor position
330 Vector<Character>& currentText = mImpl->mLogicalModel->mText;
331 CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
333 CharacterIndex cursorIndex = oldCursorIndex;
335 // Validate the cursor position & number of characters
336 if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex )
338 cursorIndex = oldCursorIndex + cursorOffset;
341 if( (cursorIndex + numberOfChars) > currentText.Count() )
343 numberOfChars = currentText.Count() - cursorIndex;
346 if( (cursorIndex + numberOfChars) <= currentText.Count() )
348 Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
349 Vector<Character>::Iterator last = first + numberOfChars;
351 currentText.Erase( first, last );
353 // Cursor position retreat
354 oldCursorIndex = cursorIndex;
356 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfChars );
364 void Controller::SetPlaceholderTextColor( const Vector4& textColor )
366 if( mImpl->mEventData )
368 mImpl->mEventData->mPlaceholderTextColor = textColor;
371 if( mImpl->IsShowingPlaceholderText() )
373 mImpl->mVisualModel->SetTextColor( textColor );
374 mImpl->RequestRelayout();
378 const Vector4& Controller::GetPlaceholderTextColor() const
380 if( mImpl->mEventData )
382 return mImpl->mEventData->mPlaceholderTextColor;
388 void Controller::SetShadowOffset( const Vector2& shadowOffset )
390 mImpl->mVisualModel->SetShadowOffset( shadowOffset );
392 mImpl->RequestRelayout();
395 const Vector2& Controller::GetShadowOffset() const
397 return mImpl->mVisualModel->GetShadowOffset();
400 void Controller::SetShadowColor( const Vector4& shadowColor )
402 mImpl->mVisualModel->SetShadowColor( shadowColor );
404 mImpl->RequestRelayout();
407 const Vector4& Controller::GetShadowColor() const
409 return mImpl->mVisualModel->GetShadowColor();
412 void Controller::SetUnderlineColor( const Vector4& color )
414 mImpl->mVisualModel->SetUnderlineColor( color );
416 mImpl->RequestRelayout();
419 const Vector4& Controller::GetUnderlineColor() const
421 return mImpl->mVisualModel->GetUnderlineColor();
424 void Controller::SetUnderlineEnabled( bool enabled )
426 mImpl->mVisualModel->SetUnderlineEnabled( enabled );
428 mImpl->RequestRelayout();
431 bool Controller::IsUnderlineEnabled() const
433 return mImpl->mVisualModel->IsUnderlineEnabled();
436 void Controller::SetUnderlineHeight( float height )
438 mImpl->mVisualModel->SetUnderlineHeight( height );
440 mImpl->RequestRelayout();
443 float Controller::GetUnderlineHeight() const
445 return mImpl->mVisualModel->GetUnderlineHeight();
448 void Controller::SetEnableCursorBlink( bool enable )
450 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
452 if( mImpl->mEventData )
454 mImpl->mEventData->mCursorBlinkEnabled = enable;
457 mImpl->mEventData->mDecorator )
459 mImpl->mEventData->mDecorator->StopCursorBlink();
464 bool Controller::GetEnableCursorBlink() const
466 if( mImpl->mEventData )
468 return mImpl->mEventData->mCursorBlinkEnabled;
474 const Vector2& Controller::GetScrollPosition() const
476 if( mImpl->mEventData )
478 return mImpl->mEventData->mScrollPosition;
481 return Vector2::ZERO;
484 const Vector2& Controller::GetAlignmentOffset() const
486 return mImpl->mAlignmentOffset;
489 Vector3 Controller::GetNaturalSize()
491 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
494 // Make sure the model is up-to-date before layouting
495 ProcessModifyEvents();
497 if( mImpl->mRecalculateNaturalSize )
499 // Operations that can be done only once until the text changes.
500 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
508 // Make sure the model is up-to-date before layouting
509 mImpl->UpdateModel( onlyOnceOperations );
511 // Operations that need to be done if the size changes.
512 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
516 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
517 static_cast<OperationsMask>( onlyOnceOperations |
519 naturalSize.GetVectorXY() );
521 // Do not do again the only once operations.
522 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
524 // Do the size related operations again.
525 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
527 // Stores the natural size to avoid recalculate it again
528 // unless the text/style changes.
529 mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
531 mImpl->mRecalculateNaturalSize = false;
533 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
537 naturalSize = mImpl->mVisualModel->GetNaturalSize();
539 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
542 naturalSize.x = ConvertToEven( naturalSize.x );
543 naturalSize.y = ConvertToEven( naturalSize.y );
548 float Controller::GetHeightForWidth( float width )
550 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", this, width );
551 // Make sure the model is up-to-date before layouting
552 ProcessModifyEvents();
555 if( width != mImpl->mControlSize.width )
557 // Operations that can be done only once until the text changes.
558 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
566 // Make sure the model is up-to-date before layouting
567 mImpl->UpdateModel( onlyOnceOperations );
569 // Operations that need to be done if the size changes.
570 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
574 DoRelayout( Size( width, MAX_FLOAT ),
575 static_cast<OperationsMask>( onlyOnceOperations |
579 // Do not do again the only once operations.
580 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
582 // Do the size related operations again.
583 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
584 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
588 layoutSize = mImpl->mVisualModel->GetActualSize();
589 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
592 return layoutSize.height;
595 bool Controller::Relayout( const Size& size )
597 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f\n", this, size.width, size.height );
599 if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
601 bool glyphsRemoved( false );
602 if( 0u != mImpl->mVisualModel->GetNumberOfGlyphPositions() )
604 mImpl->mVisualModel->SetGlyphPositions( NULL, 0u );
605 glyphsRemoved = true;
607 // Not worth to relayout if width or height is equal to zero.
608 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
609 return glyphsRemoved;
612 if( size != mImpl->mControlSize )
614 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mControlSize.width, mImpl->mControlSize.height );
616 // Operations that need to be done if the size changes.
617 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
623 mImpl->mControlSize = size;
626 // Make sure the model is up-to-date before layouting
627 ProcessModifyEvents();
628 mImpl->UpdateModel( mImpl->mOperationsPending );
631 bool updated = DoRelayout( mImpl->mControlSize,
632 mImpl->mOperationsPending,
635 // Do not re-do any operation until something changes.
636 mImpl->mOperationsPending = NO_OPERATION;
638 // After doing the text layout, the alignment offset to place the actor in the desired position can be calculated.
639 CalculateTextAlignment( size );
641 if( mImpl->mEventData )
643 // Move the cursor, grab handle etc.
644 updated = mImpl->ProcessInputEvents() || updated;
647 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
651 void Controller::ProcessModifyEvents()
653 std::vector<ModifyEvent>& events = mImpl->mModifyEvents;
655 for( unsigned int i=0; i<events.size(); ++i )
657 if( ModifyEvent::TEXT_REPLACED == events[0].type )
659 // A (single) replace event should come first, otherwise we wasted time processing NOOP events
660 DALI_ASSERT_DEBUG( 0 == i && "Unexpected TEXT_REPLACED event" );
664 else if( ModifyEvent::TEXT_INSERTED == events[0].type )
668 else if( ModifyEvent::TEXT_DELETED == events[0].type )
670 // Placeholder-text cannot be deleted
671 if( !mImpl->IsShowingPlaceholderText() )
678 // Discard temporary text
682 void Controller::ResetText()
685 mImpl->mLogicalModel->mText.Clear();
688 // We have cleared everything including the placeholder-text
689 mImpl->PlaceholderCleared();
691 // The natural size needs to be re-calculated.
692 mImpl->mRecalculateNaturalSize = true;
694 // Apply modifications to the model
695 mImpl->mOperationsPending = ALL_OPERATIONS;
698 void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
700 // Reset the cursor position
701 if( NULL != mImpl->mEventData )
703 mImpl->mEventData->mPrimaryCursorPosition = cursorIndex;
705 // Update the cursor if it's in editing mode.
706 if( ( EventData::EDITING == mImpl->mEventData->mState ) ||
707 ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) )
709 mImpl->mEventData->mUpdateCursorPosition = true;
714 void Controller::ResetScrollPosition()
716 if( NULL != mImpl->mEventData )
718 // Reset the scroll position.
719 mImpl->mEventData->mScrollPosition = Vector2::ZERO;
720 mImpl->mEventData->mScrollAfterUpdatePosition = true;
724 void Controller::TextReplacedEvent()
729 // The natural size needs to be re-calculated.
730 mImpl->mRecalculateNaturalSize = true;
732 // Apply modifications to the model
733 mImpl->mOperationsPending = ALL_OPERATIONS;
734 mImpl->UpdateModel( ALL_OPERATIONS );
735 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
741 void Controller::TextInsertedEvent()
743 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
745 // TODO - Optimize this
748 // The natural size needs to be re-calculated.
749 mImpl->mRecalculateNaturalSize = true;
751 // Apply modifications to the model; TODO - Optimize this
752 mImpl->mOperationsPending = ALL_OPERATIONS;
753 mImpl->UpdateModel( ALL_OPERATIONS );
754 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
759 // Queue a cursor reposition event; this must wait until after DoRelayout()
760 mImpl->mEventData->mUpdateCursorPosition = true;
761 mImpl->mEventData->mScrollAfterUpdatePosition = true;
764 void Controller::TextDeletedEvent()
766 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
768 // TODO - Optimize this
771 // The natural size needs to be re-calculated.
772 mImpl->mRecalculateNaturalSize = true;
774 // Apply modifications to the model; TODO - Optimize this
775 mImpl->mOperationsPending = ALL_OPERATIONS;
776 mImpl->UpdateModel( ALL_OPERATIONS );
777 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
782 // Queue a cursor reposition event; this must wait until after DoRelayout()
783 mImpl->mEventData->mScrollAfterDelete = true;
786 bool Controller::DoRelayout( const Size& size,
787 OperationsMask operationsRequired,
790 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
791 bool viewUpdated( false );
793 // Calculate the operations to be done.
794 const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
796 if( LAYOUT & operations )
798 // Some vectors with data needed to layout and reorder may be void
799 // after the first time the text has been laid out.
800 // Fill the vectors again.
802 Length numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
804 if( 0u == numberOfGlyphs )
806 // Nothing else to do if there is no glyphs.
807 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
811 Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
812 Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
813 Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
814 Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
815 Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
816 Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
818 // Set the layout parameters.
819 LayoutParameters layoutParameters( size,
820 mImpl->mLogicalModel->mText.Begin(),
821 lineBreakInfo.Begin(),
822 wordBreakInfo.Begin(),
823 ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
826 glyphsToCharactersMap.Begin(),
827 charactersPerGlyph.Begin() );
829 // The laid-out lines.
830 // It's not possible to know in how many lines the text is going to be laid-out,
831 // but it can be resized at least with the number of 'paragraphs' to avoid
832 // some re-allocations.
833 Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
835 // Delete any previous laid out lines before setting the new ones.
838 // The capacity of the bidirectional paragraph info is the number of paragraphs.
839 lines.Reserve( mImpl->mLogicalModel->mBidirectionalParagraphInfo.Capacity() );
841 // Resize the vector of positions to have the same size than the vector of glyphs.
842 Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
843 glyphPositions.Resize( numberOfGlyphs );
845 // Update the visual model.
846 viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
854 if( REORDER & operations )
856 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
858 // Check first if there are paragraphs with bidirectional info.
859 if( 0u != bidirectionalInfo.Count() )
862 const Length numberOfLines = mImpl->mVisualModel->GetNumberOfLines();
864 // Reorder the lines.
865 Vector<BidirectionalLineInfoRun> lineBidirectionalInfoRuns;
866 lineBidirectionalInfoRuns.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
867 ReorderLines( bidirectionalInfo,
869 lineBidirectionalInfoRuns );
871 // Set the bidirectional info into the model.
872 const Length numberOfBidirectionalInfoRuns = lineBidirectionalInfoRuns.Count();
873 mImpl->mLogicalModel->SetVisualToLogicalMap( lineBidirectionalInfoRuns.Begin(),
874 numberOfBidirectionalInfoRuns );
876 // Set the bidirectional info per line into the layout parameters.
877 layoutParameters.lineBidirectionalInfoRunsBuffer = lineBidirectionalInfoRuns.Begin();
878 layoutParameters.numberOfBidirectionalInfoRuns = numberOfBidirectionalInfoRuns;
880 // Get the character to glyph conversion table and set into the layout.
881 layoutParameters.charactersToGlyphsBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin();
883 // Get the glyphs per character table and set into the layout.
884 layoutParameters.glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin();
886 // Re-layout the text. Reorder those lines with right to left characters.
887 mImpl->mLayoutEngine.ReLayoutRightToLeftLines( layoutParameters,
890 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
891 for( Vector<BidirectionalLineInfoRun>::Iterator it = lineBidirectionalInfoRuns.Begin(),
892 endIt = lineBidirectionalInfoRuns.End();
896 BidirectionalLineInfoRun& bidiLineInfo = *it;
898 free( bidiLineInfo.visualToLogicalMap );
903 // Sets the actual size.
904 if( UPDATE_ACTUAL_SIZE & operations )
906 mImpl->mVisualModel->SetActualSize( layoutSize );
912 layoutSize = mImpl->mVisualModel->GetActualSize();
915 if( ALIGN & operations )
917 // The laid-out lines.
918 Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
920 mImpl->mLayoutEngine.Align( layoutSize,
926 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
930 void Controller::SetMultiLineEnabled( bool enable )
932 const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
934 if( layout != mImpl->mLayoutEngine.GetLayout() )
936 // Set the layout type.
937 mImpl->mLayoutEngine.SetLayout( layout );
939 // Set the flags to redo the layout operations
940 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
945 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
947 mImpl->RequestRelayout();
951 bool Controller::IsMultiLineEnabled() const
953 return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
956 void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
958 if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
960 // Set the alignment.
961 mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
963 // Set the flag to redo the alignment operation.
964 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
966 mImpl->RequestRelayout();
970 LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
972 return mImpl->mLayoutEngine.GetHorizontalAlignment();
975 void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
977 if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
979 // Set the alignment.
980 mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
982 // Set the flag to redo the alignment operation.
983 // TODO : Is not needed re-layout and reorder again but with the current implementation it is.
984 // Im working on a different patch to fix an issue with the alignment. When that patch
985 // is in, this issue can be fixed.
986 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
991 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
993 mImpl->RequestRelayout();
997 LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
999 return mImpl->mLayoutEngine.GetVerticalAlignment();
1002 void Controller::CalculateTextAlignment( const Size& size )
1004 // Get the direction of the first character.
1005 const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
1007 const Size& actualSize = mImpl->mVisualModel->GetActualSize();
1009 // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
1010 LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
1011 if( firstParagraphDirection &&
1012 ( LayoutEngine::HORIZONTAL_ALIGN_CENTER != horizontalAlignment ) )
1014 if( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == horizontalAlignment )
1016 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_END;
1020 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_BEGIN;
1024 switch( horizontalAlignment )
1026 case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
1028 mImpl->mAlignmentOffset.x = 0.f;
1031 case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
1033 const int intOffset = static_cast<int>( 0.5f * ( size.width - actualSize.width ) ); // try to avoid pixel alignment.
1034 mImpl->mAlignmentOffset.x = static_cast<float>( intOffset );
1037 case LayoutEngine::HORIZONTAL_ALIGN_END:
1039 mImpl->mAlignmentOffset.x = size.width - actualSize.width;
1044 const LayoutEngine::VerticalAlignment verticalAlignment = mImpl->mLayoutEngine.GetVerticalAlignment();
1045 switch( verticalAlignment )
1047 case LayoutEngine::VERTICAL_ALIGN_TOP:
1049 mImpl->mAlignmentOffset.y = 0.f;
1052 case LayoutEngine::VERTICAL_ALIGN_CENTER:
1054 const int intOffset = static_cast<int>( 0.5f * ( size.height - actualSize.height ) ); // try to avoid pixel alignment.
1055 mImpl->mAlignmentOffset.y = static_cast<float>( intOffset );
1058 case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
1060 mImpl->mAlignmentOffset.y = size.height - actualSize.height;
1066 LayoutEngine& Controller::GetLayoutEngine()
1068 return mImpl->mLayoutEngine;
1071 View& Controller::GetView()
1073 return mImpl->mView;
1076 void Controller::KeyboardFocusGainEvent()
1078 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
1080 if( mImpl->mEventData )
1082 mImpl->ChangeState( EventData::EDITING );
1084 if( mImpl->IsShowingPlaceholderText() )
1086 // Show alternative placeholder-text when editing
1087 ShowPlaceholderText();
1090 mImpl->RequestRelayout();
1094 void Controller::KeyboardFocusLostEvent()
1096 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
1098 if( mImpl->mEventData )
1100 mImpl->ChangeState( EventData::INACTIVE );
1102 if( mImpl->IsShowingPlaceholderText() )
1104 // Revert to regular placeholder-text when not editing
1105 ShowPlaceholderText();
1108 mImpl->RequestRelayout();
1112 bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
1114 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
1116 bool textChanged( false );
1118 if( mImpl->mEventData &&
1119 keyEvent.state == KeyEvent::Down )
1121 int keyCode = keyEvent.keyCode;
1122 const std::string& keyString = keyEvent.keyPressed;
1124 // Hide the grab handle.
1125 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
1127 // Pre-process to separate modifying events from non-modifying input events.
1128 if( Dali::DALI_KEY_ESCAPE == keyCode )
1130 // Escape key is a special case which causes focus loss
1131 KeyboardFocusLostEvent();
1133 else if( Dali::DALI_KEY_CURSOR_LEFT == keyCode ||
1134 Dali::DALI_KEY_CURSOR_RIGHT == keyCode ||
1135 Dali::DALI_KEY_CURSOR_UP == keyCode ||
1136 Dali::DALI_KEY_CURSOR_DOWN == keyCode )
1138 Event event( Event::CURSOR_KEY_EVENT );
1139 event.p1.mInt = keyCode;
1140 mImpl->mEventData->mEventQueue.push_back( event );
1142 else if( Dali::DALI_KEY_BACKSPACE == keyCode )
1144 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE\n", this );
1146 // IMF manager is no longer handling key-events
1147 mImpl->ClearPreEditFlag();
1149 // Remove the character before the current cursor position
1150 bool removed = RemoveText( -1, 1 );
1154 if( 0u != mImpl->mLogicalModel->mText.Count() ||
1155 !mImpl->IsPlaceholderAvailable() )
1157 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
1161 ShowPlaceholderText();
1162 mImpl->mEventData->mUpdateCursorPosition = true;
1170 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
1172 // IMF manager is no longer handling key-events
1173 mImpl->ClearPreEditFlag();
1175 InsertText( keyString, COMMIT );
1180 mImpl->ChangeState( EventData::EDITING ); // todo Confirm this is the best place to change the state of
1182 mImpl->RequestRelayout();
1187 // Do this last since it provides callbacks into application code
1188 mImpl->mControlInterface.TextChanged();
1194 void Controller::InsertText( const std::string& text, Controller::InsertType type )
1196 bool removedPreEdit( false );
1197 bool maxLengthReached( false );
1199 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" )
1200 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n",
1201 this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
1202 mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1204 Vector<Character> utf32Characters;
1205 Length characterCount( 0u );
1207 if( ! text.empty() )
1209 // The placeholder text is no longer needed
1210 if( mImpl->IsShowingPlaceholderText() )
1215 // Convert text into UTF-32
1216 utf32Characters.Resize( text.size() );
1218 // This is a bit horrible but std::string returns a (signed) char*
1219 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
1221 // Transform a text array encoded in utf8 into an array encoded in utf32.
1222 // It returns the actual number of characters.
1223 characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
1224 utf32Characters.Resize( characterCount );
1226 DALI_ASSERT_DEBUG( text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length" );
1227 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count() );
1230 if( 0u != utf32Characters.Count() )
1232 // Handle the IMF (predicitive text) state changes
1233 if( mImpl->mEventData )
1235 if( mImpl->mEventData->mPreEditFlag &&
1236 0 != mImpl->mEventData->mPreEditLength )
1238 // Remove previous pre-edit text
1239 CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
1240 removedPreEdit = RemoveText( -static_cast<int>(offset), mImpl->mEventData->mPreEditLength );
1242 mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
1243 mImpl->mEventData->mPreEditLength = 0;
1246 if( COMMIT == type )
1248 // IMF manager is no longer handling key-events
1249 mImpl->ClearPreEditFlag();
1253 if( ! mImpl->mEventData->mPreEditFlag )
1255 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state" );
1257 // Record the start of the pre-edit text
1258 mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
1261 mImpl->mEventData->mPreEditLength = utf32Characters.Count();
1262 mImpl->mEventData->mPreEditFlag = true;
1264 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1268 const Length numberOfCharactersInModel = mImpl->mLogicalModel->GetNumberOfCharacters();
1270 // Restrict new text to fit within Maximum characters setting
1271 Length maxSizeOfNewText = std::min ( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
1272 maxLengthReached = ( characterCount > maxSizeOfNewText );
1274 // Insert at current cursor position
1275 CharacterIndex& cursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
1277 Vector<Character>& modifyText = mImpl->mLogicalModel->mText;
1279 if( cursorIndex < numberOfCharactersInModel )
1281 modifyText.Insert( modifyText.Begin() + cursorIndex, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1285 modifyText.Insert( modifyText.End(), utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1288 cursorIndex += maxSizeOfNewText;
1290 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
1293 if( removedPreEdit ||
1294 0 != utf32Characters.Count() )
1296 // Queue an inserted event
1297 mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
1300 if( maxLengthReached )
1302 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mLogicalModel->mText.Count() );
1304 mImpl->ResetImfManager();
1306 // Do this last since it provides callbacks into application code
1307 mImpl->mControlInterface.MaxLengthReached();
1311 void Controller::TapEvent( unsigned int tapCount, float x, float y )
1313 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
1315 if( NULL != mImpl->mEventData )
1317 const bool isShowingPlaceholderText = mImpl->IsShowingPlaceholderText();
1318 if( 1u == tapCount )
1320 bool tapDuringEditMode( EventData::EDITING == mImpl->mEventData->mState );
1322 if( !isShowingPlaceholderText && tapDuringEditMode )
1324 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
1325 mImpl->mEventData->mDecorator->SetPopupActive( false );
1328 mImpl->ChangeState( EventData::EDITING );
1330 else if( !isShowingPlaceholderText &&
1331 mImpl->mEventData->mSelectionEnabled &&
1332 ( 2u == tapCount ) )
1334 if ( mImpl->mEventData->mState == EventData::SELECTING )
1336 mImpl->ChangeState( EventData::SELECTION_CHANGED );
1340 mImpl->ChangeState( EventData::SELECTING );
1345 // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
1346 if( mImpl->mEventData )
1348 Event event( Event::TAP_EVENT );
1349 event.p1.mUint = tapCount;
1350 event.p2.mFloat = x;
1351 event.p3.mFloat = y;
1352 mImpl->mEventData->mEventQueue.push_back( event );
1354 mImpl->RequestRelayout();
1357 // Reset keyboard as tap event has occurred.
1358 mImpl->ResetImfManager();
1361 void Controller::PanEvent( Gesture::State state, const Vector2& displacement )
1363 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
1365 if( mImpl->mEventData )
1367 Event event( Event::PAN_EVENT );
1368 event.p1.mInt = state;
1369 event.p2.mFloat = displacement.x;
1370 event.p3.mFloat = displacement.y;
1371 mImpl->mEventData->mEventQueue.push_back( event );
1373 mImpl->RequestRelayout();
1377 void Controller::GetTargetSize( Vector2& targetSize )
1379 targetSize = mImpl->mControlSize;
1382 void Controller::AddDecoration( Actor& actor, bool needsClipping )
1384 mImpl->mControlInterface.AddDecoration( actor, needsClipping );
1387 void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
1389 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
1391 if( mImpl->mEventData )
1393 switch( handleType )
1397 Event event( Event::GRAB_HANDLE_EVENT );
1398 event.p1.mUint = state;
1399 event.p2.mFloat = x;
1400 event.p3.mFloat = y;
1402 mImpl->mEventData->mEventQueue.push_back( event );
1405 case LEFT_SELECTION_HANDLE:
1407 Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
1408 event.p1.mUint = state;
1409 event.p2.mFloat = x;
1410 event.p3.mFloat = y;
1412 mImpl->mEventData->mEventQueue.push_back( event );
1415 case RIGHT_SELECTION_HANDLE:
1417 Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
1418 event.p1.mUint = state;
1419 event.p2.mFloat = x;
1420 event.p3.mFloat = y;
1422 mImpl->mEventData->mEventQueue.push_back( event );
1425 case HANDLE_TYPE_COUNT:
1427 DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
1431 mImpl->RequestRelayout();
1435 ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1437 bool update( false );
1438 bool requestRelayout = false;
1441 unsigned int cursorPosition( 0 );
1443 switch ( imfEvent.eventName )
1445 case ImfManager::COMMIT:
1447 InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
1448 requestRelayout = true;
1451 case ImfManager::PREEDIT:
1453 InsertText( imfEvent.predictiveString, Text::Controller::PRE_EDIT );
1455 requestRelayout = true;
1458 case ImfManager::DELETESURROUNDING:
1460 RemoveText( imfEvent.cursorOffset, imfEvent.numberOfChars );
1461 requestRelayout = true;
1464 case ImfManager::GETSURROUNDING:
1467 cursorPosition = GetLogicalCursorPosition();
1469 imfManager.SetSurroundingText( text );
1470 imfManager.SetCursorPosition( cursorPosition );
1473 case ImfManager::VOID:
1480 if( ImfManager::GETSURROUNDING != imfEvent.eventName )
1483 cursorPosition = GetLogicalCursorPosition();
1486 if( requestRelayout )
1488 mImpl->mOperationsPending = ALL_OPERATIONS;
1489 mImpl->RequestRelayout();
1491 // Do this last since it provides callbacks into application code
1492 mImpl->mControlInterface.TextChanged();
1495 ImfManager::ImfCallbackData callbackData( update, cursorPosition, text, false );
1497 return callbackData;
1501 Controller::~Controller()
1506 void Controller::ShowPlaceholderText()
1508 if( mImpl->IsPlaceholderAvailable() )
1510 DALI_ASSERT_DEBUG( mImpl->mEventData && "No placeholder text available" );
1512 mImpl->mEventData->mIsShowingPlaceholderText = true;
1514 // Disable handles when showing place-holder text
1515 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
1516 mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
1517 mImpl->mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
1519 const char* text( NULL );
1522 // TODO - Switch placeholder text styles when changing state
1523 if( EventData::INACTIVE != mImpl->mEventData->mState &&
1524 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() )
1526 text = mImpl->mEventData->mPlaceholderTextActive.c_str();
1527 size = mImpl->mEventData->mPlaceholderTextActive.size();
1531 text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
1532 size = mImpl->mEventData->mPlaceholderTextInactive.size();
1535 // Reset model for showing placeholder.
1536 mImpl->mLogicalModel->mText.Clear();
1538 mImpl->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
1540 // Convert text into UTF-32
1541 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
1542 utf32Characters.Resize( size );
1544 // This is a bit horrible but std::string returns a (signed) char*
1545 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text );
1547 // Transform a text array encoded in utf8 into an array encoded in utf32.
1548 // It returns the actual number of characters.
1549 Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
1550 utf32Characters.Resize( characterCount );
1552 // Reset the cursor position
1553 mImpl->mEventData->mPrimaryCursorPosition = 0;
1555 // The natural size needs to be re-calculated.
1556 mImpl->mRecalculateNaturalSize = true;
1558 // Apply modifications to the model
1559 mImpl->mOperationsPending = ALL_OPERATIONS;
1561 // Update the rest of the model during size negotiation
1562 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
1566 void Controller::ClearModelData()
1568 // n.b. This does not Clear the mText from mLogicalModel
1569 mImpl->mLogicalModel->mScriptRuns.Clear();
1570 mImpl->mLogicalModel->mFontRuns.Clear();
1571 mImpl->mLogicalModel->mLineBreakInfo.Clear();
1572 mImpl->mLogicalModel->mWordBreakInfo.Clear();
1573 mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
1574 mImpl->mLogicalModel->mCharacterDirections.Clear();
1575 mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
1576 mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
1577 mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
1578 mImpl->mVisualModel->mGlyphs.Clear();
1579 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1580 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1581 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1582 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1583 mImpl->mVisualModel->mGlyphPositions.Clear();
1584 mImpl->mVisualModel->mLines.Clear();
1585 mImpl->mVisualModel->ClearCaches();
1588 void Controller::ClearFontData()
1590 mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
1591 mImpl->mLogicalModel->mFontRuns.Clear();
1592 mImpl->mVisualModel->mGlyphs.Clear();
1593 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1594 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1595 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1596 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1597 mImpl->mVisualModel->mGlyphPositions.Clear();
1598 mImpl->mVisualModel->mLines.Clear();
1599 mImpl->mVisualModel->ClearCaches();
1602 Controller::Controller( ControlInterface& controlInterface )
1605 mImpl = new Controller::Impl( controlInterface );
1610 } // namespace Toolkit