2 * Copyright (c) 2020 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>
25 #include <dali/public-api/adaptor-framework/key.h>
26 #include <dali/integration-api/debug.h>
27 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/adaptor-framework/key-devel.h>
32 #include <dali-toolkit/public-api/controls/text-controls/placeholder-properties.h>
33 #include <dali-toolkit/internal/text/bidirectional-support.h>
34 #include <dali-toolkit/internal/text/character-set-conversion.h>
35 #include <dali-toolkit/internal/text/layouts/layout-parameters.h>
36 #include <dali-toolkit/internal/text/markup-processor.h>
37 #include <dali-toolkit/internal/text/multi-language-support.h>
38 #include <dali-toolkit/internal/text/text-controller-impl.h>
39 #include <dali-toolkit/internal/text/text-editable-control-interface.h>
40 #include <dali-toolkit/internal/text/text-font-style.h>
45 #if defined(DEBUG_ENABLED)
46 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
49 const float MAX_FLOAT = std::numeric_limits<float>::max();
51 const std::string EMPTY_STRING("");
53 const std::string KEY_C_NAME = "c";
54 const std::string KEY_V_NAME = "v";
55 const std::string KEY_X_NAME = "x";
56 const std::string KEY_A_NAME = "a";
57 const std::string KEY_INSERT_NAME = "Insert";
59 const char * const PLACEHOLDER_TEXT = "text";
60 const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
61 const char * const PLACEHOLDER_COLOR = "color";
62 const char * const PLACEHOLDER_FONT_FAMILY = "fontFamily";
63 const char * const PLACEHOLDER_FONT_STYLE = "fontStyle";
64 const char * const PLACEHOLDER_POINT_SIZE = "pointSize";
65 const char * const PLACEHOLDER_PIXEL_SIZE = "pixelSize";
66 const char * const PLACEHOLDER_ELLIPSIS = "ellipsis";
68 float ConvertToEven( float value )
70 int intValue(static_cast<int>( value ));
71 return static_cast<float>( intValue + ( intValue & 1 ) );
74 int ConvertPixelToPint( float pixel )
76 unsigned int horizontalDpi = 0u;
77 unsigned int verticalDpi = 0u;
78 Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
79 fontClient.GetDpi( horizontalDpi, verticalDpi );
81 return ( pixel * 72.f ) / static_cast< float >( horizontalDpi );
96 * @brief Adds a new font description run for the selected text.
98 * The new font parameters are added after the call to this method.
100 * @param[in] eventData The event data pointer.
101 * @param[in] logicalModel The logical model where to add the new font description run.
102 * @param[out] startOfSelectedText Index to the first selected character.
103 * @param[out] lengthOfSelectedText Number of selected characters.
105 FontDescriptionRun& UpdateSelectionFontStyleRun( EventData* eventData,
106 LogicalModelPtr logicalModel,
107 CharacterIndex& startOfSelectedText,
108 Length& lengthOfSelectedText )
110 const bool handlesCrossed = eventData->mLeftSelectionPosition > eventData->mRightSelectionPosition;
112 // Get start and end position of selection
113 startOfSelectedText = handlesCrossed ? eventData->mRightSelectionPosition : eventData->mLeftSelectionPosition;
114 lengthOfSelectedText = ( handlesCrossed ? eventData->mLeftSelectionPosition : eventData->mRightSelectionPosition ) - startOfSelectedText;
117 const VectorBase::SizeType numberOfRuns = logicalModel->mFontDescriptionRuns.Count();
118 logicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
120 FontDescriptionRun& fontDescriptionRun = *( logicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
122 fontDescriptionRun.characterRun.characterIndex = startOfSelectedText;
123 fontDescriptionRun.characterRun.numberOfCharacters = lengthOfSelectedText;
125 // Recalculate the selection highlight as the metrics may have changed.
126 eventData->mUpdateLeftSelectionPosition = true;
127 eventData->mUpdateRightSelectionPosition = true;
128 eventData->mUpdateHighlightBox = true;
130 return fontDescriptionRun;
133 // public : Constructor.
135 ControllerPtr Controller::New()
137 return ControllerPtr( new Controller() );
140 ControllerPtr Controller::New( ControlInterface* controlInterface )
142 return ControllerPtr( new Controller( controlInterface ) );
145 ControllerPtr Controller::New( ControlInterface* controlInterface,
146 EditableControlInterface* editableControlInterface )
148 return ControllerPtr( new Controller( controlInterface,
149 editableControlInterface ) );
152 // public : Configure the text controller.
154 void Controller::EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext )
158 delete mImpl->mEventData;
159 mImpl->mEventData = NULL;
161 // Nothing else to do.
165 if( NULL == mImpl->mEventData )
167 mImpl->mEventData = new EventData( decorator, inputMethodContext );
171 void Controller::SetGlyphType( TextAbstraction::GlyphType glyphType )
173 // Metrics for bitmap & vector based glyphs are different
174 mImpl->mMetrics->SetGlyphType( glyphType );
176 // Clear the font-specific data
179 mImpl->RequestRelayout();
182 void Controller::SetMarkupProcessorEnabled( bool enable )
184 if( enable != mImpl->mMarkupProcessorEnabled )
186 //If Text was already set, call the SetText again for enabling or disabling markup
187 mImpl->mMarkupProcessorEnabled = enable;
194 bool Controller::IsMarkupProcessorEnabled() const
196 return mImpl->mMarkupProcessorEnabled;
199 void Controller::SetAutoScrollEnabled( bool enable )
201 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable)?"true":"false", ( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX)?"true":"false", this );
203 if( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX )
207 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled for SINGLE_LINE_BOX\n" );
208 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
218 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled Disabling autoscroll\n");
219 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
226 mImpl->mIsAutoScrollEnabled = enable;
227 mImpl->RequestRelayout();
231 DALI_LOG_WARNING( "Attempted AutoScrolling on a non SINGLE_LINE_BOX, request ignored\n" );
232 mImpl->mIsAutoScrollEnabled = false;
236 bool Controller::IsAutoScrollEnabled() const
238 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::IsAutoScrollEnabled[%s]\n", mImpl->mIsAutoScrollEnabled?"true":"false" );
240 return mImpl->mIsAutoScrollEnabled;
243 CharacterDirection Controller::GetAutoScrollDirection() const
245 return mImpl->mIsTextDirectionRTL;
248 float Controller::GetAutoScrollLineAlignment() const
252 if( mImpl->mModel->mVisualModel &&
253 ( 0u != mImpl->mModel->mVisualModel->mLines.Count() ) )
255 offset = ( *mImpl->mModel->mVisualModel->mLines.Begin() ).alignmentOffset;
261 void Controller::SetHorizontalScrollEnabled( bool enable )
263 if( ( NULL != mImpl->mEventData ) &&
264 mImpl->mEventData->mDecorator )
266 mImpl->mEventData->mDecorator->SetHorizontalScrollEnabled( enable );
269 bool Controller::IsHorizontalScrollEnabled() const
271 if( ( NULL != mImpl->mEventData ) &&
272 mImpl->mEventData->mDecorator )
274 return mImpl->mEventData->mDecorator->IsHorizontalScrollEnabled();
280 void Controller::SetVerticalScrollEnabled( bool enable )
282 if( ( NULL != mImpl->mEventData ) &&
283 mImpl->mEventData->mDecorator )
285 if( mImpl->mEventData->mDecorator )
287 mImpl->mEventData->mDecorator->SetVerticalScrollEnabled( enable );
292 bool Controller::IsVerticalScrollEnabled() const
294 if( ( NULL != mImpl->mEventData ) &&
295 mImpl->mEventData->mDecorator )
297 return mImpl->mEventData->mDecorator->IsVerticalScrollEnabled();
303 void Controller::SetSmoothHandlePanEnabled( bool enable )
305 if( ( NULL != mImpl->mEventData ) &&
306 mImpl->mEventData->mDecorator )
308 mImpl->mEventData->mDecorator->SetSmoothHandlePanEnabled( enable );
312 bool Controller::IsSmoothHandlePanEnabled() const
314 if( ( NULL != mImpl->mEventData ) &&
315 mImpl->mEventData->mDecorator )
317 return mImpl->mEventData->mDecorator->IsSmoothHandlePanEnabled();
323 void Controller::SetMaximumNumberOfCharacters( Length maxCharacters )
325 mImpl->mMaximumNumberOfCharacters = maxCharacters;
328 int Controller::GetMaximumNumberOfCharacters()
330 return mImpl->mMaximumNumberOfCharacters;
333 void Controller::SetEnableCursorBlink( bool enable )
335 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
337 if( NULL != mImpl->mEventData )
339 mImpl->mEventData->mCursorBlinkEnabled = enable;
342 mImpl->mEventData->mDecorator )
344 mImpl->mEventData->mDecorator->StopCursorBlink();
349 bool Controller::GetEnableCursorBlink() const
351 if( NULL != mImpl->mEventData )
353 return mImpl->mEventData->mCursorBlinkEnabled;
359 void Controller::SetMultiLineEnabled( bool enable )
361 const Layout::Engine::Type layout = enable ? Layout::Engine::MULTI_LINE_BOX : Layout::Engine::SINGLE_LINE_BOX;
363 if( layout != mImpl->mLayoutEngine.GetLayout() )
365 // Set the layout type.
366 mImpl->mLayoutEngine.SetLayout( layout );
368 // Set the flags to redo the layout operations
369 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
374 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
375 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
377 // Need to recalculate natural size
378 mImpl->mRecalculateNaturalSize = true;
380 mImpl->RequestRelayout();
384 bool Controller::IsMultiLineEnabled() const
386 return Layout::Engine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
389 void Controller::SetHorizontalAlignment( Text::HorizontalAlignment::Type alignment )
391 if( alignment != mImpl->mModel->mHorizontalAlignment )
393 // Set the alignment.
394 mImpl->mModel->mHorizontalAlignment = alignment;
396 // Set the flag to redo the alignment operation.
397 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
399 if( mImpl->mEventData )
401 mImpl->mEventData->mUpdateAlignment = true;
403 // Update the cursor if it's in editing mode
404 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
406 mImpl->ChangeState( EventData::EDITING );
407 mImpl->mEventData->mUpdateCursorPosition = true;
411 mImpl->RequestRelayout();
415 Text::HorizontalAlignment::Type Controller::GetHorizontalAlignment() const
417 return mImpl->mModel->mHorizontalAlignment;
420 void Controller::SetVerticalAlignment( VerticalAlignment::Type alignment )
422 if( alignment != mImpl->mModel->mVerticalAlignment )
424 // Set the alignment.
425 mImpl->mModel->mVerticalAlignment = alignment;
427 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
429 mImpl->RequestRelayout();
433 VerticalAlignment::Type Controller::GetVerticalAlignment() const
435 return mImpl->mModel->mVerticalAlignment;
438 bool Controller::IsIgnoreSpacesAfterText() const
440 return mImpl->mModel->mIgnoreSpacesAfterText;
443 void Controller::SetIgnoreSpacesAfterText( bool ignore )
445 mImpl->mModel->mIgnoreSpacesAfterText = ignore;
448 bool Controller::IsMatchSystemLanguageDirection() const
450 return mImpl->mModel->mMatchSystemLanguageDirection;
453 void Controller::SetMatchSystemLanguageDirection( bool match )
455 mImpl->mModel->mMatchSystemLanguageDirection = match;
458 void Controller::SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection )
460 mImpl->mLayoutDirection = layoutDirection;
463 bool Controller::IsShowingRealText() const
465 return mImpl->IsShowingRealText();
469 void Controller::SetLineWrapMode( Text::LineWrap::Mode lineWrapMode )
471 if( lineWrapMode != mImpl->mModel->mLineWrapMode )
473 // Set the text wrap mode.
474 mImpl->mModel->mLineWrapMode = lineWrapMode;
477 // Update Text layout for applying wrap mode
478 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
483 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
484 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
485 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
488 mImpl->RequestRelayout();
492 Text::LineWrap::Mode Controller::GetLineWrapMode() const
494 return mImpl->mModel->mLineWrapMode;
497 void Controller::SetTextElideEnabled( bool enabled )
499 mImpl->mModel->mElideEnabled = enabled;
502 bool Controller::IsTextElideEnabled() const
504 return mImpl->mModel->mElideEnabled;
507 void Controller::SetTextFitEnabled(bool enabled)
509 mImpl->mTextFitEnabled = enabled;
512 bool Controller::IsTextFitEnabled() const
514 return mImpl->mTextFitEnabled;
517 void Controller::SetTextFitMinSize( float minSize, FontSizeType type )
523 mImpl->mTextFitMinSize = minSize;
528 mImpl->mTextFitMinSize = ConvertPixelToPint( minSize );
534 float Controller::GetTextFitMinSize() const
536 return mImpl->mTextFitMinSize;
539 void Controller::SetTextFitMaxSize( float maxSize, FontSizeType type )
545 mImpl->mTextFitMaxSize = maxSize;
550 mImpl->mTextFitMaxSize = ConvertPixelToPint( maxSize );
556 float Controller::GetTextFitMaxSize() const
558 return mImpl->mTextFitMaxSize;
561 void Controller::SetTextFitStepSize( float step, FontSizeType type )
567 mImpl->mTextFitStepSize = step;
572 mImpl->mTextFitStepSize = ConvertPixelToPint( step );
578 float Controller::GetTextFitStepSize() const
580 return mImpl->mTextFitStepSize;
583 void Controller::SetTextFitContentSize(Vector2 size)
585 mImpl->mTextFitContentSize = size;
588 Vector2 Controller::GetTextFitContentSize() const
590 return mImpl->mTextFitContentSize;
593 void Controller::SetPlaceholderTextElideEnabled( bool enabled )
595 mImpl->mEventData->mIsPlaceholderElideEnabled = enabled;
596 mImpl->mEventData->mPlaceholderEllipsisFlag = true;
598 // Update placeholder if there is no text
599 if( mImpl->IsShowingPlaceholderText() ||
600 ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
602 ShowPlaceholderText();
606 bool Controller::IsPlaceholderTextElideEnabled() const
608 return mImpl->mEventData->mIsPlaceholderElideEnabled;
611 void Controller::SetSelectionEnabled( bool enabled )
613 mImpl->mEventData->mSelectionEnabled = enabled;
616 bool Controller::IsSelectionEnabled() const
618 return mImpl->mEventData->mSelectionEnabled;
621 void Controller::SetShiftSelectionEnabled( bool enabled )
623 mImpl->mEventData->mShiftSelectionFlag = enabled;
626 bool Controller::IsShiftSelectionEnabled() const
628 return mImpl->mEventData->mShiftSelectionFlag;
631 void Controller::SetGrabHandleEnabled( bool enabled )
633 mImpl->mEventData->mGrabHandleEnabled = enabled;
636 bool Controller::IsGrabHandleEnabled() const
638 return mImpl->mEventData->mGrabHandleEnabled;
641 void Controller::SetGrabHandlePopupEnabled(bool enabled)
643 mImpl->mEventData->mGrabHandlePopupEnabled = enabled;
646 bool Controller::IsGrabHandlePopupEnabled() const
648 return mImpl->mEventData->mGrabHandlePopupEnabled;
653 void Controller::SetText( const std::string& text )
655 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" );
657 // Reset keyboard as text changed
658 mImpl->ResetInputMethodContext();
660 // Remove the previously set text and style.
666 CharacterIndex lastCursorIndex = 0u;
668 if( NULL != mImpl->mEventData )
670 // If popup shown then hide it by switching to Editing state
671 if( ( EventData::SELECTING == mImpl->mEventData->mState ) ||
672 ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) ||
673 ( EventData::EDITING_WITH_GRAB_HANDLE == mImpl->mEventData->mState ) ||
674 ( EventData::EDITING_WITH_PASTE_POPUP == mImpl->mEventData->mState ) )
676 mImpl->ChangeState( EventData::EDITING );
682 mImpl->mModel->mVisualModel->SetTextColor( mImpl->mTextColor );
684 MarkupProcessData markupProcessData( mImpl->mModel->mLogicalModel->mColorRuns,
685 mImpl->mModel->mLogicalModel->mFontDescriptionRuns,
686 mImpl->mModel->mLogicalModel->mEmbeddedItems );
688 Length textSize = 0u;
689 const uint8_t* utf8 = NULL;
690 if( mImpl->mMarkupProcessorEnabled )
692 ProcessMarkupString( text, markupProcessData );
693 textSize = markupProcessData.markupProcessedText.size();
695 // This is a bit horrible but std::string returns a (signed) char*
696 utf8 = reinterpret_cast<const uint8_t*>( markupProcessData.markupProcessedText.c_str() );
700 textSize = text.size();
702 // This is a bit horrible but std::string returns a (signed) char*
703 utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
706 // Convert text into UTF-32
707 Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
708 utf32Characters.Resize( textSize );
710 // Transform a text array encoded in utf8 into an array encoded in utf32.
711 // It returns the actual number of characters.
712 Length characterCount = Utf8ToUtf32( utf8, textSize, utf32Characters.Begin() );
713 utf32Characters.Resize( characterCount );
715 DALI_ASSERT_DEBUG( textSize >= characterCount && "Invalid UTF32 conversion length" );
716 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mModel->mLogicalModel->mText.Count() );
718 // The characters to be added.
719 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
721 // To reset the cursor position
722 lastCursorIndex = characterCount;
724 // Update the rest of the model during size negotiation
725 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
727 // The natural size needs to be re-calculated.
728 mImpl->mRecalculateNaturalSize = true;
730 // The text direction needs to be updated.
731 mImpl->mUpdateTextDirection = true;
733 // Apply modifications to the model
734 mImpl->mOperationsPending = ALL_OPERATIONS;
738 ShowPlaceholderText();
741 // Resets the cursor position.
742 ResetCursorPosition( lastCursorIndex );
744 // Scrolls the text to make the cursor visible.
745 ResetScrollPosition();
747 mImpl->RequestRelayout();
749 if( NULL != mImpl->mEventData )
751 // Cancel previously queued events
752 mImpl->mEventData->mEventQueue.clear();
755 // Do this last since it provides callbacks into application code.
756 if( NULL != mImpl->mEditableControlInterface )
758 mImpl->mEditableControlInterface->TextChanged();
762 void Controller::GetText( std::string& text ) const
764 if( !mImpl->IsShowingPlaceholderText() )
766 // Retrieves the text string.
767 mImpl->GetText( 0u, text );
771 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::GetText %p empty (but showing placeholder)\n", this );
775 void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
777 if( NULL != mImpl->mEventData )
779 if( PLACEHOLDER_TYPE_INACTIVE == type )
781 mImpl->mEventData->mPlaceholderTextInactive = text;
785 mImpl->mEventData->mPlaceholderTextActive = text;
788 // Update placeholder if there is no text
789 if( mImpl->IsShowingPlaceholderText() ||
790 ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
792 ShowPlaceholderText();
797 void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
799 if( NULL != mImpl->mEventData )
801 if( PLACEHOLDER_TYPE_INACTIVE == type )
803 text = mImpl->mEventData->mPlaceholderTextInactive;
807 text = mImpl->mEventData->mPlaceholderTextActive;
812 void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
814 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::UpdateAfterFontChange\n");
816 if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
818 DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
819 mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
823 mImpl->RequestRelayout();
827 // public : Default style & Input style
829 void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
831 if( NULL == mImpl->mFontDefaults )
833 mImpl->mFontDefaults = new FontDefaults();
836 mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily;
837 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str());
838 mImpl->mFontDefaults->familyDefined = !defaultFontFamily.empty();
840 if( mImpl->mEventData )
842 // Update the cursor position if it's in editing mode
843 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
845 mImpl->mEventData->mDecoratorUpdated = true;
846 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font family is updated.
850 // Clear the font-specific data
853 mImpl->RequestRelayout();
856 const std::string& Controller::GetDefaultFontFamily() const
858 if( NULL != mImpl->mFontDefaults )
860 return mImpl->mFontDefaults->mFontDescription.family;
866 void Controller::SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily )
868 if( NULL != mImpl->mEventData )
870 if( NULL == mImpl->mEventData->mPlaceholderFont )
872 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
875 mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
876 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
877 mImpl->mEventData->mPlaceholderFont->familyDefined = !placeholderTextFontFamily.empty();
879 mImpl->RequestRelayout();
883 const std::string& Controller::GetPlaceholderFontFamily() const
885 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
887 return mImpl->mEventData->mPlaceholderFont->mFontDescription.family;
893 void Controller::SetDefaultFontWeight( FontWeight weight )
895 if( NULL == mImpl->mFontDefaults )
897 mImpl->mFontDefaults = new FontDefaults();
900 mImpl->mFontDefaults->mFontDescription.weight = weight;
901 mImpl->mFontDefaults->weightDefined = true;
903 if( mImpl->mEventData )
905 // Update the cursor position if it's in editing mode
906 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
908 mImpl->mEventData->mDecoratorUpdated = true;
909 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font weight is updated.
913 // Clear the font-specific data
916 mImpl->RequestRelayout();
919 bool Controller::IsDefaultFontWeightDefined() const
921 if( NULL != mImpl->mFontDefaults )
923 return mImpl->mFontDefaults->weightDefined;
929 FontWeight Controller::GetDefaultFontWeight() const
931 if( NULL != mImpl->mFontDefaults )
933 return mImpl->mFontDefaults->mFontDescription.weight;
936 return TextAbstraction::FontWeight::NORMAL;
939 void Controller::SetPlaceholderTextFontWeight( FontWeight weight )
941 if( NULL != mImpl->mEventData )
943 if( NULL == mImpl->mEventData->mPlaceholderFont )
945 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
948 mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
949 mImpl->mEventData->mPlaceholderFont->weightDefined = true;
951 mImpl->RequestRelayout();
955 bool Controller::IsPlaceholderTextFontWeightDefined() const
957 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
959 return mImpl->mEventData->mPlaceholderFont->weightDefined;
964 FontWeight Controller::GetPlaceholderTextFontWeight() const
966 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
968 return mImpl->mEventData->mPlaceholderFont->mFontDescription.weight;
971 return TextAbstraction::FontWeight::NORMAL;
974 void Controller::SetDefaultFontWidth( FontWidth width )
976 if( NULL == mImpl->mFontDefaults )
978 mImpl->mFontDefaults = new FontDefaults();
981 mImpl->mFontDefaults->mFontDescription.width = width;
982 mImpl->mFontDefaults->widthDefined = true;
984 if( mImpl->mEventData )
986 // Update the cursor position if it's in editing mode
987 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
989 mImpl->mEventData->mDecoratorUpdated = true;
990 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font width is updated.
994 // Clear the font-specific data
997 mImpl->RequestRelayout();
1000 bool Controller::IsDefaultFontWidthDefined() const
1002 if( NULL != mImpl->mFontDefaults )
1004 return mImpl->mFontDefaults->widthDefined;
1010 FontWidth Controller::GetDefaultFontWidth() const
1012 if( NULL != mImpl->mFontDefaults )
1014 return mImpl->mFontDefaults->mFontDescription.width;
1017 return TextAbstraction::FontWidth::NORMAL;
1020 void Controller::SetPlaceholderTextFontWidth( FontWidth width )
1022 if( NULL != mImpl->mEventData )
1024 if( NULL == mImpl->mEventData->mPlaceholderFont )
1026 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
1029 mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
1030 mImpl->mEventData->mPlaceholderFont->widthDefined = true;
1032 mImpl->RequestRelayout();
1036 bool Controller::IsPlaceholderTextFontWidthDefined() const
1038 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1040 return mImpl->mEventData->mPlaceholderFont->widthDefined;
1045 FontWidth Controller::GetPlaceholderTextFontWidth() const
1047 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1049 return mImpl->mEventData->mPlaceholderFont->mFontDescription.width;
1052 return TextAbstraction::FontWidth::NORMAL;
1055 void Controller::SetDefaultFontSlant( FontSlant slant )
1057 if( NULL == mImpl->mFontDefaults )
1059 mImpl->mFontDefaults = new FontDefaults();
1062 mImpl->mFontDefaults->mFontDescription.slant = slant;
1063 mImpl->mFontDefaults->slantDefined = true;
1065 if( mImpl->mEventData )
1067 // Update the cursor position if it's in editing mode
1068 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
1070 mImpl->mEventData->mDecoratorUpdated = true;
1071 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font slant is updated.
1075 // Clear the font-specific data
1078 mImpl->RequestRelayout();
1081 bool Controller::IsDefaultFontSlantDefined() const
1083 if( NULL != mImpl->mFontDefaults )
1085 return mImpl->mFontDefaults->slantDefined;
1090 FontSlant Controller::GetDefaultFontSlant() const
1092 if( NULL != mImpl->mFontDefaults )
1094 return mImpl->mFontDefaults->mFontDescription.slant;
1097 return TextAbstraction::FontSlant::NORMAL;
1100 void Controller::SetPlaceholderTextFontSlant( FontSlant slant )
1102 if( NULL != mImpl->mEventData )
1104 if( NULL == mImpl->mEventData->mPlaceholderFont )
1106 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
1109 mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
1110 mImpl->mEventData->mPlaceholderFont->slantDefined = true;
1112 mImpl->RequestRelayout();
1116 bool Controller::IsPlaceholderTextFontSlantDefined() const
1118 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1120 return mImpl->mEventData->mPlaceholderFont->slantDefined;
1125 FontSlant Controller::GetPlaceholderTextFontSlant() const
1127 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1129 return mImpl->mEventData->mPlaceholderFont->mFontDescription.slant;
1132 return TextAbstraction::FontSlant::NORMAL;
1135 void Controller::SetDefaultFontSize( float fontSize, FontSizeType type )
1137 if( NULL == mImpl->mFontDefaults )
1139 mImpl->mFontDefaults = new FontDefaults();
1146 mImpl->mFontDefaults->mDefaultPointSize = fontSize;
1147 mImpl->mFontDefaults->sizeDefined = true;
1152 // Point size = Pixel size * 72.f / DPI
1153 unsigned int horizontalDpi = 0u;
1154 unsigned int verticalDpi = 0u;
1155 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1156 fontClient.GetDpi( horizontalDpi, verticalDpi );
1158 mImpl->mFontDefaults->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
1159 mImpl->mFontDefaults->sizeDefined = true;
1164 if( mImpl->mEventData )
1166 // Update the cursor position if it's in editing mode
1167 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
1169 mImpl->mEventData->mDecoratorUpdated = true;
1170 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font size is updated.
1174 // Clear the font-specific data
1177 mImpl->RequestRelayout();
1180 float Controller::GetDefaultFontSize( FontSizeType type ) const
1183 if( NULL != mImpl->mFontDefaults )
1189 value = mImpl->mFontDefaults->mDefaultPointSize;
1194 // Pixel size = Point size * DPI / 72.f
1195 unsigned int horizontalDpi = 0u;
1196 unsigned int verticalDpi = 0u;
1197 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1198 fontClient.GetDpi( horizontalDpi, verticalDpi );
1200 value = mImpl->mFontDefaults->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
1210 void Controller::SetPlaceholderTextFontSize( float fontSize, FontSizeType type )
1212 if( NULL != mImpl->mEventData )
1214 if( NULL == mImpl->mEventData->mPlaceholderFont )
1216 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
1223 mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = fontSize;
1224 mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
1225 mImpl->mEventData->mIsPlaceholderPixelSize = false; // Font size flag
1230 // Point size = Pixel size * 72.f / DPI
1231 unsigned int horizontalDpi = 0u;
1232 unsigned int verticalDpi = 0u;
1233 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1234 fontClient.GetDpi( horizontalDpi, verticalDpi );
1236 mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
1237 mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
1238 mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag
1243 mImpl->RequestRelayout();
1247 float Controller::GetPlaceholderTextFontSize( FontSizeType type ) const
1250 if( NULL != mImpl->mEventData )
1256 if( NULL != mImpl->mEventData->mPlaceholderFont )
1258 value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize;
1262 // If the placeholder text font size is not set, then return the default font size.
1263 value = GetDefaultFontSize( POINT_SIZE );
1269 if( NULL != mImpl->mEventData->mPlaceholderFont )
1271 // Pixel size = Point size * DPI / 72.f
1272 unsigned int horizontalDpi = 0u;
1273 unsigned int verticalDpi = 0u;
1274 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1275 fontClient.GetDpi( horizontalDpi, verticalDpi );
1277 value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
1281 // If the placeholder text font size is not set, then return the default font size.
1282 value = GetDefaultFontSize( PIXEL_SIZE );
1293 void Controller::SetDefaultColor( const Vector4& color )
1295 mImpl->mTextColor = color;
1297 if( !mImpl->IsShowingPlaceholderText() )
1299 mImpl->mModel->mVisualModel->SetTextColor( color );
1301 mImpl->mModel->mLogicalModel->mColorRuns.Clear();
1303 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | COLOR );
1305 mImpl->RequestRelayout();
1309 const Vector4& Controller::GetDefaultColor() const
1311 return mImpl->mTextColor;
1314 void Controller::SetPlaceholderTextColor( const Vector4& textColor )
1316 if( NULL != mImpl->mEventData )
1318 mImpl->mEventData->mPlaceholderTextColor = textColor;
1321 if( mImpl->IsShowingPlaceholderText() )
1323 mImpl->mModel->mVisualModel->SetTextColor( textColor );
1324 mImpl->RequestRelayout();
1328 const Vector4& Controller::GetPlaceholderTextColor() const
1330 if( NULL != mImpl->mEventData )
1332 return mImpl->mEventData->mPlaceholderTextColor;
1335 return Color::BLACK;
1338 void Controller::SetShadowOffset( const Vector2& shadowOffset )
1340 mImpl->mModel->mVisualModel->SetShadowOffset( shadowOffset );
1342 mImpl->RequestRelayout();
1345 const Vector2& Controller::GetShadowOffset() const
1347 return mImpl->mModel->mVisualModel->GetShadowOffset();
1350 void Controller::SetShadowColor( const Vector4& shadowColor )
1352 mImpl->mModel->mVisualModel->SetShadowColor( shadowColor );
1354 mImpl->RequestRelayout();
1357 const Vector4& Controller::GetShadowColor() const
1359 return mImpl->mModel->mVisualModel->GetShadowColor();
1362 void Controller::SetShadowBlurRadius( const float& shadowBlurRadius )
1364 if ( fabsf( GetShadowBlurRadius() - shadowBlurRadius ) > Math::MACHINE_EPSILON_1 )
1366 mImpl->mModel->mVisualModel->SetShadowBlurRadius( shadowBlurRadius );
1368 mImpl->RequestRelayout();
1372 const float& Controller::GetShadowBlurRadius() const
1374 return mImpl->mModel->mVisualModel->GetShadowBlurRadius();
1377 void Controller::SetUnderlineColor( const Vector4& color )
1379 mImpl->mModel->mVisualModel->SetUnderlineColor( color );
1381 mImpl->RequestRelayout();
1384 const Vector4& Controller::GetUnderlineColor() const
1386 return mImpl->mModel->mVisualModel->GetUnderlineColor();
1389 void Controller::SetUnderlineEnabled( bool enabled )
1391 mImpl->mModel->mVisualModel->SetUnderlineEnabled( enabled );
1393 mImpl->RequestRelayout();
1396 bool Controller::IsUnderlineEnabled() const
1398 return mImpl->mModel->mVisualModel->IsUnderlineEnabled();
1401 void Controller::SetUnderlineHeight( float height )
1403 mImpl->mModel->mVisualModel->SetUnderlineHeight( height );
1405 mImpl->RequestRelayout();
1408 float Controller::GetUnderlineHeight() const
1410 return mImpl->mModel->mVisualModel->GetUnderlineHeight();
1413 void Controller::SetOutlineColor( const Vector4& color )
1415 mImpl->mModel->mVisualModel->SetOutlineColor( color );
1417 mImpl->RequestRelayout();
1420 const Vector4& Controller::GetOutlineColor() const
1422 return mImpl->mModel->mVisualModel->GetOutlineColor();
1425 void Controller::SetOutlineWidth( uint16_t width )
1427 mImpl->mModel->mVisualModel->SetOutlineWidth( width );
1429 mImpl->RequestRelayout();
1432 uint16_t Controller::GetOutlineWidth() const
1434 return mImpl->mModel->mVisualModel->GetOutlineWidth();
1437 void Controller::SetBackgroundColor( const Vector4& color )
1439 mImpl->mModel->mVisualModel->SetBackgroundColor( color );
1441 mImpl->RequestRelayout();
1444 const Vector4& Controller::GetBackgroundColor() const
1446 return mImpl->mModel->mVisualModel->GetBackgroundColor();
1449 void Controller::SetBackgroundEnabled( bool enabled )
1451 mImpl->mModel->mVisualModel->SetBackgroundEnabled( enabled );
1453 mImpl->RequestRelayout();
1456 bool Controller::IsBackgroundEnabled() const
1458 return mImpl->mModel->mVisualModel->IsBackgroundEnabled();
1461 void Controller::SetDefaultEmbossProperties( const std::string& embossProperties )
1463 if( NULL == mImpl->mEmbossDefaults )
1465 mImpl->mEmbossDefaults = new EmbossDefaults();
1468 mImpl->mEmbossDefaults->properties = embossProperties;
1471 const std::string& Controller::GetDefaultEmbossProperties() const
1473 if( NULL != mImpl->mEmbossDefaults )
1475 return mImpl->mEmbossDefaults->properties;
1478 return EMPTY_STRING;
1481 void Controller::SetDefaultOutlineProperties( const std::string& outlineProperties )
1483 if( NULL == mImpl->mOutlineDefaults )
1485 mImpl->mOutlineDefaults = new OutlineDefaults();
1488 mImpl->mOutlineDefaults->properties = outlineProperties;
1491 const std::string& Controller::GetDefaultOutlineProperties() const
1493 if( NULL != mImpl->mOutlineDefaults )
1495 return mImpl->mOutlineDefaults->properties;
1498 return EMPTY_STRING;
1501 bool Controller::SetDefaultLineSpacing( float lineSpacing )
1503 if( std::fabs( lineSpacing - mImpl->mLayoutEngine.GetDefaultLineSpacing() ) > Math::MACHINE_EPSILON_1000 )
1505 mImpl->mLayoutEngine.SetDefaultLineSpacing(lineSpacing);
1506 mImpl->mRecalculateNaturalSize = true;
1512 float Controller::GetDefaultLineSpacing() const
1514 return mImpl->mLayoutEngine.GetDefaultLineSpacing();
1517 bool Controller::SetDefaultLineSize( float lineSize )
1519 if( std::fabs( lineSize - mImpl->mLayoutEngine.GetDefaultLineSize() ) > Math::MACHINE_EPSILON_1000 )
1521 mImpl->mLayoutEngine.SetDefaultLineSize(lineSize);
1522 mImpl->mRecalculateNaturalSize = true;
1528 float Controller::GetDefaultLineSize() const
1530 return mImpl->mLayoutEngine.GetDefaultLineSize();
1533 void Controller::SetInputColor( const Vector4& color )
1535 if( NULL != mImpl->mEventData )
1537 mImpl->mEventData->mInputStyle.textColor = color;
1538 mImpl->mEventData->mInputStyle.isDefaultColor = false;
1540 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1542 const bool handlesCrossed = mImpl->mEventData->mLeftSelectionPosition > mImpl->mEventData->mRightSelectionPosition;
1544 // Get start and end position of selection
1545 const CharacterIndex startOfSelectedText = handlesCrossed ? mImpl->mEventData->mRightSelectionPosition : mImpl->mEventData->mLeftSelectionPosition;
1546 const Length lengthOfSelectedText = ( handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition ) - startOfSelectedText;
1548 // Add the color run.
1549 const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
1550 mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
1552 ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
1553 colorRun.color = color;
1554 colorRun.characterRun.characterIndex = startOfSelectedText;
1555 colorRun.characterRun.numberOfCharacters = lengthOfSelectedText;
1557 // Request to relayout.
1558 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | COLOR );
1559 mImpl->RequestRelayout();
1561 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1562 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1563 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1568 const Vector4& Controller::GetInputColor() const
1570 if( NULL != mImpl->mEventData )
1572 return mImpl->mEventData->mInputStyle.textColor;
1575 // Return the default text's color if there is no EventData.
1576 return mImpl->mTextColor;
1580 void Controller::SetInputFontFamily( const std::string& fontFamily )
1582 if( NULL != mImpl->mEventData )
1584 mImpl->mEventData->mInputStyle.familyName = fontFamily;
1585 mImpl->mEventData->mInputStyle.isFamilyDefined = true;
1587 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1589 CharacterIndex startOfSelectedText = 0u;
1590 Length lengthOfSelectedText = 0u;
1592 if( EventData::SELECTING == mImpl->mEventData->mState )
1594 // Update a font description run for the selecting state.
1595 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1596 mImpl->mModel->mLogicalModel,
1597 startOfSelectedText,
1598 lengthOfSelectedText );
1600 fontDescriptionRun.familyLength = fontFamily.size();
1601 fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
1602 memcpy( fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength );
1603 fontDescriptionRun.familyDefined = true;
1605 // The memory allocated for the font family name is freed when the font description is removed from the logical model.
1607 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1608 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1609 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1613 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1614 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1615 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1618 // Request to relayout.
1619 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1624 UPDATE_LAYOUT_SIZE |
1627 mImpl->mRecalculateNaturalSize = true;
1628 mImpl->RequestRelayout();
1630 // As the font changes, recalculate the handle positions is needed.
1631 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1632 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1633 mImpl->mEventData->mUpdateHighlightBox = true;
1634 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1639 const std::string& Controller::GetInputFontFamily() const
1641 if( NULL != mImpl->mEventData )
1643 return mImpl->mEventData->mInputStyle.familyName;
1646 // Return the default font's family if there is no EventData.
1647 return GetDefaultFontFamily();
1650 void Controller::SetInputFontWeight( FontWeight weight )
1652 if( NULL != mImpl->mEventData )
1654 mImpl->mEventData->mInputStyle.weight = weight;
1655 mImpl->mEventData->mInputStyle.isWeightDefined = true;
1657 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1659 CharacterIndex startOfSelectedText = 0u;
1660 Length lengthOfSelectedText = 0u;
1662 if( EventData::SELECTING == mImpl->mEventData->mState )
1664 // Update a font description run for the selecting state.
1665 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1666 mImpl->mModel->mLogicalModel,
1667 startOfSelectedText,
1668 lengthOfSelectedText );
1670 fontDescriptionRun.weight = weight;
1671 fontDescriptionRun.weightDefined = true;
1673 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1674 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1675 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1679 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1680 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1681 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1684 // Request to relayout.
1685 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1690 UPDATE_LAYOUT_SIZE |
1693 mImpl->mRecalculateNaturalSize = true;
1694 mImpl->RequestRelayout();
1696 // As the font might change, recalculate the handle positions is needed.
1697 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1698 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1699 mImpl->mEventData->mUpdateHighlightBox = true;
1700 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1705 bool Controller::IsInputFontWeightDefined() const
1707 bool defined = false;
1709 if( NULL != mImpl->mEventData )
1711 defined = mImpl->mEventData->mInputStyle.isWeightDefined;
1717 FontWeight Controller::GetInputFontWeight() const
1719 if( NULL != mImpl->mEventData )
1721 return mImpl->mEventData->mInputStyle.weight;
1724 return GetDefaultFontWeight();
1727 void Controller::SetInputFontWidth( FontWidth width )
1729 if( NULL != mImpl->mEventData )
1731 mImpl->mEventData->mInputStyle.width = width;
1732 mImpl->mEventData->mInputStyle.isWidthDefined = true;
1734 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1736 CharacterIndex startOfSelectedText = 0u;
1737 Length lengthOfSelectedText = 0u;
1739 if( EventData::SELECTING == mImpl->mEventData->mState )
1741 // Update a font description run for the selecting state.
1742 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1743 mImpl->mModel->mLogicalModel,
1744 startOfSelectedText,
1745 lengthOfSelectedText );
1747 fontDescriptionRun.width = width;
1748 fontDescriptionRun.widthDefined = true;
1750 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1751 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1752 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1756 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1757 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1758 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1761 // Request to relayout.
1762 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1767 UPDATE_LAYOUT_SIZE |
1770 mImpl->mRecalculateNaturalSize = true;
1771 mImpl->RequestRelayout();
1773 // As the font might change, recalculate the handle positions is needed.
1774 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1775 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1776 mImpl->mEventData->mUpdateHighlightBox = true;
1777 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1782 bool Controller::IsInputFontWidthDefined() const
1784 bool defined = false;
1786 if( NULL != mImpl->mEventData )
1788 defined = mImpl->mEventData->mInputStyle.isWidthDefined;
1794 FontWidth Controller::GetInputFontWidth() const
1796 if( NULL != mImpl->mEventData )
1798 return mImpl->mEventData->mInputStyle.width;
1801 return GetDefaultFontWidth();
1804 void Controller::SetInputFontSlant( FontSlant slant )
1806 if( NULL != mImpl->mEventData )
1808 mImpl->mEventData->mInputStyle.slant = slant;
1809 mImpl->mEventData->mInputStyle.isSlantDefined = true;
1811 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1813 CharacterIndex startOfSelectedText = 0u;
1814 Length lengthOfSelectedText = 0u;
1816 if( EventData::SELECTING == mImpl->mEventData->mState )
1818 // Update a font description run for the selecting state.
1819 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1820 mImpl->mModel->mLogicalModel,
1821 startOfSelectedText,
1822 lengthOfSelectedText );
1824 fontDescriptionRun.slant = slant;
1825 fontDescriptionRun.slantDefined = true;
1827 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1828 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1829 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1833 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1834 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1835 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1838 // Request to relayout.
1839 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1844 UPDATE_LAYOUT_SIZE |
1847 mImpl->mRecalculateNaturalSize = true;
1848 mImpl->RequestRelayout();
1850 // As the font might change, recalculate the handle positions is needed.
1851 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1852 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1853 mImpl->mEventData->mUpdateHighlightBox = true;
1854 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1859 bool Controller::IsInputFontSlantDefined() const
1861 bool defined = false;
1863 if( NULL != mImpl->mEventData )
1865 defined = mImpl->mEventData->mInputStyle.isSlantDefined;
1871 FontSlant Controller::GetInputFontSlant() const
1873 if( NULL != mImpl->mEventData )
1875 return mImpl->mEventData->mInputStyle.slant;
1878 return GetDefaultFontSlant();
1881 void Controller::SetInputFontPointSize( float size )
1883 if( NULL != mImpl->mEventData )
1885 mImpl->mEventData->mInputStyle.size = size;
1886 mImpl->mEventData->mInputStyle.isSizeDefined = true;
1888 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1890 CharacterIndex startOfSelectedText = 0u;
1891 Length lengthOfSelectedText = 0u;
1893 if( EventData::SELECTING == mImpl->mEventData->mState )
1895 // Update a font description run for the selecting state.
1896 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1897 mImpl->mModel->mLogicalModel,
1898 startOfSelectedText,
1899 lengthOfSelectedText );
1901 fontDescriptionRun.size = static_cast<PointSize26Dot6>( size * 64.f );
1902 fontDescriptionRun.sizeDefined = true;
1904 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1905 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1906 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1910 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1911 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1912 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1915 // Request to relayout.
1916 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1921 UPDATE_LAYOUT_SIZE |
1924 mImpl->mRecalculateNaturalSize = true;
1925 mImpl->RequestRelayout();
1927 // As the font might change, recalculate the handle positions is needed.
1928 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1929 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1930 mImpl->mEventData->mUpdateHighlightBox = true;
1931 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1936 float Controller::GetInputFontPointSize() const
1938 if( NULL != mImpl->mEventData )
1940 return mImpl->mEventData->mInputStyle.size;
1943 // Return the default font's point size if there is no EventData.
1944 return GetDefaultFontSize( Text::Controller::POINT_SIZE );
1947 void Controller::SetInputLineSpacing( float lineSpacing )
1949 if( NULL != mImpl->mEventData )
1951 mImpl->mEventData->mInputStyle.lineSpacing = lineSpacing;
1952 mImpl->mEventData->mInputStyle.isLineSpacingDefined = true;
1956 float Controller::GetInputLineSpacing() const
1958 if( NULL != mImpl->mEventData )
1960 return mImpl->mEventData->mInputStyle.lineSpacing;
1966 void Controller::SetInputShadowProperties( const std::string& shadowProperties )
1968 if( NULL != mImpl->mEventData )
1970 mImpl->mEventData->mInputStyle.shadowProperties = shadowProperties;
1974 const std::string& Controller::GetInputShadowProperties() const
1976 if( NULL != mImpl->mEventData )
1978 return mImpl->mEventData->mInputStyle.shadowProperties;
1981 return EMPTY_STRING;
1984 void Controller::SetInputUnderlineProperties( const std::string& underlineProperties )
1986 if( NULL != mImpl->mEventData )
1988 mImpl->mEventData->mInputStyle.underlineProperties = underlineProperties;
1992 const std::string& Controller::GetInputUnderlineProperties() const
1994 if( NULL != mImpl->mEventData )
1996 return mImpl->mEventData->mInputStyle.underlineProperties;
1999 return EMPTY_STRING;
2002 void Controller::SetInputEmbossProperties( const std::string& embossProperties )
2004 if( NULL != mImpl->mEventData )
2006 mImpl->mEventData->mInputStyle.embossProperties = embossProperties;
2010 const std::string& Controller::GetInputEmbossProperties() const
2012 if( NULL != mImpl->mEventData )
2014 return mImpl->mEventData->mInputStyle.embossProperties;
2017 return GetDefaultEmbossProperties();
2020 void Controller::SetInputOutlineProperties( const std::string& outlineProperties )
2022 if( NULL != mImpl->mEventData )
2024 mImpl->mEventData->mInputStyle.outlineProperties = outlineProperties;
2028 const std::string& Controller::GetInputOutlineProperties() const
2030 if( NULL != mImpl->mEventData )
2032 return mImpl->mEventData->mInputStyle.outlineProperties;
2035 return GetDefaultOutlineProperties();
2038 void Controller::SetInputModePassword( bool passwordInput )
2040 if( NULL != mImpl->mEventData )
2042 mImpl->mEventData->mPasswordInput = passwordInput;
2046 bool Controller::IsInputModePassword()
2048 if( NULL != mImpl->mEventData )
2050 return mImpl->mEventData->mPasswordInput;
2055 void Controller::SetNoTextDoubleTapAction( NoTextTap::Action action )
2057 if( NULL != mImpl->mEventData )
2059 mImpl->mEventData->mDoubleTapAction = action;
2063 Controller::NoTextTap::Action Controller::GetNoTextDoubleTapAction() const
2065 NoTextTap::Action action = NoTextTap::NO_ACTION;
2067 if( NULL != mImpl->mEventData )
2069 action = mImpl->mEventData->mDoubleTapAction;
2075 void Controller::SetNoTextLongPressAction( NoTextTap::Action action )
2077 if( NULL != mImpl->mEventData )
2079 mImpl->mEventData->mLongPressAction = action;
2083 Controller::NoTextTap::Action Controller::GetNoTextLongPressAction() const
2085 NoTextTap::Action action = NoTextTap::NO_ACTION;
2087 if( NULL != mImpl->mEventData )
2089 action = mImpl->mEventData->mLongPressAction;
2095 bool Controller::IsUnderlineSetByString()
2097 return mImpl->mUnderlineSetByString;
2100 void Controller::UnderlineSetByString( bool setByString )
2102 mImpl->mUnderlineSetByString = setByString;
2105 bool Controller::IsShadowSetByString()
2107 return mImpl->mShadowSetByString;
2110 void Controller::ShadowSetByString( bool setByString )
2112 mImpl->mShadowSetByString = setByString;
2115 bool Controller::IsOutlineSetByString()
2117 return mImpl->mOutlineSetByString;
2120 void Controller::OutlineSetByString( bool setByString )
2122 mImpl->mOutlineSetByString = setByString;
2125 bool Controller::IsFontStyleSetByString()
2127 return mImpl->mFontStyleSetByString;
2130 void Controller::FontStyleSetByString( bool setByString )
2132 mImpl->mFontStyleSetByString = setByString;
2135 // public : Queries & retrieves.
2137 Layout::Engine& Controller::GetLayoutEngine()
2139 return mImpl->mLayoutEngine;
2142 View& Controller::GetView()
2144 return mImpl->mView;
2147 Vector3 Controller::GetNaturalSize()
2149 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
2150 Vector3 naturalSize;
2152 // Make sure the model is up-to-date before layouting
2153 ProcessModifyEvents();
2155 if( mImpl->mRecalculateNaturalSize )
2157 // Operations that can be done only once until the text changes.
2158 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2164 GET_GLYPH_METRICS );
2166 // Set the update info to relayout the whole text.
2167 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2168 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2170 // Make sure the model is up-to-date before layouting
2171 mImpl->UpdateModel( onlyOnceOperations );
2173 // Layout the text for the new width.
2174 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | LAYOUT | REORDER );
2176 // Store the actual control's size to restore later.
2177 const Size actualControlSize = mImpl->mModel->mVisualModel->mControlSize;
2179 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
2180 static_cast<OperationsMask>( onlyOnceOperations |
2182 naturalSize.GetVectorXY() );
2184 // Do not do again the only once operations.
2185 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
2187 // Do the size related operations again.
2188 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
2191 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
2193 // Stores the natural size to avoid recalculate it again
2194 // unless the text/style changes.
2195 mImpl->mModel->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
2197 mImpl->mRecalculateNaturalSize = false;
2199 // Clear the update info. This info will be set the next time the text is updated.
2200 mImpl->mTextUpdateInfo.Clear();
2201 mImpl->mTextUpdateInfo.mClearAll = true;
2203 // Restore the actual control's size.
2204 mImpl->mModel->mVisualModel->mControlSize = actualControlSize;
2206 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
2210 naturalSize = mImpl->mModel->mVisualModel->GetNaturalSize();
2212 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
2215 naturalSize.x = ConvertToEven( naturalSize.x );
2216 naturalSize.y = ConvertToEven( naturalSize.y );
2221 bool Controller::CheckForTextFit( float pointSize, Size& layoutSize )
2224 mImpl->mFontDefaults->mFitPointSize = pointSize;
2225 mImpl->mFontDefaults->sizeDefined = true;
2228 // Operations that can be done only once until the text changes.
2229 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2235 GET_GLYPH_METRICS );
2237 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2238 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2240 // Make sure the model is up-to-date before layouting
2241 mImpl->UpdateModel( onlyOnceOperations );
2243 DoRelayout( Size( layoutSize.width, MAX_FLOAT ),
2244 static_cast<OperationsMask>( onlyOnceOperations | LAYOUT),
2247 // Clear the update info. This info will be set the next time the text is updated.
2248 mImpl->mTextUpdateInfo.Clear();
2249 mImpl->mTextUpdateInfo.mClearAll = true;
2251 if( textSize.width > layoutSize.width || textSize.height > layoutSize.height )
2258 void Controller::FitPointSizeforLayout( Size layoutSize )
2260 const OperationsMask operations = mImpl->mOperationsPending;
2261 if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) || mImpl->mTextFitContentSize != layoutSize )
2263 bool actualellipsis = mImpl->mModel->mElideEnabled;
2264 float minPointSize = mImpl->mTextFitMinSize;
2265 float maxPointSize = mImpl->mTextFitMaxSize;
2266 float pointInterval = mImpl->mTextFitStepSize;
2268 mImpl->mModel->mElideEnabled = false;
2269 Vector<float> pointSizeArray;
2272 if( pointInterval < 1.f )
2274 mImpl->mTextFitStepSize = pointInterval = 1.0f;
2277 pointSizeArray.Reserve( static_cast< unsigned int >( ceil( ( maxPointSize - minPointSize ) / pointInterval ) ) );
2279 for( float i = minPointSize; i < maxPointSize; i += pointInterval )
2281 pointSizeArray.PushBack( i );
2284 pointSizeArray.PushBack( maxPointSize );
2286 int bestSizeIndex = 0;
2287 int min = bestSizeIndex + 1;
2288 int max = pointSizeArray.Size() - 1;
2291 int destI = ( min + max ) / 2;
2293 if( CheckForTextFit( pointSizeArray[destI], layoutSize ) )
2295 bestSizeIndex = min;
2301 bestSizeIndex = max;
2305 mImpl->mModel->mElideEnabled = actualellipsis;
2306 mImpl->mFontDefaults->mFitPointSize = pointSizeArray[bestSizeIndex];
2307 mImpl->mFontDefaults->sizeDefined = true;
2312 float Controller::GetHeightForWidth( float width )
2314 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", this, width );
2315 // Make sure the model is up-to-date before layouting
2316 ProcessModifyEvents();
2319 if( fabsf( width - mImpl->mModel->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 ||
2320 mImpl->mTextUpdateInfo.mFullRelayoutNeeded ||
2321 mImpl->mTextUpdateInfo.mClearAll )
2323 // Operations that can be done only once until the text changes.
2324 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2330 GET_GLYPH_METRICS );
2332 // Set the update info to relayout the whole text.
2333 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2334 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2336 // Make sure the model is up-to-date before layouting
2337 mImpl->UpdateModel( onlyOnceOperations );
2340 // Layout the text for the new width.
2341 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | LAYOUT );
2343 // Store the actual control's width.
2344 const float actualControlWidth = mImpl->mModel->mVisualModel->mControlSize.width;
2346 DoRelayout( Size( width, MAX_FLOAT ),
2347 static_cast<OperationsMask>( onlyOnceOperations |
2351 // Do not do again the only once operations.
2352 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
2354 // Do the size related operations again.
2355 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
2359 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
2361 // Clear the update info. This info will be set the next time the text is updated.
2362 mImpl->mTextUpdateInfo.Clear();
2363 mImpl->mTextUpdateInfo.mClearAll = true;
2365 // Restore the actual control's width.
2366 mImpl->mModel->mVisualModel->mControlSize.width = actualControlWidth;
2368 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
2372 layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
2373 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
2376 return layoutSize.height;
2379 int Controller::GetLineCount( float width )
2381 GetHeightForWidth( width );
2382 int numberofLines = mImpl->mModel->GetNumberOfLines();
2383 return numberofLines;
2386 const ModelInterface* const Controller::GetTextModel() const
2388 return mImpl->mModel.Get();
2391 float Controller::GetScrollAmountByUserInput()
2393 float scrollAmount = 0.0f;
2395 if (NULL != mImpl->mEventData && mImpl->mEventData->mCheckScrollAmount)
2397 scrollAmount = mImpl->mModel->mScrollPosition.y - mImpl->mModel->mScrollPositionLast.y;
2398 mImpl->mEventData->mCheckScrollAmount = false;
2400 return scrollAmount;
2403 bool Controller::GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight )
2405 const Vector2& layout = mImpl->mModel->mVisualModel->GetLayoutSize();
2408 controlHeight = mImpl->mModel->mVisualModel->mControlSize.height;
2409 layoutHeight = layout.height;
2410 scrollPosition = mImpl->mModel->mScrollPosition.y;
2411 isScrolled = !Equals( mImpl->mModel->mScrollPosition.y, mImpl->mModel->mScrollPositionLast.y, Math::MACHINE_EPSILON_1 );
2415 void Controller::SetHiddenInputOption(const Property::Map& options )
2417 if( NULL == mImpl->mHiddenInput )
2419 mImpl->mHiddenInput = new HiddenText( this );
2421 mImpl->mHiddenInput->SetProperties(options);
2424 void Controller::GetHiddenInputOption(Property::Map& options )
2426 if( NULL != mImpl->mHiddenInput )
2428 mImpl->mHiddenInput->GetProperties(options);
2432 void Controller::SetPlaceholderProperty( const Property::Map& map )
2434 const Property::Map::SizeType count = map.Count();
2436 for( Property::Map::SizeType position = 0; position < count; ++position )
2438 KeyValuePair keyValue = map.GetKeyValue( position );
2439 Property::Key& key = keyValue.first;
2440 Property::Value& value = keyValue.second;
2442 if( key == Toolkit::Text::PlaceHolder::Property::TEXT || key == PLACEHOLDER_TEXT )
2444 std::string text = "";
2446 SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
2448 else if( key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED )
2450 std::string text = "";
2452 SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
2454 else if( key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR )
2457 value.Get( textColor );
2458 if( GetPlaceholderTextColor() != textColor )
2460 SetPlaceholderTextColor( textColor );
2463 else if( key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY )
2465 std::string fontFamily = "";
2466 value.Get( fontFamily );
2467 SetPlaceholderFontFamily( fontFamily );
2469 else if( key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE )
2471 SetFontStyleProperty( this, value, Text::FontStyle::PLACEHOLDER );
2473 else if( key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE )
2476 value.Get( pointSize );
2477 if( !Equals( GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
2479 SetPlaceholderTextFontSize( pointSize, Text::Controller::POINT_SIZE );
2482 else if( key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE )
2485 value.Get( pixelSize );
2486 if( !Equals( GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
2488 SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
2491 else if( key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS )
2494 value.Get( ellipsis );
2495 SetPlaceholderTextElideEnabled( ellipsis );
2500 void Controller::GetPlaceholderProperty( Property::Map& map )
2502 if( NULL != mImpl->mEventData )
2504 if( !mImpl->mEventData->mPlaceholderTextActive.empty() )
2506 map[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive;
2508 if( !mImpl->mEventData->mPlaceholderTextInactive.empty() )
2510 map[ Text::PlaceHolder::Property::TEXT ] = mImpl->mEventData->mPlaceholderTextInactive;
2513 map[ Text::PlaceHolder::Property::COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
2514 map[ Text::PlaceHolder::Property::FONT_FAMILY ] = GetPlaceholderFontFamily();
2516 Property::Value fontStyleMapGet;
2517 GetFontStyleProperty( this, fontStyleMapGet, Text::FontStyle::PLACEHOLDER );
2518 map[ Text::PlaceHolder::Property::FONT_STYLE ] = fontStyleMapGet;
2520 // Choose font size : POINT_SIZE or PIXEL_SIZE
2521 if( !mImpl->mEventData->mIsPlaceholderPixelSize )
2523 map[ Text::PlaceHolder::Property::POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE );
2527 map[ Text::PlaceHolder::Property::PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE );
2530 if( mImpl->mEventData->mPlaceholderEllipsisFlag )
2532 map[ Text::PlaceHolder::Property::ELLIPSIS ] = IsPlaceholderTextElideEnabled();
2537 Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection()
2539 // Make sure the model is up-to-date before layouting
2540 ProcessModifyEvents();
2542 if ( mImpl->mUpdateTextDirection )
2544 // Operations that can be done only once until the text changes.
2545 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2551 GET_GLYPH_METRICS );
2553 // Set the update info to relayout the whole text.
2554 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2555 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2557 // Make sure the model is up-to-date before layouting
2558 mImpl->UpdateModel( onlyOnceOperations );
2560 Vector3 naturalSize;
2561 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
2562 static_cast<OperationsMask>( onlyOnceOperations |
2563 LAYOUT | REORDER | UPDATE_DIRECTION ),
2564 naturalSize.GetVectorXY() );
2566 // Do not do again the only once operations.
2567 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
2569 // Clear the update info. This info will be set the next time the text is updated.
2570 mImpl->mTextUpdateInfo.Clear();
2572 // FullRelayoutNeeded should be true because DoRelayout is MAX_FLOAT, MAX_FLOAT.
2573 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
2575 mImpl->mUpdateTextDirection = false;
2578 return mImpl->mIsTextDirectionRTL ? Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT : Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
2581 Toolkit::DevelText::VerticalLineAlignment::Type Controller::GetVerticalLineAlignment() const
2583 return mImpl->mModel->GetVerticalLineAlignment();
2586 void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment )
2588 mImpl->mModel->mVerticalLineAlignment = alignment;
2591 // public : Relayout.
2593 Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection )
2595 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f, autoScroll[%s]\n", this, size.width, size.height, mImpl->mIsAutoScrollEnabled ?"true":"false" );
2597 UpdateTextType updateTextType = NONE_UPDATED;
2599 if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
2601 if( 0u != mImpl->mModel->mVisualModel->mGlyphPositions.Count() )
2603 mImpl->mModel->mVisualModel->mGlyphPositions.Clear();
2604 updateTextType = MODEL_UPDATED;
2607 // Clear the update info. This info will be set the next time the text is updated.
2608 mImpl->mTextUpdateInfo.Clear();
2610 // Not worth to relayout if width or height is equal to zero.
2611 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
2613 return updateTextType;
2616 // Whether a new size has been set.
2617 const bool newSize = ( size != mImpl->mModel->mVisualModel->mControlSize );
2621 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mModel->mVisualModel->mControlSize.width, mImpl->mModel->mVisualModel->mControlSize.height );
2623 if( ( 0 == mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd ) &&
2624 ( 0 == mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) &&
2625 ( ( mImpl->mModel->mVisualModel->mControlSize.width < Math::MACHINE_EPSILON_1000 ) || ( mImpl->mModel->mVisualModel->mControlSize.height < Math::MACHINE_EPSILON_1000 ) ) )
2627 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
2630 // Layout operations that need to be done if the size changes.
2631 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2634 UPDATE_LAYOUT_SIZE |
2636 // Set the update info to relayout the whole text.
2637 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
2638 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
2640 // Store the size used to layout the text.
2641 mImpl->mModel->mVisualModel->mControlSize = size;
2644 // Whether there are modify events.
2645 if( 0u != mImpl->mModifyEvents.Count() )
2647 // Style operations that need to be done if the text is modified.
2648 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2652 // Set the update info to elide the text.
2653 if( mImpl->mModel->mElideEnabled ||
2654 ( ( NULL != mImpl->mEventData ) && mImpl->mEventData->mIsPlaceholderElideEnabled ) )
2656 // Update Text layout for applying elided
2657 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2660 UPDATE_LAYOUT_SIZE |
2662 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
2663 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
2666 if( mImpl->mModel->mMatchSystemLanguageDirection && mImpl->mLayoutDirection != layoutDirection )
2668 // Clear the update info. This info will be set the next time the text is updated.
2669 mImpl->mTextUpdateInfo.mClearAll = true;
2670 // Apply modifications to the model
2671 // Shape the text again is needed because characters like '()[]{}' have to be mirrored and the glyphs generated again.
2672 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2679 mImpl->mLayoutDirection = layoutDirection;
2682 // Make sure the model is up-to-date before layouting.
2683 ProcessModifyEvents();
2684 bool updated = mImpl->UpdateModel( mImpl->mOperationsPending );
2688 updated = DoRelayout( size,
2689 mImpl->mOperationsPending,
2690 layoutSize ) || updated;
2695 updateTextType = MODEL_UPDATED;
2698 // Do not re-do any operation until something changes.
2699 mImpl->mOperationsPending = NO_OPERATION;
2700 mImpl->mModel->mScrollPositionLast = mImpl->mModel->mScrollPosition;
2702 // Whether the text control is editable
2703 const bool isEditable = NULL != mImpl->mEventData;
2705 // Keep the current offset as it will be used to update the decorator's positions (if the size changes).
2707 if( newSize && isEditable )
2709 offset = mImpl->mModel->mScrollPosition;
2712 if( !isEditable || !IsMultiLineEnabled() )
2714 // After doing the text layout, the vertical offset to place the actor in the desired position can be calculated.
2715 CalculateVerticalOffset( size );
2722 // If there is a new size, the scroll position needs to be clamped.
2723 mImpl->ClampHorizontalScroll( layoutSize );
2725 // Update the decorator's positions is needed if there is a new size.
2726 mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mModel->mScrollPosition - offset );
2729 // Move the cursor, grab handle etc.
2730 if( mImpl->ProcessInputEvents() )
2732 updateTextType = static_cast<UpdateTextType>( updateTextType | DECORATOR_UPDATED );
2736 // Clear the update info. This info will be set the next time the text is updated.
2737 mImpl->mTextUpdateInfo.Clear();
2738 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
2740 return updateTextType;
2743 void Controller::RequestRelayout()
2745 mImpl->RequestRelayout();
2748 // public : Input style change signals.
2750 bool Controller::IsInputStyleChangedSignalsQueueEmpty()
2752 return ( NULL == mImpl->mEventData ) || ( 0u == mImpl->mEventData->mInputStyleChangedQueue.Count() );
2755 void Controller::ProcessInputStyleChangedSignals()
2757 if( NULL == mImpl->mEventData )
2763 for( Vector<InputStyle::Mask>::ConstIterator it = mImpl->mEventData->mInputStyleChangedQueue.Begin(),
2764 endIt = mImpl->mEventData->mInputStyleChangedQueue.End();
2768 const InputStyle::Mask mask = *it;
2770 if( NULL != mImpl->mEditableControlInterface )
2772 // Emit the input style changed signal.
2773 mImpl->mEditableControlInterface->InputStyleChanged( mask );
2777 mImpl->mEventData->mInputStyleChangedQueue.Clear();
2780 // public : Text-input Event Queuing.
2782 void Controller::KeyboardFocusGainEvent()
2784 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
2786 if( NULL != mImpl->mEventData )
2788 if( ( EventData::INACTIVE == mImpl->mEventData->mState ) ||
2789 ( EventData::INTERRUPTED == mImpl->mEventData->mState ) )
2791 mImpl->ChangeState( EventData::EDITING );
2792 mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered.
2793 mImpl->mEventData->mUpdateInputStyle = true;
2794 mImpl->mEventData->mScrollAfterUpdatePosition = true;
2796 mImpl->NotifyInputMethodContextMultiLineStatus();
2797 if( mImpl->IsShowingPlaceholderText() )
2799 // Show alternative placeholder-text when editing
2800 ShowPlaceholderText();
2803 mImpl->RequestRelayout();
2807 void Controller::KeyboardFocusLostEvent()
2809 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
2811 if( NULL != mImpl->mEventData )
2813 if( EventData::INTERRUPTED != mImpl->mEventData->mState )
2815 mImpl->ChangeState( EventData::INACTIVE );
2817 if( !mImpl->IsShowingRealText() )
2819 // Revert to regular placeholder-text when not editing
2820 ShowPlaceholderText();
2824 mImpl->RequestRelayout();
2827 bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
2829 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
2831 bool textChanged = false;
2832 bool relayoutNeeded = false;
2834 if( ( NULL != mImpl->mEventData ) &&
2835 ( keyEvent.GetState() == KeyEvent::DOWN ) )
2837 int keyCode = keyEvent.GetKeyCode();
2838 const std::string& keyString = keyEvent.GetKeyString();
2839 const std::string keyName = keyEvent.GetKeyName();
2841 const bool isNullKey = ( 0 == keyCode ) && ( keyString.empty() );
2843 // Pre-process to separate modifying events from non-modifying input events.
2846 // In some platforms arrive key events with no key code.
2850 else if( Dali::DALI_KEY_ESCAPE == keyCode || Dali::DALI_KEY_BACK == keyCode || Dali::DALI_KEY_SEARCH == keyCode )
2855 else if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode ) ||
2856 ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) ||
2857 ( Dali::DALI_KEY_CURSOR_UP == keyCode ) ||
2858 ( Dali::DALI_KEY_CURSOR_DOWN == keyCode ) )
2860 // If don't have any text, do nothing.
2861 if( !mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters )
2866 uint32_t cursorPosition = mImpl->mEventData->mPrimaryCursorPosition;
2867 uint32_t numberOfCharacters = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
2868 uint32_t cursorLine = mImpl->mModel->mVisualModel->GetLineOfCharacter( cursorPosition );
2869 uint32_t numberOfLines = mImpl->mModel->GetNumberOfLines();
2871 // Logic to determine whether this text control will lose focus or not.
2872 if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode && 0 == cursorPosition && !keyEvent.IsShiftModifier() ) ||
2873 ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode && numberOfCharacters == cursorPosition && !keyEvent.IsShiftModifier() ) ||
2874 ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && cursorLine == numberOfLines -1 ) ||
2875 ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && numberOfCharacters == cursorPosition && cursorLine -1 == numberOfLines -1 ) ||
2876 ( Dali::DALI_KEY_CURSOR_UP == keyCode && cursorLine == 0 ) ||
2877 ( Dali::DALI_KEY_CURSOR_UP == keyCode && numberOfCharacters == cursorPosition && cursorLine == 1 ) )
2879 // Release the active highlight.
2880 if( mImpl->mEventData->mState == EventData::SELECTING )
2882 mImpl->ChangeState( EventData::EDITING );
2884 // Update selection position.
2885 mImpl->mEventData->mLeftSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
2886 mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
2887 mImpl->mEventData->mUpdateCursorPosition = true;
2888 mImpl->RequestRelayout();
2893 mImpl->mEventData->mCheckScrollAmount = true;
2894 Event event( Event::CURSOR_KEY_EVENT );
2895 event.p1.mInt = keyCode;
2896 event.p2.mBool = keyEvent.IsShiftModifier();
2897 mImpl->mEventData->mEventQueue.push_back( event );
2899 // Will request for relayout.
2900 relayoutNeeded = true;
2902 else if ( Dali::DevelKey::DALI_KEY_CONTROL_LEFT == keyCode || Dali::DevelKey::DALI_KEY_CONTROL_RIGHT == keyCode )
2904 // Left or Right Control key event is received before Ctrl-C/V/X key event is received
2905 // If not handle it here, any selected text will be deleted
2910 else if ( keyEvent.IsCtrlModifier() && !keyEvent.IsShiftModifier())
2912 bool consumed = false;
2913 if (keyName == KEY_C_NAME || keyName == KEY_INSERT_NAME)
2915 // Ctrl-C or Ctrl+Insert to copy the selected text
2916 TextPopupButtonTouched( Toolkit::TextSelectionPopup::COPY );
2919 else if (keyName == KEY_V_NAME)
2921 // Ctrl-V to paste the copied text
2922 TextPopupButtonTouched( Toolkit::TextSelectionPopup::PASTE );
2925 else if (keyName == KEY_X_NAME)
2927 // Ctrl-X to cut the selected text
2928 TextPopupButtonTouched( Toolkit::TextSelectionPopup::CUT );
2931 else if (keyName == KEY_A_NAME)
2933 // Ctrl-A to select All the text
2934 TextPopupButtonTouched( Toolkit::TextSelectionPopup::SELECT_ALL );
2939 else if( ( Dali::DALI_KEY_BACKSPACE == keyCode ) ||
2940 ( Dali::DevelKey::DALI_KEY_DELETE == keyCode ) )
2942 textChanged = DeleteEvent( keyCode );
2944 // Will request for relayout.
2945 relayoutNeeded = true;
2947 else if( IsKey( keyEvent, Dali::DALI_KEY_POWER ) ||
2948 IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
2949 IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
2951 // Power key/Menu/Home key behaviour does not allow edit mode to resume.
2952 mImpl->ChangeState( EventData::INACTIVE );
2954 // Will request for relayout.
2955 relayoutNeeded = true;
2957 // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text.
2959 else if( ( Dali::DALI_KEY_SHIFT_LEFT == keyCode ) || ( Dali::DALI_KEY_SHIFT_RIGHT == keyCode ) )
2961 // DALI_KEY_SHIFT_LEFT or DALI_KEY_SHIFT_RIGHT is the key code for Shift. It's sent (by the InputMethodContext?) when the predictive text is enabled
2962 // and a character is typed after the type of a upper case latin character.
2967 else if( ( Dali::DALI_KEY_VOLUME_UP == keyCode ) || ( Dali::DALI_KEY_VOLUME_DOWN == keyCode ) )
2969 // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text.
2975 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
2977 if( !keyString.empty() )
2979 // InputMethodContext is no longer handling key-events
2980 mImpl->ClearPreEditFlag();
2982 InsertText( keyString, COMMIT );
2986 // Will request for relayout.
2987 relayoutNeeded = true;
2992 if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
2993 ( mImpl->mEventData->mState != EventData::INACTIVE ) &&
2995 ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) &&
2996 ( Dali::DALI_KEY_SHIFT_RIGHT != keyCode ) &&
2997 ( Dali::DALI_KEY_VOLUME_UP != keyCode ) &&
2998 ( Dali::DALI_KEY_VOLUME_DOWN != keyCode ) )
3000 // Should not change the state if the key is the shift send by the InputMethodContext.
3001 // Otherwise, when the state is SELECTING the text controller can't send the right
3002 // surrounding info to the InputMethodContext.
3003 mImpl->ChangeState( EventData::EDITING );
3005 // Will request for relayout.
3006 relayoutNeeded = true;
3009 if( relayoutNeeded )
3011 mImpl->RequestRelayout();
3016 ( NULL != mImpl->mEditableControlInterface ) )
3018 // Do this last since it provides callbacks into application code
3019 mImpl->mEditableControlInterface->TextChanged();
3025 void Controller::TapEvent( unsigned int tapCount, float x, float y )
3027 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
3029 if( NULL != mImpl->mEventData )
3031 DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState );
3032 EventData::State state( mImpl->mEventData->mState );
3033 bool relayoutNeeded( false ); // to avoid unnecessary relayouts when tapping an empty text-field
3035 if( mImpl->IsClipboardVisible() )
3037 if( EventData::INACTIVE == state || EventData::EDITING == state)
3039 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
3041 relayoutNeeded = true;
3043 else if( 1u == tapCount )
3045 if( EventData::EDITING_WITH_POPUP == state || EventData::EDITING_WITH_PASTE_POPUP == state )
3047 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); // If Popup shown hide it here so can be shown again if required.
3050 if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != state ) )
3052 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
3053 relayoutNeeded = true;
3057 if( mImpl->IsShowingPlaceholderText() && !mImpl->IsFocusedPlaceholderAvailable() )
3059 // Hide placeholder text
3063 if( EventData::INACTIVE == state )
3065 mImpl->ChangeState( EventData::EDITING );
3067 else if( !mImpl->IsClipboardEmpty() )
3069 mImpl->ChangeState( EventData::EDITING_WITH_POPUP );
3071 relayoutNeeded = true;
3074 else if( 2u == tapCount )
3076 if( mImpl->mEventData->mSelectionEnabled &&
3077 mImpl->IsShowingRealText() )
3079 relayoutNeeded = true;
3080 mImpl->mEventData->mIsLeftHandleSelected = true;
3081 mImpl->mEventData->mIsRightHandleSelected = true;
3085 // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
3086 if( relayoutNeeded )
3088 Event event( Event::TAP_EVENT );
3089 event.p1.mUint = tapCount;
3090 event.p2.mFloat = x;
3091 event.p3.mFloat = y;
3092 mImpl->mEventData->mEventQueue.push_back( event );
3094 mImpl->RequestRelayout();
3098 // Reset keyboard as tap event has occurred.
3099 mImpl->ResetInputMethodContext();
3102 void Controller::PanEvent( GestureState state, const Vector2& displacement )
3104 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
3106 if( NULL != mImpl->mEventData )
3108 Event event( Event::PAN_EVENT );
3109 event.p1.mInt = static_cast<int>( state );
3110 event.p2.mFloat = displacement.x;
3111 event.p3.mFloat = displacement.y;
3112 mImpl->mEventData->mEventQueue.push_back( event );
3114 mImpl->RequestRelayout();
3118 void Controller::LongPressEvent( GestureState state, float x, float y )
3120 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected LongPressEvent" );
3122 if( ( state == GestureState::STARTED ) &&
3123 ( NULL != mImpl->mEventData ) )
3125 // The 1st long-press on inactive text-field is treated as tap
3126 if( EventData::INACTIVE == mImpl->mEventData->mState )
3128 mImpl->ChangeState( EventData::EDITING );
3130 Event event( Event::TAP_EVENT );
3132 event.p2.mFloat = x;
3133 event.p3.mFloat = y;
3134 mImpl->mEventData->mEventQueue.push_back( event );
3136 mImpl->RequestRelayout();
3138 else if( !mImpl->IsShowingRealText() )
3140 Event event( Event::LONG_PRESS_EVENT );
3141 event.p1.mInt = static_cast<int>( state );
3142 event.p2.mFloat = x;
3143 event.p3.mFloat = y;
3144 mImpl->mEventData->mEventQueue.push_back( event );
3145 mImpl->RequestRelayout();
3147 else if( !mImpl->IsClipboardVisible() )
3149 // Reset the InputMethodContext to commit the pre-edit before selecting the text.
3150 mImpl->ResetInputMethodContext();
3152 Event event( Event::LONG_PRESS_EVENT );
3153 event.p1.mInt = static_cast<int>( state );
3154 event.p2.mFloat = x;
3155 event.p3.mFloat = y;
3156 mImpl->mEventData->mEventQueue.push_back( event );
3157 mImpl->RequestRelayout();
3159 mImpl->mEventData->mIsLeftHandleSelected = true;
3160 mImpl->mEventData->mIsRightHandleSelected = true;
3165 void Controller::SelectEvent( float x, float y, SelectionType selectType )
3167 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SelectEvent\n" );
3169 if( NULL != mImpl->mEventData )
3171 if( selectType == SelectionType::ALL )
3173 Event event( Event::SELECT_ALL );
3174 mImpl->mEventData->mEventQueue.push_back( event );
3176 else if( selectType == SelectionType::NONE )
3178 Event event( Event::SELECT_NONE );
3179 mImpl->mEventData->mEventQueue.push_back( event );
3183 Event event( Event::SELECT );
3184 event.p2.mFloat = x;
3185 event.p3.mFloat = y;
3186 mImpl->mEventData->mEventQueue.push_back( event );
3189 mImpl->mEventData->mCheckScrollAmount = true;
3190 mImpl->mEventData->mIsLeftHandleSelected = true;
3191 mImpl->mEventData->mIsRightHandleSelected = true;
3192 mImpl->RequestRelayout();
3196 InputMethodContext::CallbackData Controller::OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent )
3198 // Whether the text needs to be relaid-out.
3199 bool requestRelayout = false;
3201 // Whether to retrieve the text and cursor position to be sent to the InputMethodContext.
3202 bool retrieveText = false;
3203 bool retrieveCursor = false;
3205 switch( inputMethodContextEvent.eventName )
3207 case InputMethodContext::COMMIT:
3209 InsertText( inputMethodContextEvent.predictiveString, Text::Controller::COMMIT );
3210 requestRelayout = true;
3211 retrieveCursor = true;
3214 case InputMethodContext::PRE_EDIT:
3216 InsertText( inputMethodContextEvent.predictiveString, Text::Controller::PRE_EDIT );
3217 requestRelayout = true;
3218 retrieveCursor = true;
3221 case InputMethodContext::DELETE_SURROUNDING:
3223 const bool textDeleted = RemoveText( inputMethodContextEvent.cursorOffset,
3224 inputMethodContextEvent.numberOfChars,
3225 DONT_UPDATE_INPUT_STYLE );
3229 if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
3230 !mImpl->IsPlaceholderAvailable() )
3232 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
3236 ShowPlaceholderText();
3238 mImpl->mEventData->mUpdateCursorPosition = true;
3239 mImpl->mEventData->mScrollAfterDelete = true;
3241 requestRelayout = true;
3245 case InputMethodContext::GET_SURROUNDING:
3247 retrieveText = true;
3248 retrieveCursor = true;
3251 case InputMethodContext::PRIVATE_COMMAND:
3253 // PRIVATECOMMAND event is just for getting the private command message
3254 retrieveText = true;
3255 retrieveCursor = true;
3258 case InputMethodContext::VOID:
3265 if( requestRelayout )
3267 mImpl->mOperationsPending = ALL_OPERATIONS;
3268 mImpl->RequestRelayout();
3272 CharacterIndex cursorPosition = 0u;
3273 Length numberOfWhiteSpaces = 0u;
3275 if( retrieveCursor )
3277 numberOfWhiteSpaces = mImpl->GetNumberOfWhiteSpaces( 0u );
3279 cursorPosition = mImpl->GetLogicalCursorPosition();
3281 if( cursorPosition < numberOfWhiteSpaces )
3283 cursorPosition = 0u;
3287 cursorPosition -= numberOfWhiteSpaces;
3293 if( !mImpl->IsShowingPlaceholderText() )
3295 // Retrieves the normal text string.
3296 mImpl->GetText( numberOfWhiteSpaces, text );
3300 // When the current text is Placeholder Text, the surrounding text should be empty string.
3301 // It means DALi should send empty string ("") to IME.
3306 InputMethodContext::CallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
3308 if( requestRelayout &&
3309 ( NULL != mImpl->mEditableControlInterface ) )
3311 // Do this last since it provides callbacks into application code
3312 mImpl->mEditableControlInterface->TextChanged();
3315 return callbackData;
3318 void Controller::PasteClipboardItemEvent()
3320 // Retrieve the clipboard contents first
3321 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
3322 std::string stringToPaste( notifier.GetContent() );
3324 // Commit the current pre-edit text; the contents of the clipboard should be appended
3325 mImpl->ResetInputMethodContext();
3327 // Temporary disable hiding clipboard
3328 mImpl->SetClipboardHideEnable( false );
3331 PasteText( stringToPaste );
3333 mImpl->SetClipboardHideEnable( true );
3336 // protected : Inherit from Text::Decorator::ControllerInterface.
3338 void Controller::GetTargetSize( Vector2& targetSize )
3340 targetSize = mImpl->mModel->mVisualModel->mControlSize;
3343 void Controller::AddDecoration( Actor& actor, bool needsClipping )
3345 if( NULL != mImpl->mEditableControlInterface )
3347 mImpl->mEditableControlInterface->AddDecoration( actor, needsClipping );
3351 void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
3353 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
3355 if( NULL != mImpl->mEventData )
3357 switch( handleType )
3361 Event event( Event::GRAB_HANDLE_EVENT );
3362 event.p1.mUint = state;
3363 event.p2.mFloat = x;
3364 event.p3.mFloat = y;
3366 mImpl->mEventData->mEventQueue.push_back( event );
3369 case LEFT_SELECTION_HANDLE:
3371 Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
3372 event.p1.mUint = state;
3373 event.p2.mFloat = x;
3374 event.p3.mFloat = y;
3376 mImpl->mEventData->mEventQueue.push_back( event );
3379 case RIGHT_SELECTION_HANDLE:
3381 Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
3382 event.p1.mUint = state;
3383 event.p2.mFloat = x;
3384 event.p3.mFloat = y;
3386 mImpl->mEventData->mEventQueue.push_back( event );
3389 case LEFT_SELECTION_HANDLE_MARKER:
3390 case RIGHT_SELECTION_HANDLE_MARKER:
3392 // Markers do not move the handles.
3395 case HANDLE_TYPE_COUNT:
3397 DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
3401 mImpl->RequestRelayout();
3405 // protected : Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
3407 void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button )
3409 if( NULL == mImpl->mEventData )
3416 case Toolkit::TextSelectionPopup::CUT:
3418 mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
3419 mImpl->mOperationsPending = ALL_OPERATIONS;
3421 if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
3422 !mImpl->IsPlaceholderAvailable() )
3424 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
3428 ShowPlaceholderText();
3431 mImpl->mEventData->mUpdateCursorPosition = true;
3432 mImpl->mEventData->mScrollAfterDelete = true;
3434 mImpl->RequestRelayout();
3436 if( NULL != mImpl->mEditableControlInterface )
3438 mImpl->mEditableControlInterface->TextChanged();
3442 case Toolkit::TextSelectionPopup::COPY:
3444 mImpl->SendSelectionToClipboard( false ); // Text not modified
3446 mImpl->mEventData->mUpdateCursorPosition = true;
3448 mImpl->RequestRelayout(); // Cursor, Handles, Selection Highlight, Popup
3451 case Toolkit::TextSelectionPopup::PASTE:
3453 mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
3456 case Toolkit::TextSelectionPopup::SELECT:
3458 const Vector2& currentCursorPosition = mImpl->mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
3460 if( mImpl->mEventData->mSelectionEnabled )
3462 // Creates a SELECT event.
3463 SelectEvent( currentCursorPosition.x, currentCursorPosition.y, SelectionType::INTERACTIVE );
3467 case Toolkit::TextSelectionPopup::SELECT_ALL:
3469 // Creates a SELECT_ALL event
3470 SelectEvent( 0.f, 0.f, SelectionType::ALL );
3473 case Toolkit::TextSelectionPopup::CLIPBOARD:
3475 mImpl->ShowClipboard();
3478 case Toolkit::TextSelectionPopup::NONE:
3486 void Controller::DisplayTimeExpired()
3488 mImpl->mEventData->mUpdateCursorPosition = true;
3489 // Apply modifications to the model
3490 mImpl->mOperationsPending = ALL_OPERATIONS;
3492 mImpl->RequestRelayout();
3495 // private : Update.
3497 void Controller::InsertText( const std::string& text, Controller::InsertType type )
3499 bool removedPrevious = false;
3500 bool removedSelected = false;
3501 bool maxLengthReached = false;
3503 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" )
3505 if( NULL == mImpl->mEventData )
3510 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n",
3511 this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
3512 mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
3514 // TODO: At the moment the underline runs are only for pre-edit.
3515 mImpl->mModel->mVisualModel->mUnderlineRuns.Clear();
3517 // Remove the previous InputMethodContext pre-edit.
3518 if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) )
3520 removedPrevious = RemoveText( -static_cast<int>( mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition ),
3521 mImpl->mEventData->mPreEditLength,
3522 DONT_UPDATE_INPUT_STYLE );
3524 mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
3525 mImpl->mEventData->mPreEditLength = 0u;
3529 // Remove the previous Selection.
3530 removedSelected = RemoveSelectedText();
3534 Vector<Character> utf32Characters;
3535 Length characterCount = 0u;
3539 // Convert text into UTF-32
3540 utf32Characters.Resize( text.size() );
3542 // This is a bit horrible but std::string returns a (signed) char*
3543 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
3545 // Transform a text array encoded in utf8 into an array encoded in utf32.
3546 // It returns the actual number of characters.
3547 characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
3548 utf32Characters.Resize( characterCount );
3550 DALI_ASSERT_DEBUG( text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length" );
3551 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count() );
3554 if( 0u != utf32Characters.Count() ) // Check if Utf8ToUtf32 conversion succeeded
3556 // The placeholder text is no longer needed
3557 if( mImpl->IsShowingPlaceholderText() )
3562 mImpl->ChangeState( EventData::EDITING );
3564 // Handle the InputMethodContext (predicitive text) state changes
3565 if( COMMIT == type )
3567 // InputMethodContext is no longer handling key-events
3568 mImpl->ClearPreEditFlag();
3572 if( !mImpl->mEventData->mPreEditFlag )
3574 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state\n" );
3576 // Record the start of the pre-edit text
3577 mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
3580 mImpl->mEventData->mPreEditLength = utf32Characters.Count();
3581 mImpl->mEventData->mPreEditFlag = true;
3583 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
3586 const Length numberOfCharactersInModel = mImpl->mModel->mLogicalModel->mText.Count();
3588 // Restrict new text to fit within Maximum characters setting.
3589 Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
3590 maxLengthReached = ( characterCount > maxSizeOfNewText );
3592 // The cursor position.
3593 CharacterIndex& cursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
3595 // Update the text's style.
3597 // Updates the text style runs by adding characters.
3598 mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText );
3600 // Get the character index from the cursor index.
3601 const CharacterIndex styleIndex = ( cursorIndex > 0u ) ? cursorIndex - 1u : 0u;
3603 // Retrieve the text's style for the given index.
3605 mImpl->RetrieveDefaultInputStyle( style );
3606 mImpl->mModel->mLogicalModel->RetrieveStyle( styleIndex, style );
3608 // Whether to add a new text color run.
3609 const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor ) && !mImpl->mEventData->mInputStyle.isDefaultColor;
3611 // Whether to add a new font run.
3612 const bool addFontNameRun = ( style.familyName != mImpl->mEventData->mInputStyle.familyName ) && mImpl->mEventData->mInputStyle.isFamilyDefined;
3613 const bool addFontWeightRun = ( style.weight != mImpl->mEventData->mInputStyle.weight ) && mImpl->mEventData->mInputStyle.isWeightDefined;
3614 const bool addFontWidthRun = ( style.width != mImpl->mEventData->mInputStyle.width ) && mImpl->mEventData->mInputStyle.isWidthDefined;
3615 const bool addFontSlantRun = ( style.slant != mImpl->mEventData->mInputStyle.slant ) && mImpl->mEventData->mInputStyle.isSlantDefined;
3616 const bool addFontSizeRun = ( style.size != mImpl->mEventData->mInputStyle.size ) && mImpl->mEventData->mInputStyle.isSizeDefined ;
3621 const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
3622 mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
3624 ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
3625 colorRun.color = mImpl->mEventData->mInputStyle.textColor;
3626 colorRun.characterRun.characterIndex = cursorIndex;
3627 colorRun.characterRun.numberOfCharacters = maxSizeOfNewText;
3630 if( addFontNameRun ||
3636 const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Count();
3637 mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
3639 FontDescriptionRun& fontDescriptionRun = *( mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
3641 if( addFontNameRun )
3643 fontDescriptionRun.familyLength = mImpl->mEventData->mInputStyle.familyName.size();
3644 fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
3645 memcpy( fontDescriptionRun.familyName, mImpl->mEventData->mInputStyle.familyName.c_str(), fontDescriptionRun.familyLength );
3646 fontDescriptionRun.familyDefined = true;
3648 // The memory allocated for the font family name is freed when the font description is removed from the logical model.
3651 if( addFontWeightRun )
3653 fontDescriptionRun.weight = mImpl->mEventData->mInputStyle.weight;
3654 fontDescriptionRun.weightDefined = true;
3657 if( addFontWidthRun )
3659 fontDescriptionRun.width = mImpl->mEventData->mInputStyle.width;
3660 fontDescriptionRun.widthDefined = true;
3663 if( addFontSlantRun )
3665 fontDescriptionRun.slant = mImpl->mEventData->mInputStyle.slant;
3666 fontDescriptionRun.slantDefined = true;
3669 if( addFontSizeRun )
3671 fontDescriptionRun.size = static_cast<PointSize26Dot6>( mImpl->mEventData->mInputStyle.size * 64.f );
3672 fontDescriptionRun.sizeDefined = true;
3675 fontDescriptionRun.characterRun.characterIndex = cursorIndex;
3676 fontDescriptionRun.characterRun.numberOfCharacters = maxSizeOfNewText;
3679 // Insert at current cursor position.
3680 Vector<Character>& modifyText = mImpl->mModel->mLogicalModel->mText;
3682 if( cursorIndex < numberOfCharactersInModel )
3684 modifyText.Insert( modifyText.Begin() + cursorIndex, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
3688 modifyText.Insert( modifyText.End(), utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
3691 // Mark the first paragraph to be updated.
3692 if( Layout::Engine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() )
3694 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
3695 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
3696 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = numberOfCharactersInModel + maxSizeOfNewText;
3697 mImpl->mTextUpdateInfo.mClearAll = true;
3701 mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex );
3702 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd += maxSizeOfNewText;
3705 // Update the cursor index.
3706 cursorIndex += maxSizeOfNewText;
3708 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
3711 if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) &&
3712 mImpl->IsPlaceholderAvailable() )
3714 // Show place-holder if empty after removing the pre-edit text
3715 ShowPlaceholderText();
3716 mImpl->mEventData->mUpdateCursorPosition = true;
3717 mImpl->ClearPreEditFlag();
3719 else if( removedPrevious ||
3721 ( 0 != utf32Characters.Count() ) )
3723 // Queue an inserted event
3724 mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
3726 mImpl->mEventData->mUpdateCursorPosition = true;
3727 if( removedSelected )
3729 mImpl->mEventData->mScrollAfterDelete = true;
3733 mImpl->mEventData->mScrollAfterUpdatePosition = true;
3737 if( maxLengthReached )
3739 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mModel->mLogicalModel->mText.Count() );
3741 mImpl->ResetInputMethodContext();
3743 if( NULL != mImpl->mEditableControlInterface )
3745 // Do this last since it provides callbacks into application code
3746 mImpl->mEditableControlInterface->MaxLengthReached();
3751 void Controller::PasteText( const std::string& stringToPaste )
3753 InsertText( stringToPaste, Text::Controller::COMMIT );
3754 mImpl->ChangeState( EventData::EDITING );
3755 mImpl->RequestRelayout();
3757 if( NULL != mImpl->mEditableControlInterface )
3759 // Do this last since it provides callbacks into application code
3760 mImpl->mEditableControlInterface->TextChanged();
3764 bool Controller::RemoveText( int cursorOffset,
3765 int numberOfCharacters,
3766 UpdateInputStyleType type )
3768 bool removed = false;
3770 if( NULL == mImpl->mEventData )
3775 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n",
3776 this, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
3778 if( !mImpl->IsShowingPlaceholderText() )
3780 // Delete at current cursor position
3781 Vector<Character>& currentText = mImpl->mModel->mLogicalModel->mText;
3782 CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
3784 CharacterIndex cursorIndex = 0;
3786 // Validate the cursor position & number of characters
3787 if( ( static_cast< int >( mImpl->mEventData->mPrimaryCursorPosition ) + cursorOffset ) >= 0 )
3789 cursorIndex = mImpl->mEventData->mPrimaryCursorPosition + cursorOffset;
3792 if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )
3794 numberOfCharacters = currentText.Count() - cursorIndex;
3797 if( mImpl->mEventData->mPreEditFlag || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time.
3798 ( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) )
3800 // Mark the paragraphs to be updated.
3801 if( Layout::Engine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() )
3803 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
3804 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
3805 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters - numberOfCharacters;
3806 mImpl->mTextUpdateInfo.mClearAll = true;
3810 mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex );
3811 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove += numberOfCharacters;
3814 // Update the input style and remove the text's style before removing the text.
3816 if( UPDATE_INPUT_STYLE == type )
3818 // Keep a copy of the current input style.
3819 InputStyle currentInputStyle;
3820 currentInputStyle.Copy( mImpl->mEventData->mInputStyle );
3822 // Set first the default input style.
3823 mImpl->RetrieveDefaultInputStyle( mImpl->mEventData->mInputStyle );
3825 // Update the input style.
3826 mImpl->mModel->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
3828 // Compare if the input style has changed.
3829 const bool hasInputStyleChanged = !currentInputStyle.Equal( mImpl->mEventData->mInputStyle );
3831 if( hasInputStyleChanged )
3833 const InputStyle::Mask styleChangedMask = currentInputStyle.GetInputStyleChangeMask( mImpl->mEventData->mInputStyle );
3834 // Queue the input style changed signal.
3835 mImpl->mEventData->mInputStyleChangedQueue.PushBack( styleChangedMask );
3839 // If the number of current text and the number of characters to be deleted are same,
3840 // it means all texts should be removed and all Preedit variables should be initialized.
3841 if( ( currentText.Count() - numberOfCharacters == 0 ) && ( cursorIndex == 0 ) )
3843 mImpl->ClearPreEditFlag();
3844 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0;
3847 // Updates the text style runs by removing characters. Runs with no characters are removed.
3848 mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
3850 // Remove the characters.
3851 Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
3852 Vector<Character>::Iterator last = first + numberOfCharacters;
3854 currentText.Erase( first, last );
3856 // Cursor position retreat
3857 oldCursorIndex = cursorIndex;
3859 mImpl->mEventData->mScrollAfterDelete = true;
3861 if( EventData::INACTIVE == mImpl->mEventData->mState )
3863 mImpl->ChangeState( EventData::EDITING );
3866 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
3874 bool Controller::RemoveSelectedText()
3876 bool textRemoved( false );
3878 if( EventData::SELECTING == mImpl->mEventData->mState )
3880 std::string removedString;
3881 mImpl->RetrieveSelection( removedString, true );
3883 if( !removedString.empty() )
3886 mImpl->ChangeState( EventData::EDITING );
3893 std::string Controller::GetSelectedText()
3896 if( EventData::SELECTING == mImpl->mEventData->mState )
3898 mImpl->RetrieveSelection( text, false );
3903 // private : Relayout.
3905 bool Controller::DoRelayout( const Size& size,
3906 OperationsMask operationsRequired,
3909 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
3910 bool viewUpdated( false );
3912 // Calculate the operations to be done.
3913 const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
3915 const CharacterIndex startIndex = mImpl->mTextUpdateInfo.mParagraphCharacterIndex;
3916 const Length requestedNumberOfCharacters = mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters;
3918 // Get the current layout size.
3919 layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
3921 if( NO_OPERATION != ( LAYOUT & operations ) )
3923 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout LAYOUT & operations\n");
3925 // Some vectors with data needed to layout and reorder may be void
3926 // after the first time the text has been laid out.
3927 // Fill the vectors again.
3929 // Calculate the number of glyphs to layout.
3930 const Vector<GlyphIndex>& charactersToGlyph = mImpl->mModel->mVisualModel->mCharactersToGlyph;
3931 const Vector<Length>& glyphsPerCharacter = mImpl->mModel->mVisualModel->mGlyphsPerCharacter;
3932 const GlyphIndex* const charactersToGlyphBuffer = charactersToGlyph.Begin();
3933 const Length* const glyphsPerCharacterBuffer = glyphsPerCharacter.Begin();
3935 const CharacterIndex lastIndex = startIndex + ( ( requestedNumberOfCharacters > 0u ) ? requestedNumberOfCharacters - 1u : 0u );
3936 const GlyphIndex startGlyphIndex = mImpl->mTextUpdateInfo.mStartGlyphIndex;
3938 // Make sure the index is not out of bound
3939 if ( charactersToGlyph.Count() != glyphsPerCharacter.Count() ||
3940 requestedNumberOfCharacters > charactersToGlyph.Count() ||
3941 ( lastIndex > charactersToGlyph.Count() && charactersToGlyph.Count() > 0u ) )
3943 std::string currentText;
3944 GetText( currentText );
3946 DALI_LOG_ERROR( "Controller::DoRelayout: Attempting to access invalid buffer\n" );
3947 DALI_LOG_ERROR( "Current text is: %s\n", currentText.c_str() );
3948 DALI_LOG_ERROR( "startIndex: %u, lastIndex: %u, requestedNumberOfCharacters: %u, charactersToGlyph.Count = %lu, glyphsPerCharacter.Count = %lu\n", startIndex, lastIndex, requestedNumberOfCharacters, charactersToGlyph.Count(), glyphsPerCharacter.Count());
3953 const Length numberOfGlyphs = ( requestedNumberOfCharacters > 0u ) ? *( charactersToGlyphBuffer + lastIndex ) + *( glyphsPerCharacterBuffer + lastIndex ) - startGlyphIndex : 0u;
3954 const Length totalNumberOfGlyphs = mImpl->mModel->mVisualModel->mGlyphs.Count();
3956 if( 0u == totalNumberOfGlyphs )
3958 if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
3960 mImpl->mModel->mVisualModel->SetLayoutSize( Size::ZERO );
3963 // Nothing else to do if there is no glyphs.
3964 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
3968 // Set the layout parameters.
3969 Layout::Parameters layoutParameters( size,
3972 // Resize the vector of positions to have the same size than the vector of glyphs.
3973 Vector<Vector2>& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions;
3974 glyphPositions.Resize( totalNumberOfGlyphs );
3976 // Whether the last character is a new paragraph character.
3977 const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
3978 mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mModel->mLogicalModel->mText.Count() - 1u ) ) );
3979 layoutParameters.isLastNewParagraph = mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph;
3981 // The initial glyph and the number of glyphs to layout.
3982 layoutParameters.startGlyphIndex = startGlyphIndex;
3983 layoutParameters.numberOfGlyphs = numberOfGlyphs;
3984 layoutParameters.startLineIndex = mImpl->mTextUpdateInfo.mStartLineIndex;
3985 layoutParameters.estimatedNumberOfLines = mImpl->mTextUpdateInfo.mEstimatedNumberOfLines;
3987 // Update the ellipsis
3988 bool elideTextEnabled = mImpl->mModel->mElideEnabled;
3990 if( NULL != mImpl->mEventData )
3992 if( mImpl->mEventData->mPlaceholderEllipsisFlag && mImpl->IsShowingPlaceholderText() )
3994 elideTextEnabled = mImpl->mEventData->mIsPlaceholderElideEnabled;
3996 else if( EventData::INACTIVE != mImpl->mEventData->mState )
3998 // Disable ellipsis when editing
3999 elideTextEnabled = false;
4002 // Reset the scroll position in inactive state
4003 if( elideTextEnabled && ( mImpl->mEventData->mState == EventData::INACTIVE ) )
4005 ResetScrollPosition();
4009 // Update the visual model.
4010 bool isAutoScrollEnabled = mImpl->mIsAutoScrollEnabled;
4012 viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
4015 isAutoScrollEnabled );
4016 mImpl->mIsAutoScrollEnabled = isAutoScrollEnabled;
4018 viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );
4022 layoutSize = newLayoutSize;
4024 if( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
4026 mImpl->mIsTextDirectionRTL = false;
4029 if ( ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) && !mImpl->mModel->mVisualModel->mLines.Empty() )
4031 mImpl->mIsTextDirectionRTL = mImpl->mModel->mVisualModel->mLines[0u].direction;
4034 // Sets the layout size.
4035 if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
4037 mImpl->mModel->mVisualModel->SetLayoutSize( layoutSize );
4042 if( NO_OPERATION != ( ALIGN & operations ) )
4044 // The laid-out lines.
4045 Vector<LineRun>& lines = mImpl->mModel->mVisualModel->mLines;
4047 CharacterIndex alignStartIndex = startIndex;
4048 Length alignRequestedNumberOfCharacters = requestedNumberOfCharacters;
4050 // the whole text needs to be full aligned.
4051 // If you do not do a full aligned, only the last line of the multiline input is aligned.
4052 if( mImpl->mEventData && mImpl->mEventData->mUpdateAlignment )
4054 alignStartIndex = 0u;
4055 alignRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
4056 mImpl->mEventData->mUpdateAlignment = false;
4059 // Need to align with the control's size as the text may contain lines
4060 // starting either with left to right text or right to left.
4061 mImpl->mLayoutEngine.Align( size,
4063 alignRequestedNumberOfCharacters,
4064 mImpl->mModel->mHorizontalAlignment,
4066 mImpl->mModel->mAlignmentOffset,
4067 mImpl->mLayoutDirection,
4068 mImpl->mModel->mMatchSystemLanguageDirection );
4072 #if defined(DEBUG_ENABLED)
4073 std::string currentText;
4074 GetText( currentText );
4075 DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::DoRelayout [%p] mImpl->mIsTextDirectionRTL[%s] [%s]\n", this, (mImpl->mIsTextDirectionRTL)?"true":"false", currentText.c_str() );
4077 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
4081 void Controller::CalculateVerticalOffset( const Size& controlSize )
4083 Size layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
4085 if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 )
4087 // Get the line height of the default font.
4088 layoutSize.height = mImpl->GetDefaultFontLineHeight();
4091 switch( mImpl->mModel->mVerticalAlignment )
4093 case VerticalAlignment::TOP:
4095 mImpl->mModel->mScrollPosition.y = 0.f;
4098 case VerticalAlignment::CENTER:
4100 mImpl->mModel->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
4103 case VerticalAlignment::BOTTOM:
4105 mImpl->mModel->mScrollPosition.y = controlSize.height - layoutSize.height;
4111 // private : Events.
4113 void Controller::ProcessModifyEvents()
4115 Vector<ModifyEvent>& events = mImpl->mModifyEvents;
4117 if( 0u == events.Count() )
4123 for( Vector<ModifyEvent>::ConstIterator it = events.Begin(),
4124 endIt = events.End();
4128 const ModifyEvent& event = *it;
4130 if( ModifyEvent::TEXT_REPLACED == event.type )
4132 // A (single) replace event should come first, otherwise we wasted time processing NOOP events
4133 DALI_ASSERT_DEBUG( it == events.Begin() && "Unexpected TEXT_REPLACED event" );
4135 TextReplacedEvent();
4137 else if( ModifyEvent::TEXT_INSERTED == event.type )
4139 TextInsertedEvent();
4141 else if( ModifyEvent::TEXT_DELETED == event.type )
4143 // Placeholder-text cannot be deleted
4144 if( !mImpl->IsShowingPlaceholderText() )
4151 if( NULL != mImpl->mEventData )
4153 // When the text is being modified, delay cursor blinking
4154 mImpl->mEventData->mDecorator->DelayCursorBlink();
4156 // Update selection position after modifying the text
4157 mImpl->mEventData->mLeftSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
4158 mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
4161 // DISCARD temporary text
4165 void Controller::TextReplacedEvent()
4167 // The natural size needs to be re-calculated.
4168 mImpl->mRecalculateNaturalSize = true;
4170 // The text direction needs to be updated.
4171 mImpl->mUpdateTextDirection = true;
4173 // Apply modifications to the model
4174 mImpl->mOperationsPending = ALL_OPERATIONS;
4177 void Controller::TextInsertedEvent()
4179 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
4181 if( NULL == mImpl->mEventData )
4186 mImpl->mEventData->mCheckScrollAmount = true;
4188 // The natural size needs to be re-calculated.
4189 mImpl->mRecalculateNaturalSize = true;
4191 // The text direction needs to be updated.
4192 mImpl->mUpdateTextDirection = true;
4194 // Apply modifications to the model; TODO - Optimize this
4195 mImpl->mOperationsPending = ALL_OPERATIONS;
4198 void Controller::TextDeletedEvent()
4200 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
4202 if( NULL == mImpl->mEventData )
4207 mImpl->mEventData->mCheckScrollAmount = true;
4209 // The natural size needs to be re-calculated.
4210 mImpl->mRecalculateNaturalSize = true;
4212 // The text direction needs to be updated.
4213 mImpl->mUpdateTextDirection = true;
4215 // Apply modifications to the model; TODO - Optimize this
4216 mImpl->mOperationsPending = ALL_OPERATIONS;
4219 bool Controller::DeleteEvent( int keyCode )
4221 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p KeyCode : %d \n", this, keyCode );
4223 bool removed = false;
4225 if( NULL == mImpl->mEventData )
4230 // InputMethodContext is no longer handling key-events
4231 mImpl->ClearPreEditFlag();
4233 if( EventData::SELECTING == mImpl->mEventData->mState )
4235 removed = RemoveSelectedText();
4237 else if( ( mImpl->mEventData->mPrimaryCursorPosition > 0 ) && ( keyCode == Dali::DALI_KEY_BACKSPACE) )
4239 // Remove the character before the current cursor position
4240 removed = RemoveText( -1,
4242 UPDATE_INPUT_STYLE );
4244 else if( keyCode == Dali::DevelKey::DALI_KEY_DELETE )
4246 // Remove the character after the current cursor position
4247 removed = RemoveText( 0,
4249 UPDATE_INPUT_STYLE );
4254 if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
4255 !mImpl->IsPlaceholderAvailable() )
4257 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
4261 ShowPlaceholderText();
4263 mImpl->mEventData->mUpdateCursorPosition = true;
4264 mImpl->mEventData->mScrollAfterDelete = true;
4270 // private : Helpers.
4272 void Controller::ResetText()
4275 mImpl->mModel->mLogicalModel->mText.Clear();
4277 // Reset the embedded images buffer.
4278 mImpl->mModel->mLogicalModel->ClearEmbeddedImages();
4280 // We have cleared everything including the placeholder-text
4281 mImpl->PlaceholderCleared();
4283 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
4284 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
4285 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0u;
4287 // Clear any previous text.
4288 mImpl->mTextUpdateInfo.mClearAll = true;
4290 // The natural size needs to be re-calculated.
4291 mImpl->mRecalculateNaturalSize = true;
4293 // The text direction needs to be updated.
4294 mImpl->mUpdateTextDirection = true;
4296 // Apply modifications to the model
4297 mImpl->mOperationsPending = ALL_OPERATIONS;
4300 void Controller::ShowPlaceholderText()
4302 if( mImpl->IsPlaceholderAvailable() )
4304 DALI_ASSERT_DEBUG( mImpl->mEventData && "No placeholder text available" );
4306 if( NULL == mImpl->mEventData )
4311 mImpl->mEventData->mIsShowingPlaceholderText = true;
4313 // Disable handles when showing place-holder text
4314 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
4315 mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
4316 mImpl->mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
4318 const char* text( NULL );
4321 // TODO - Switch Placeholder text when changing state
4322 if( ( EventData::INACTIVE != mImpl->mEventData->mState ) &&
4323 ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) )
4325 text = mImpl->mEventData->mPlaceholderTextActive.c_str();
4326 size = mImpl->mEventData->mPlaceholderTextActive.size();
4330 text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
4331 size = mImpl->mEventData->mPlaceholderTextInactive.size();
4334 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
4335 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
4337 // Reset model for showing placeholder.
4338 mImpl->mModel->mLogicalModel->mText.Clear();
4339 mImpl->mModel->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
4341 // Convert text into UTF-32
4342 Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
4343 utf32Characters.Resize( size );
4345 // This is a bit horrible but std::string returns a (signed) char*
4346 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text );
4348 // Transform a text array encoded in utf8 into an array encoded in utf32.
4349 // It returns the actual number of characters.
4350 const Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
4351 utf32Characters.Resize( characterCount );
4353 // The characters to be added.
4354 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = characterCount;
4356 // Reset the cursor position
4357 mImpl->mEventData->mPrimaryCursorPosition = 0;
4359 // The natural size needs to be re-calculated.
4360 mImpl->mRecalculateNaturalSize = true;
4362 // The text direction needs to be updated.
4363 mImpl->mUpdateTextDirection = true;
4365 // Apply modifications to the model
4366 mImpl->mOperationsPending = ALL_OPERATIONS;
4368 // Update the rest of the model during size negotiation
4369 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
4373 void Controller::ClearFontData()
4375 if( mImpl->mFontDefaults )
4377 mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
4380 // Set flags to update the model.
4381 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
4382 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
4383 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
4385 mImpl->mTextUpdateInfo.mClearAll = true;
4386 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
4387 mImpl->mRecalculateNaturalSize = true;
4389 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
4395 UPDATE_LAYOUT_SIZE |
4400 void Controller::ClearStyleData()
4402 mImpl->mModel->mLogicalModel->mColorRuns.Clear();
4403 mImpl->mModel->mLogicalModel->ClearFontDescriptionRuns();
4406 void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
4408 // Reset the cursor position
4409 if( NULL != mImpl->mEventData )
4411 mImpl->mEventData->mPrimaryCursorPosition = cursorIndex;
4413 // Update the cursor if it's in editing mode.
4414 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
4416 mImpl->mEventData->mUpdateCursorPosition = true;
4421 void Controller::ResetScrollPosition()
4423 if( NULL != mImpl->mEventData )
4425 // Reset the scroll position.
4426 mImpl->mModel->mScrollPosition = Vector2::ZERO;
4427 mImpl->mEventData->mScrollAfterUpdatePosition = true;
4431 void Controller::SetControlInterface( ControlInterface* controlInterface )
4433 mImpl->mControlInterface = controlInterface;
4436 bool Controller::ShouldClearFocusOnEscape() const
4438 return mImpl->mShouldClearFocusOnEscape;
4441 Actor Controller::CreateBackgroundActor()
4443 return mImpl->CreateBackgroundActor();
4446 // private : Private contructors & copy operator.
4448 Controller::Controller()
4451 mImpl = new Controller::Impl( NULL, NULL );
4454 Controller::Controller( ControlInterface* controlInterface )
4456 mImpl = new Controller::Impl( controlInterface, NULL );
4459 Controller::Controller( ControlInterface* controlInterface,
4460 EditableControlInterface* editableControlInterface )
4462 mImpl = new Controller::Impl( controlInterface,
4463 editableControlInterface );
4466 // The copy constructor and operator are left unimplemented.
4468 // protected : Destructor.
4470 Controller::~Controller()
4477 } // namespace Toolkit