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 // Cancel previously queued inserts etc.
77 mImpl->mModifyEvents.clear();
79 // Remove the previously set text
84 // Convert text into UTF-32
85 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
86 utf32Characters.Resize( text.size() );
88 // This is a bit horrible but std::string returns a (signed) char*
89 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
91 // Transform a text array encoded in utf8 into an array encoded in utf32.
92 // It returns the actual number of characters.
93 Length characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
94 utf32Characters.Resize( characterCount );
96 DALI_ASSERT_DEBUG( text.size() >= characterCount && "Invalid UTF32 conversion length" );
97 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, text.size(), mImpl->mLogicalModel->mText.Count() );
99 // Reset the cursor position
100 if( mImpl->mEventData )
102 mImpl->mEventData->mPrimaryCursorPosition = characterCount;
105 // Update the rest of the model during size negotiation
106 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
108 // The natural size needs to be re-calculated.
109 mImpl->mRecalculateNaturalSize = true;
111 // Apply modifications to the model
112 mImpl->mOperationsPending = ALL_OPERATIONS;
116 ShowPlaceholderText();
119 mImpl->RequestRelayout();
121 if( mImpl->mEventData )
123 // Cancel previously queued events
124 mImpl->mEventData->mEventQueue.clear();
127 // Reset keyboard as text changed
128 mImpl->ResetImfManager();
131 void Controller::GetText( std::string& text ) const
133 if( ! mImpl->IsShowingPlaceholderText() )
135 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
137 if( 0u != utf32Characters.Count() )
139 Utf32ToUtf8( &utf32Characters[0], utf32Characters.Count(), text );
144 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::GetText %p empty (but showing placeholder)\n", this );
148 unsigned int Controller::GetLogicalCursorPosition() const
150 if( mImpl->mEventData )
152 return mImpl->mEventData->mPrimaryCursorPosition;
158 void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
160 if( mImpl->mEventData )
162 if( PLACEHOLDER_TYPE_INACTIVE == type )
164 mImpl->mEventData->mPlaceholderTextInactive = text;
168 mImpl->mEventData->mPlaceholderTextActive = text;
171 // Update placeholder if there is no text
172 if( mImpl->IsShowingPlaceholderText() ||
173 0u == mImpl->mLogicalModel->mText.Count() )
175 ShowPlaceholderText();
180 void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
182 if( mImpl->mEventData )
184 if( PLACEHOLDER_TYPE_INACTIVE == type )
186 text = mImpl->mEventData->mPlaceholderTextInactive;
190 text = mImpl->mEventData->mPlaceholderTextActive;
195 void Controller::SetMaximumNumberOfCharacters( int maxCharacters )
197 if ( maxCharacters >= 0 )
199 mImpl->mMaximumNumberOfCharacters = maxCharacters;
203 int Controller::GetMaximumNumberOfCharacters()
205 return mImpl->mMaximumNumberOfCharacters;
208 void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
210 if( !mImpl->mFontDefaults )
212 mImpl->mFontDefaults = new FontDefaults();
215 mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily;
217 // Clear the font-specific data
220 mImpl->mOperationsPending = ALL_OPERATIONS;
221 mImpl->mRecalculateNaturalSize = true;
223 mImpl->RequestRelayout();
226 const std::string& Controller::GetDefaultFontFamily() const
228 if( mImpl->mFontDefaults )
230 return mImpl->mFontDefaults->mDefaultFontFamily;
236 void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle )
238 if( !mImpl->mFontDefaults )
240 mImpl->mFontDefaults = new FontDefaults();
243 mImpl->mFontDefaults->mDefaultFontStyle = defaultFontStyle;
245 // Clear the font-specific data
248 mImpl->mOperationsPending = ALL_OPERATIONS;
249 mImpl->mRecalculateNaturalSize = true;
251 mImpl->RequestRelayout();
254 const std::string& Controller::GetDefaultFontStyle() const
256 if( mImpl->mFontDefaults )
258 return mImpl->mFontDefaults->mDefaultFontStyle;
264 void Controller::SetDefaultPointSize( float pointSize )
266 if( !mImpl->mFontDefaults )
268 mImpl->mFontDefaults = new FontDefaults();
271 mImpl->mFontDefaults->mDefaultPointSize = pointSize;
273 // Clear the font-specific data
276 mImpl->mOperationsPending = ALL_OPERATIONS;
277 mImpl->mRecalculateNaturalSize = true;
279 mImpl->RequestRelayout();
282 float Controller::GetDefaultPointSize() const
284 if( mImpl->mFontDefaults )
286 return mImpl->mFontDefaults->mDefaultPointSize;
292 void Controller::SetTextColor( const Vector4& textColor )
294 mImpl->mTextColor = textColor;
296 if( !mImpl->IsShowingPlaceholderText() )
298 mImpl->mVisualModel->SetTextColor( textColor );
300 mImpl->RequestRelayout();
304 const Vector4& Controller::GetTextColor() const
306 return mImpl->mTextColor;
309 bool Controller::RemoveText( int cursorOffset, int numberOfChars )
311 bool removed( false );
313 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfChars %d\n",
314 this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfChars );
316 if( ! mImpl->IsShowingPlaceholderText() )
318 // Delete at current cursor position
319 Vector<Character>& currentText = mImpl->mLogicalModel->mText;
320 CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
322 CharacterIndex cursorIndex = oldCursorIndex;
324 // Validate the cursor position & number of characters
325 if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex )
327 cursorIndex = oldCursorIndex + cursorOffset;
330 if( (cursorIndex + numberOfChars) > currentText.Count() )
332 numberOfChars = currentText.Count() - cursorIndex;
335 if( cursorIndex >= 0 &&
336 (cursorIndex + numberOfChars) <= currentText.Count() )
338 Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
339 Vector<Character>::Iterator last = first + numberOfChars;
341 currentText.Erase( first, last );
343 // Cursor position retreat
344 oldCursorIndex = cursorIndex;
346 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfChars );
354 void Controller::SetPlaceholderTextColor( const Vector4& textColor )
356 if( mImpl->mEventData )
358 mImpl->mEventData->mPlaceholderTextColor = textColor;
361 if( mImpl->IsShowingPlaceholderText() )
363 mImpl->mVisualModel->SetTextColor( textColor );
364 mImpl->RequestRelayout();
368 const Vector4& Controller::GetPlaceholderTextColor() const
370 if( mImpl->mEventData )
372 return mImpl->mEventData->mPlaceholderTextColor;
378 void Controller::SetShadowOffset( const Vector2& shadowOffset )
380 mImpl->mVisualModel->SetShadowOffset( shadowOffset );
382 mImpl->RequestRelayout();
385 const Vector2& Controller::GetShadowOffset() const
387 return mImpl->mVisualModel->GetShadowOffset();
390 void Controller::SetShadowColor( const Vector4& shadowColor )
392 mImpl->mVisualModel->SetShadowColor( shadowColor );
394 mImpl->RequestRelayout();
397 const Vector4& Controller::GetShadowColor() const
399 return mImpl->mVisualModel->GetShadowColor();
402 void Controller::SetUnderlineColor( const Vector4& color )
404 mImpl->mVisualModel->SetUnderlineColor( color );
406 mImpl->RequestRelayout();
409 const Vector4& Controller::GetUnderlineColor() const
411 return mImpl->mVisualModel->GetUnderlineColor();
414 void Controller::SetUnderlineEnabled( bool enabled )
416 mImpl->mVisualModel->SetUnderlineEnabled( enabled );
418 mImpl->RequestRelayout();
421 bool Controller::IsUnderlineEnabled() const
423 return mImpl->mVisualModel->IsUnderlineEnabled();
426 void Controller::SetUnderlineHeight( float height )
428 mImpl->mVisualModel->SetUnderlineHeight( height );
430 mImpl->RequestRelayout();
433 float Controller::GetUnderlineHeight() const
435 return mImpl->mVisualModel->GetUnderlineHeight();
438 void Controller::SetEnableCursorBlink( bool enable )
440 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
442 if( mImpl->mEventData )
444 mImpl->mEventData->mCursorBlinkEnabled = enable;
447 mImpl->mEventData->mDecorator )
449 mImpl->mEventData->mDecorator->StopCursorBlink();
454 bool Controller::GetEnableCursorBlink() const
456 if( mImpl->mEventData )
458 return mImpl->mEventData->mCursorBlinkEnabled;
464 const Vector2& Controller::GetScrollPosition() const
466 if( mImpl->mEventData )
468 return mImpl->mEventData->mScrollPosition;
471 return Vector2::ZERO;
474 const Vector2& Controller::GetAlignmentOffset() const
476 return mImpl->mAlignmentOffset;
479 Vector3 Controller::GetNaturalSize()
481 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
484 // Make sure the model is up-to-date before layouting
485 ProcessModifyEvents();
487 if( mImpl->mRecalculateNaturalSize )
489 // Operations that can be done only once until the text changes.
490 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
498 // Make sure the model is up-to-date before layouting
499 mImpl->UpdateModel( onlyOnceOperations );
501 // Operations that need to be done if the size changes.
502 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
506 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
507 static_cast<OperationsMask>( onlyOnceOperations |
509 naturalSize.GetVectorXY() );
511 // Do not do again the only once operations.
512 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
514 // Do the size related operations again.
515 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
517 // Stores the natural size to avoid recalculate it again
518 // unless the text/style changes.
519 mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
521 mImpl->mRecalculateNaturalSize = false;
523 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
527 naturalSize = mImpl->mVisualModel->GetNaturalSize();
529 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
535 float Controller::GetHeightForWidth( float width )
537 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", this, width );
538 // Make sure the model is up-to-date before layouting
539 ProcessModifyEvents();
542 if( width != mImpl->mControlSize.width )
544 // Operations that can be done only once until the text changes.
545 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
553 // Make sure the model is up-to-date before layouting
554 mImpl->UpdateModel( onlyOnceOperations );
556 // Operations that need to be done if the size changes.
557 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
561 DoRelayout( Size( width, MAX_FLOAT ),
562 static_cast<OperationsMask>( onlyOnceOperations |
566 // Do not do again the only once operations.
567 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
569 // Do the size related operations again.
570 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
571 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
575 layoutSize = mImpl->mVisualModel->GetActualSize();
576 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
579 return layoutSize.height;
582 bool Controller::Relayout( const Size& size )
584 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f\n", this, size.width, size.height );
586 if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
588 bool glyphsRemoved( false );
589 if( 0u != mImpl->mVisualModel->GetNumberOfGlyphPositions() )
591 mImpl->mVisualModel->SetGlyphPositions( NULL, 0u );
592 glyphsRemoved = true;
594 // Not worth to relayout if width or height is equal to zero.
595 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
596 return glyphsRemoved;
599 if( size != mImpl->mControlSize )
601 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mControlSize.width, mImpl->mControlSize.height );
603 // Operations that need to be done if the size changes.
604 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
610 mImpl->mControlSize = size;
613 // Make sure the model is up-to-date before layouting
614 ProcessModifyEvents();
615 mImpl->UpdateModel( mImpl->mOperationsPending );
618 bool updated = DoRelayout( mImpl->mControlSize,
619 mImpl->mOperationsPending,
622 // Do not re-do any operation until something changes.
623 mImpl->mOperationsPending = NO_OPERATION;
625 // After doing the text layout, the alignment offset to place the actor in the desired position can be calculated.
626 CalculateTextAlignment( size );
628 if( mImpl->mEventData )
630 // Move the cursor, grab handle etc.
631 updated = mImpl->ProcessInputEvents() || updated;
634 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
638 void Controller::ProcessModifyEvents()
640 std::vector<ModifyEvent>& events = mImpl->mModifyEvents;
642 for( unsigned int i=0; i<events.size(); ++i )
644 if( ModifyEvent::TEXT_REPLACED == events[0].type )
646 // A (single) replace event should come first, otherwise we wasted time processing NOOP events
647 DALI_ASSERT_DEBUG( 0 == i && "Unexpected TEXT_REPLACED event" );
651 else if( ModifyEvent::TEXT_INSERTED == events[0].type )
655 else if( ModifyEvent::TEXT_DELETED == events[0].type )
657 // Placeholder-text cannot be deleted
658 if( !mImpl->IsShowingPlaceholderText() )
665 // Discard temporary text
669 void Controller::ResetText()
672 mImpl->mLogicalModel->mText.Clear();
675 // Reset the cursor position
676 if( mImpl->mEventData )
678 mImpl->mEventData->mPrimaryCursorPosition = 0;
681 // We have cleared everything including the placeholder-text
682 mImpl->PlaceholderCleared();
684 // The natural size needs to be re-calculated.
685 mImpl->mRecalculateNaturalSize = true;
687 // Apply modifications to the model
688 mImpl->mOperationsPending = ALL_OPERATIONS;
691 void Controller::TextReplacedEvent()
696 // The natural size needs to be re-calculated.
697 mImpl->mRecalculateNaturalSize = true;
699 // Apply modifications to the model
700 mImpl->mOperationsPending = ALL_OPERATIONS;
701 mImpl->UpdateModel( ALL_OPERATIONS );
702 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
708 void Controller::TextInsertedEvent()
710 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
712 // TODO - Optimize this
715 // The natural size needs to be re-calculated.
716 mImpl->mRecalculateNaturalSize = true;
718 // Apply modifications to the model; TODO - Optimize this
719 mImpl->mOperationsPending = ALL_OPERATIONS;
720 mImpl->UpdateModel( ALL_OPERATIONS );
721 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
726 // Queue a cursor reposition event; this must wait until after DoRelayout()
727 mImpl->mEventData->mUpdateCursorPosition = true;
728 mImpl->mEventData->mScrollAfterUpdateCursorPosition = true;
731 void Controller::TextDeletedEvent()
733 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
735 // TODO - Optimize this
738 // The natural size needs to be re-calculated.
739 mImpl->mRecalculateNaturalSize = true;
741 // Apply modifications to the model; TODO - Optimize this
742 mImpl->mOperationsPending = ALL_OPERATIONS;
743 mImpl->UpdateModel( ALL_OPERATIONS );
744 mImpl->mOperationsPending = static_cast<OperationsMask>( LAYOUT |
749 // Queue a cursor reposition event; this must wait until after DoRelayout()
750 mImpl->mEventData->mUpdateCursorPosition = true;
751 mImpl->mEventData->mScrollAfterUpdateCursorPosition = true;
754 bool Controller::DoRelayout( const Size& size,
755 OperationsMask operationsRequired,
758 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
759 bool viewUpdated( false );
761 // Calculate the operations to be done.
762 const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
764 if( LAYOUT & operations )
766 // Some vectors with data needed to layout and reorder may be void
767 // after the first time the text has been laid out.
768 // Fill the vectors again.
770 Length numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
772 if( 0u == numberOfGlyphs )
774 // Nothing else to do if there is no glyphs.
775 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
779 Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
780 Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
781 Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
782 Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
783 Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
784 Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
786 // Set the layout parameters.
787 LayoutParameters layoutParameters( size,
788 mImpl->mLogicalModel->mText.Begin(),
789 lineBreakInfo.Begin(),
790 wordBreakInfo.Begin(),
791 ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
794 glyphsToCharactersMap.Begin(),
795 charactersPerGlyph.Begin() );
797 // The laid-out lines.
798 // It's not possible to know in how many lines the text is going to be laid-out,
799 // but it can be resized at least with the number of 'paragraphs' to avoid
800 // some re-allocations.
801 Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
803 // Delete any previous laid out lines before setting the new ones.
806 // The capacity of the bidirectional paragraph info is the number of paragraphs.
807 lines.Reserve( mImpl->mLogicalModel->mBidirectionalParagraphInfo.Capacity() );
809 // Resize the vector of positions to have the same size than the vector of glyphs.
810 Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
811 glyphPositions.Resize( numberOfGlyphs );
813 // Update the visual model.
814 viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
822 if( REORDER & operations )
824 Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
826 // Check first if there are paragraphs with bidirectional info.
827 if( 0u != bidirectionalInfo.Count() )
830 const Length numberOfLines = mImpl->mVisualModel->GetNumberOfLines();
832 // Reorder the lines.
833 Vector<BidirectionalLineInfoRun> lineBidirectionalInfoRuns;
834 lineBidirectionalInfoRuns.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
835 ReorderLines( bidirectionalInfo,
837 lineBidirectionalInfoRuns );
839 // Set the bidirectional info into the model.
840 const Length numberOfBidirectionalInfoRuns = lineBidirectionalInfoRuns.Count();
841 mImpl->mLogicalModel->SetVisualToLogicalMap( lineBidirectionalInfoRuns.Begin(),
842 numberOfBidirectionalInfoRuns );
844 // Set the bidirectional info per line into the layout parameters.
845 layoutParameters.lineBidirectionalInfoRunsBuffer = lineBidirectionalInfoRuns.Begin();
846 layoutParameters.numberOfBidirectionalInfoRuns = numberOfBidirectionalInfoRuns;
848 // Get the character to glyph conversion table and set into the layout.
849 layoutParameters.charactersToGlyphsBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin();
851 // Get the glyphs per character table and set into the layout.
852 layoutParameters.glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin();
854 // Re-layout the text. Reorder those lines with right to left characters.
855 mImpl->mLayoutEngine.ReLayoutRightToLeftLines( layoutParameters,
858 // Free the allocated memory used to store the conversion table in the bidirectional line info run.
859 for( Vector<BidirectionalLineInfoRun>::Iterator it = lineBidirectionalInfoRuns.Begin(),
860 endIt = lineBidirectionalInfoRuns.End();
864 BidirectionalLineInfoRun& bidiLineInfo = *it;
866 free( bidiLineInfo.visualToLogicalMap );
871 // TODO: I'm working on a patch that changes the LayoutEngine::Align() method.
872 // The layoutParameters is not needed and this call can be moved outside the if().
873 // Then there is no need to do the layout again to change the alignment.
874 if( ALIGN & operations )
876 mImpl->mLayoutEngine.Align( layoutParameters,
882 // Sets the actual size.
883 if( UPDATE_ACTUAL_SIZE & operations )
885 mImpl->mVisualModel->SetActualSize( layoutSize );
891 layoutSize = mImpl->mVisualModel->GetActualSize();
894 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
898 void Controller::SetMultiLineEnabled( bool enable )
900 const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
902 if( layout != mImpl->mLayoutEngine.GetLayout() )
904 // Set the layout type.
905 mImpl->mLayoutEngine.SetLayout( layout );
907 // Set the flags to redo the layout operations
908 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
913 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
915 mImpl->RequestRelayout();
919 bool Controller::IsMultiLineEnabled() const
921 return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
924 void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
926 if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
928 // Set the alignment.
929 mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
931 // Set the flag to redo the alignment operation.
932 // TODO : Is not needed re-layout and reorder again but with the current implementation it is.
933 // Im working on a different patch to fix an issue with the alignment. When that patch
934 // is in, this issue can be fixed.
935 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
940 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
942 mImpl->RequestRelayout();
946 LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
948 return mImpl->mLayoutEngine.GetHorizontalAlignment();
951 void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
953 if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
955 // Set the alignment.
956 mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
958 // Set the flag to redo the alignment operation.
959 // TODO : Is not needed re-layout and reorder again but with the current implementation it is.
960 // Im working on a different patch to fix an issue with the alignment. When that patch
961 // is in, this issue can be fixed.
962 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
967 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
969 mImpl->RequestRelayout();
973 LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
975 return mImpl->mLayoutEngine.GetVerticalAlignment();
978 void Controller::CalculateTextAlignment( const Size& size )
980 // Get the direction of the first character.
981 const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
983 const Size& actualSize = mImpl->mVisualModel->GetActualSize();
985 // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
986 LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
987 if( firstParagraphDirection &&
988 ( LayoutEngine::HORIZONTAL_ALIGN_CENTER != horizontalAlignment ) )
990 if( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == horizontalAlignment )
992 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_END;
996 horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_BEGIN;
1000 switch( horizontalAlignment )
1002 case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
1004 mImpl->mAlignmentOffset.x = 0.f;
1007 case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
1009 const int intOffset = static_cast<int>( 0.5f * ( size.width - actualSize.width ) ); // try to avoid pixel alignment.
1010 mImpl->mAlignmentOffset.x = static_cast<float>( intOffset );
1013 case LayoutEngine::HORIZONTAL_ALIGN_END:
1015 mImpl->mAlignmentOffset.x = size.width - actualSize.width;
1020 const LayoutEngine::VerticalAlignment verticalAlignment = mImpl->mLayoutEngine.GetVerticalAlignment();
1021 switch( verticalAlignment )
1023 case LayoutEngine::VERTICAL_ALIGN_TOP:
1025 mImpl->mAlignmentOffset.y = 0.f;
1028 case LayoutEngine::VERTICAL_ALIGN_CENTER:
1030 const int intOffset = static_cast<int>( 0.5f * ( size.height - actualSize.height ) ); // try to avoid pixel alignment.
1031 mImpl->mAlignmentOffset.y = static_cast<float>( intOffset );
1034 case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
1036 mImpl->mAlignmentOffset.y = size.height - actualSize.height;
1042 LayoutEngine& Controller::GetLayoutEngine()
1044 return mImpl->mLayoutEngine;
1047 View& Controller::GetView()
1049 return mImpl->mView;
1052 void Controller::KeyboardFocusGainEvent()
1054 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
1056 if( mImpl->mEventData )
1058 mImpl->ChangeState( EventData::EDITING );
1060 if( mImpl->IsShowingPlaceholderText() )
1062 // Show alternative placeholder-text when editing
1063 ShowPlaceholderText();
1066 mImpl->RequestRelayout();
1070 void Controller::KeyboardFocusLostEvent()
1072 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
1074 if( mImpl->mEventData )
1076 mImpl->ChangeState( EventData::INACTIVE );
1078 if( mImpl->IsShowingPlaceholderText() )
1080 // Revert to regular placeholder-text when not editing
1081 ShowPlaceholderText();
1084 mImpl->RequestRelayout();
1088 bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
1090 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
1092 if( mImpl->mEventData &&
1093 keyEvent.state == KeyEvent::Down )
1095 int keyCode = keyEvent.keyCode;
1096 const std::string& keyString = keyEvent.keyPressed;
1098 // Pre-process to separate modifying events from non-modifying input events.
1099 if( Dali::DALI_KEY_ESCAPE == keyCode )
1101 // Escape key is a special case which causes focus loss
1102 KeyboardFocusLostEvent();
1104 else if( Dali::DALI_KEY_CURSOR_LEFT == keyCode ||
1105 Dali::DALI_KEY_CURSOR_RIGHT == keyCode ||
1106 Dali::DALI_KEY_CURSOR_UP == keyCode ||
1107 Dali::DALI_KEY_CURSOR_DOWN == keyCode )
1109 Event event( Event::CURSOR_KEY_EVENT );
1110 event.p1.mInt = keyCode;
1111 mImpl->mEventData->mEventQueue.push_back( event );
1113 else if( Dali::DALI_KEY_BACKSPACE == keyCode )
1115 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE\n", this );
1117 // IMF manager is no longer handling key-events
1118 mImpl->ClearPreEditFlag();
1120 // Remove the character before the current cursor position
1121 bool removed = RemoveText( -1, 1 );
1125 if( 0u == mImpl->mLogicalModel->mText.Count() )
1127 ShowPlaceholderText();
1128 mImpl->mEventData->mUpdateCursorPosition = true;
1132 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
1138 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
1140 // IMF manager is no longer handling key-events
1141 mImpl->ClearPreEditFlag();
1143 InsertText( keyString, COMMIT );
1146 mImpl->ChangeState( EventData::EDITING ); // todo Confirm this is the best place to change the state of
1148 mImpl->RequestRelayout();
1154 void Controller::InsertText( const std::string& text, Controller::InsertType type )
1156 bool removedPreEdit( false );
1157 bool maxLengthReached( false );
1159 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" )
1160 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n",
1161 this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
1162 mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1164 Vector<Character> utf32Characters;
1165 Length characterCount( 0u );
1167 if( ! text.empty() )
1169 // The placeholder text is no longer needed
1170 if( mImpl->IsShowingPlaceholderText() )
1175 // Convert text into UTF-32
1176 utf32Characters.Resize( text.size() );
1178 // This is a bit horrible but std::string returns a (signed) char*
1179 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
1181 // Transform a text array encoded in utf8 into an array encoded in utf32.
1182 // It returns the actual number of characters.
1183 characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
1184 utf32Characters.Resize( characterCount );
1186 DALI_ASSERT_DEBUG( text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length" );
1187 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count() );
1190 if( 0u != utf32Characters.Count() )
1192 // Handle the IMF (predicitive text) state changes
1193 if( mImpl->mEventData )
1195 if( mImpl->mEventData->mPreEditFlag &&
1196 0 != mImpl->mEventData->mPreEditLength )
1198 // Remove previous pre-edit text
1199 CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
1200 removedPreEdit = RemoveText( -static_cast<int>(offset), mImpl->mEventData->mPreEditLength );
1202 mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
1203 mImpl->mEventData->mPreEditLength = 0;
1206 if( COMMIT == type )
1208 // IMF manager is no longer handling key-events
1209 mImpl->ClearPreEditFlag();
1213 if( ! mImpl->mEventData->mPreEditFlag )
1215 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state" );
1217 // Record the start of the pre-edit text
1218 mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
1221 mImpl->mEventData->mPreEditLength = utf32Characters.Count();
1222 mImpl->mEventData->mPreEditFlag = true;
1224 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
1228 const Length numberOfCharactersInModel = mImpl->mLogicalModel->GetNumberOfCharacters();
1230 // Restrict new text to fit within Maximum characters setting
1231 Length maxSizeOfNewText = std::min ( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
1232 maxLengthReached = ( characterCount > maxSizeOfNewText );
1234 // Insert at current cursor position
1235 CharacterIndex& cursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
1237 Vector<Character>& modifyText = mImpl->mLogicalModel->mText;
1239 if( cursorIndex < numberOfCharactersInModel )
1241 modifyText.Insert( modifyText.Begin() + cursorIndex, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1245 modifyText.Insert( modifyText.End(), utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
1248 cursorIndex += maxSizeOfNewText;
1250 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
1253 if( removedPreEdit ||
1254 0 != utf32Characters.Count() )
1256 // Queue an inserted event
1257 mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
1260 if( maxLengthReached )
1262 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mLogicalModel->mText.Count() );
1264 mImpl->mControlInterface.MaxLengthReached();
1266 mImpl->ResetImfManager();
1270 void Controller::TapEvent( unsigned int tapCount, float x, float y )
1272 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
1274 if( NULL != mImpl->mEventData )
1276 if( 1u == tapCount )
1278 bool tapDuringEditMode( EventData::EDITING == mImpl->mEventData->mState );
1280 if( ! mImpl->IsShowingPlaceholderText() &&
1281 EventData::EDITING == mImpl->mEventData->mState )
1283 // Grab handle is not shown until a tap is received whilst EDITING
1284 if( tapDuringEditMode )
1286 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
1288 mImpl->mEventData->mDecorator->SetPopupActive( false );
1291 mImpl->ChangeState( EventData::EDITING );
1293 else if( mImpl->mEventData->mSelectionEnabled &&
1294 ( 2u == tapCount ) )
1296 mImpl->ChangeState( EventData::SELECTING );
1300 // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
1301 if( mImpl->mEventData )
1303 Event event( Event::TAP_EVENT );
1304 event.p1.mUint = tapCount;
1305 event.p2.mFloat = x;
1306 event.p3.mFloat = y;
1307 mImpl->mEventData->mEventQueue.push_back( event );
1309 mImpl->RequestRelayout();
1312 // Reset keyboard as tap event has occurred.
1313 mImpl->ResetImfManager();
1316 void Controller::PanEvent( Gesture::State state, const Vector2& displacement )
1318 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
1320 if( mImpl->mEventData )
1322 Event event( Event::PAN_EVENT );
1323 event.p1.mInt = state;
1324 event.p2.mFloat = displacement.x;
1325 event.p3.mFloat = displacement.y;
1326 mImpl->mEventData->mEventQueue.push_back( event );
1328 mImpl->RequestRelayout();
1332 void Controller::HandleEvent( HandleType handleType, HandleState state, float x, float y )
1334 DALI_ASSERT_DEBUG( mImpl->mEventData && "Controller::HandleEvent. Unexpected HandleEvent" );
1336 if( mImpl->mEventData )
1338 switch( handleType )
1342 Event event( Event::GRAB_HANDLE_EVENT );
1343 event.p1.mUint = state;
1344 event.p2.mFloat = x;
1345 event.p3.mFloat = y;
1347 mImpl->mEventData->mEventQueue.push_back( event );
1350 case LEFT_SELECTION_HANDLE:
1352 Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
1353 event.p1.mUint = state;
1354 event.p2.mFloat = x;
1355 event.p3.mFloat = y;
1357 mImpl->mEventData->mEventQueue.push_back( event );
1360 case RIGHT_SELECTION_HANDLE:
1362 Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
1363 event.p1.mUint = state;
1364 event.p2.mFloat = x;
1365 event.p3.mFloat = y;
1367 mImpl->mEventData->mEventQueue.push_back( event );
1370 case HANDLE_TYPE_COUNT:
1372 DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
1376 mImpl->RequestRelayout();
1380 ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1382 bool update( false );
1383 bool requestRelayout = false;
1386 unsigned int cursorPosition( 0 );
1388 switch ( imfEvent.eventName )
1390 case ImfManager::COMMIT:
1392 InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
1393 requestRelayout = true;
1396 case ImfManager::PREEDIT:
1398 InsertText( imfEvent.predictiveString, Text::Controller::PRE_EDIT );
1400 requestRelayout = true;
1403 case ImfManager::DELETESURROUNDING:
1405 RemoveText( imfEvent.cursorOffset, imfEvent.numberOfChars );
1406 requestRelayout = true;
1409 case ImfManager::GETSURROUNDING:
1412 cursorPosition = GetLogicalCursorPosition();
1414 imfManager.SetSurroundingText( text );
1415 imfManager.SetCursorPosition( cursorPosition );
1418 case ImfManager::VOID:
1425 if( ImfManager::GETSURROUNDING != imfEvent.eventName )
1428 cursorPosition = GetLogicalCursorPosition();
1431 if( requestRelayout )
1433 mImpl->mOperationsPending = ALL_OPERATIONS;
1434 mImpl->RequestRelayout();
1437 ImfManager::ImfCallbackData callbackData( update, cursorPosition, text, false );
1439 return callbackData;
1443 Controller::~Controller()
1448 void Controller::ShowPlaceholderText()
1450 if( mImpl->IsPlaceholderAvailable() )
1452 DALI_ASSERT_DEBUG( mImpl->mEventData && "No placeholder text available" );
1454 mImpl->mEventData->mIsShowingPlaceholderText = true;
1456 // Cancel previously queued inserts etc.
1457 mImpl->mModifyEvents.clear();
1459 // Disable handles when showing place-holder text
1460 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
1461 mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
1462 mImpl->mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
1464 const char* text( NULL );
1467 // TODO - Switch placeholder text styles when changing state
1468 if( EventData::INACTIVE != mImpl->mEventData->mState &&
1469 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() )
1471 text = mImpl->mEventData->mPlaceholderTextActive.c_str();
1472 size = mImpl->mEventData->mPlaceholderTextActive.size();
1476 text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
1477 size = mImpl->mEventData->mPlaceholderTextInactive.size();
1480 // Reset model for showing placeholder.
1481 mImpl->mLogicalModel->mText.Clear();
1483 mImpl->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
1485 // Convert text into UTF-32
1486 Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
1487 utf32Characters.Resize( size );
1489 // This is a bit horrible but std::string returns a (signed) char*
1490 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text );
1492 // Transform a text array encoded in utf8 into an array encoded in utf32.
1493 // It returns the actual number of characters.
1494 Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
1495 utf32Characters.Resize( characterCount );
1497 // Reset the cursor position
1498 mImpl->mEventData->mPrimaryCursorPosition = 0;
1500 // The natural size needs to be re-calculated.
1501 mImpl->mRecalculateNaturalSize = true;
1503 // Apply modifications to the model
1504 mImpl->mOperationsPending = ALL_OPERATIONS;
1506 // Update the rest of the model during size negotiation
1507 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
1511 void Controller::ClearModelData()
1513 // n.b. This does not Clear the mText from mLogicalModel
1514 mImpl->mLogicalModel->mScriptRuns.Clear();
1515 mImpl->mLogicalModel->mFontRuns.Clear();
1516 mImpl->mLogicalModel->mLineBreakInfo.Clear();
1517 mImpl->mLogicalModel->mWordBreakInfo.Clear();
1518 mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
1519 mImpl->mLogicalModel->mCharacterDirections.Clear();
1520 mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
1521 mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
1522 mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
1523 mImpl->mVisualModel->mGlyphs.Clear();
1524 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1525 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1526 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1527 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1528 mImpl->mVisualModel->mGlyphPositions.Clear();
1529 mImpl->mVisualModel->mLines.Clear();
1530 mImpl->mVisualModel->ClearCaches();
1533 void Controller::ClearFontData()
1535 mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
1536 mImpl->mLogicalModel->mFontRuns.Clear();
1537 mImpl->mVisualModel->mGlyphs.Clear();
1538 mImpl->mVisualModel->mGlyphsToCharacters.Clear();
1539 mImpl->mVisualModel->mCharactersToGlyph.Clear();
1540 mImpl->mVisualModel->mCharactersPerGlyph.Clear();
1541 mImpl->mVisualModel->mGlyphsPerCharacter.Clear();
1542 mImpl->mVisualModel->mGlyphPositions.Clear();
1543 mImpl->mVisualModel->mLines.Clear();
1544 mImpl->mVisualModel->ClearCaches();
1547 Controller::Controller( ControlInterface& controlInterface )
1550 mImpl = new Controller::Impl( controlInterface );
1555 } // namespace Toolkit