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";
57 const char * const PLACEHOLDER_TEXT = "text";
58 const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
59 const char * const PLACEHOLDER_COLOR = "color";
60 const char * const PLACEHOLDER_FONT_FAMILY = "fontFamily";
61 const char * const PLACEHOLDER_FONT_STYLE = "fontStyle";
62 const char * const PLACEHOLDER_POINT_SIZE = "pointSize";
63 const char * const PLACEHOLDER_PIXEL_SIZE = "pixelSize";
64 const char * const PLACEHOLDER_ELLIPSIS = "ellipsis";
66 float ConvertToEven( float value )
68 int intValue(static_cast<int>( value ));
69 return static_cast<float>( intValue + ( intValue & 1 ) );
72 int ConvertPixelToPint( float pixel )
74 unsigned int horizontalDpi = 0u;
75 unsigned int verticalDpi = 0u;
76 Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
77 fontClient.GetDpi( horizontalDpi, verticalDpi );
79 return ( pixel * 72.f ) / static_cast< float >( horizontalDpi );
94 * @brief Adds a new font description run for the selected text.
96 * The new font parameters are added after the call to this method.
98 * @param[in] eventData The event data pointer.
99 * @param[in] logicalModel The logical model where to add the new font description run.
100 * @param[out] startOfSelectedText Index to the first selected character.
101 * @param[out] lengthOfSelectedText Number of selected characters.
103 FontDescriptionRun& UpdateSelectionFontStyleRun( EventData* eventData,
104 LogicalModelPtr logicalModel,
105 CharacterIndex& startOfSelectedText,
106 Length& lengthOfSelectedText )
108 const bool handlesCrossed = eventData->mLeftSelectionPosition > eventData->mRightSelectionPosition;
110 // Get start and end position of selection
111 startOfSelectedText = handlesCrossed ? eventData->mRightSelectionPosition : eventData->mLeftSelectionPosition;
112 lengthOfSelectedText = ( handlesCrossed ? eventData->mLeftSelectionPosition : eventData->mRightSelectionPosition ) - startOfSelectedText;
115 const VectorBase::SizeType numberOfRuns = logicalModel->mFontDescriptionRuns.Count();
116 logicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
118 FontDescriptionRun& fontDescriptionRun = *( logicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
120 fontDescriptionRun.characterRun.characterIndex = startOfSelectedText;
121 fontDescriptionRun.characterRun.numberOfCharacters = lengthOfSelectedText;
123 // Recalculate the selection highlight as the metrics may have changed.
124 eventData->mUpdateLeftSelectionPosition = true;
125 eventData->mUpdateRightSelectionPosition = true;
126 eventData->mUpdateHighlightBox = true;
128 return fontDescriptionRun;
131 // public : Constructor.
133 ControllerPtr Controller::New()
135 return ControllerPtr( new Controller() );
138 ControllerPtr Controller::New( ControlInterface* controlInterface )
140 return ControllerPtr( new Controller( controlInterface ) );
143 ControllerPtr Controller::New( ControlInterface* controlInterface,
144 EditableControlInterface* editableControlInterface,
145 SelectableControlInterface* selectableControlInterface )
147 return ControllerPtr( new Controller( controlInterface,
148 editableControlInterface,
149 selectableControlInterface ) );
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() )
2912 bool consumed = false;
2913 if (keyName == KEY_C_NAME)
2915 // Ctrl-C 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 );
2933 else if( ( Dali::DALI_KEY_BACKSPACE == keyCode ) ||
2934 ( Dali::DevelKey::DALI_KEY_DELETE == keyCode ) )
2936 textChanged = DeleteEvent( keyCode );
2938 // Will request for relayout.
2939 relayoutNeeded = true;
2941 else if( IsKey( keyEvent, Dali::DALI_KEY_POWER ) ||
2942 IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
2943 IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
2945 // Power key/Menu/Home key behaviour does not allow edit mode to resume.
2946 mImpl->ChangeState( EventData::INACTIVE );
2948 // Will request for relayout.
2949 relayoutNeeded = true;
2951 // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text.
2953 else if( ( Dali::DALI_KEY_SHIFT_LEFT == keyCode ) || ( Dali::DALI_KEY_SHIFT_RIGHT == keyCode ) )
2955 // 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
2956 // and a character is typed after the type of a upper case latin character.
2961 else if( ( Dali::DALI_KEY_VOLUME_UP == keyCode ) || ( Dali::DALI_KEY_VOLUME_DOWN == keyCode ) )
2963 // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text.
2969 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
2971 if( !keyString.empty() )
2973 // InputMethodContext is no longer handling key-events
2974 mImpl->ClearPreEditFlag();
2976 InsertText( keyString, COMMIT );
2980 // Will request for relayout.
2981 relayoutNeeded = true;
2986 if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
2987 ( mImpl->mEventData->mState != EventData::INACTIVE ) &&
2989 ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) &&
2990 ( Dali::DALI_KEY_SHIFT_RIGHT != keyCode ) &&
2991 ( Dali::DALI_KEY_VOLUME_UP != keyCode ) &&
2992 ( Dali::DALI_KEY_VOLUME_DOWN != keyCode ) )
2994 // Should not change the state if the key is the shift send by the InputMethodContext.
2995 // Otherwise, when the state is SELECTING the text controller can't send the right
2996 // surrounding info to the InputMethodContext.
2997 mImpl->ChangeState( EventData::EDITING );
2999 // Will request for relayout.
3000 relayoutNeeded = true;
3003 if( relayoutNeeded )
3005 mImpl->RequestRelayout();
3010 ( NULL != mImpl->mEditableControlInterface ) )
3012 // Do this last since it provides callbacks into application code
3013 mImpl->mEditableControlInterface->TextChanged();
3019 void Controller::TapEvent( unsigned int tapCount, float x, float y )
3021 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
3023 if( NULL != mImpl->mEventData )
3025 DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState );
3026 EventData::State state( mImpl->mEventData->mState );
3027 bool relayoutNeeded( false ); // to avoid unnecessary relayouts when tapping an empty text-field
3029 if( mImpl->IsClipboardVisible() )
3031 if( EventData::INACTIVE == state || EventData::EDITING == state)
3033 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
3035 relayoutNeeded = true;
3037 else if( 1u == tapCount )
3039 if( EventData::EDITING_WITH_POPUP == state || EventData::EDITING_WITH_PASTE_POPUP == state )
3041 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); // If Popup shown hide it here so can be shown again if required.
3044 if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != state ) )
3046 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
3047 relayoutNeeded = true;
3051 if( mImpl->IsShowingPlaceholderText() && !mImpl->IsFocusedPlaceholderAvailable() )
3053 // Hide placeholder text
3057 if( EventData::INACTIVE == state )
3059 mImpl->ChangeState( EventData::EDITING );
3061 else if( !mImpl->IsClipboardEmpty() )
3063 mImpl->ChangeState( EventData::EDITING_WITH_POPUP );
3065 relayoutNeeded = true;
3068 else if( 2u == tapCount )
3070 if( mImpl->mEventData->mSelectionEnabled &&
3071 mImpl->IsShowingRealText() )
3073 relayoutNeeded = true;
3074 mImpl->mEventData->mIsLeftHandleSelected = true;
3075 mImpl->mEventData->mIsRightHandleSelected = true;
3079 // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
3080 if( relayoutNeeded )
3082 Event event( Event::TAP_EVENT );
3083 event.p1.mUint = tapCount;
3084 event.p2.mFloat = x;
3085 event.p3.mFloat = y;
3086 mImpl->mEventData->mEventQueue.push_back( event );
3088 mImpl->RequestRelayout();
3092 // Reset keyboard as tap event has occurred.
3093 mImpl->ResetInputMethodContext();
3096 void Controller::PanEvent( GestureState state, const Vector2& displacement )
3098 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
3100 if( NULL != mImpl->mEventData )
3102 Event event( Event::PAN_EVENT );
3103 event.p1.mInt = static_cast<int>( state );
3104 event.p2.mFloat = displacement.x;
3105 event.p3.mFloat = displacement.y;
3106 mImpl->mEventData->mEventQueue.push_back( event );
3108 mImpl->RequestRelayout();
3112 void Controller::LongPressEvent( GestureState state, float x, float y )
3114 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected LongPressEvent" );
3116 if( ( state == GestureState::STARTED ) &&
3117 ( NULL != mImpl->mEventData ) )
3119 // The 1st long-press on inactive text-field is treated as tap
3120 if( EventData::INACTIVE == mImpl->mEventData->mState )
3122 mImpl->ChangeState( EventData::EDITING );
3124 Event event( Event::TAP_EVENT );
3126 event.p2.mFloat = x;
3127 event.p3.mFloat = y;
3128 mImpl->mEventData->mEventQueue.push_back( event );
3130 mImpl->RequestRelayout();
3132 else if( !mImpl->IsShowingRealText() )
3134 Event event( Event::LONG_PRESS_EVENT );
3135 event.p1.mInt = static_cast<int>( state );
3136 event.p2.mFloat = x;
3137 event.p3.mFloat = y;
3138 mImpl->mEventData->mEventQueue.push_back( event );
3139 mImpl->RequestRelayout();
3141 else if( !mImpl->IsClipboardVisible() )
3143 // Reset the InputMethodContext to commit the pre-edit before selecting the text.
3144 mImpl->ResetInputMethodContext();
3146 Event event( Event::LONG_PRESS_EVENT );
3147 event.p1.mInt = static_cast<int>( state );
3148 event.p2.mFloat = x;
3149 event.p3.mFloat = y;
3150 mImpl->mEventData->mEventQueue.push_back( event );
3151 mImpl->RequestRelayout();
3153 mImpl->mEventData->mIsLeftHandleSelected = true;
3154 mImpl->mEventData->mIsRightHandleSelected = true;
3159 void Controller::SelectEvent( float x, float y, SelectionType selectType )
3161 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SelectEvent\n" );
3163 if( NULL != mImpl->mEventData )
3165 if( selectType == SelectionType::ALL )
3167 Event event( Event::SELECT_ALL );
3168 mImpl->mEventData->mEventQueue.push_back( event );
3170 else if( selectType == SelectionType::NONE )
3172 Event event( Event::SELECT_NONE );
3173 mImpl->mEventData->mEventQueue.push_back( event );
3177 Event event( Event::SELECT );
3178 event.p2.mFloat = x;
3179 event.p3.mFloat = y;
3180 mImpl->mEventData->mEventQueue.push_back( event );
3183 mImpl->mEventData->mCheckScrollAmount = true;
3184 mImpl->mEventData->mIsLeftHandleSelected = true;
3185 mImpl->mEventData->mIsRightHandleSelected = true;
3186 mImpl->RequestRelayout();
3190 void Controller::SetTextSelectionRange(const uint32_t *start, const uint32_t *end)
3192 if( mImpl->mEventData )
3194 mImpl->mEventData->mCheckScrollAmount = true;
3195 mImpl->mEventData->mIsLeftHandleSelected = true;
3196 mImpl->mEventData->mIsRightHandleSelected = true;
3197 mImpl->SetTextSelectionRange(start, end);
3198 mImpl->RequestRelayout();
3199 KeyboardFocusGainEvent();
3203 Uint32Pair Controller::GetTextSelectionRange() const
3205 return mImpl->GetTextSelectionRange();
3208 InputMethodContext::CallbackData Controller::OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent )
3210 // Whether the text needs to be relaid-out.
3211 bool requestRelayout = false;
3213 // Whether to retrieve the text and cursor position to be sent to the InputMethodContext.
3214 bool retrieveText = false;
3215 bool retrieveCursor = false;
3217 switch( inputMethodContextEvent.eventName )
3219 case InputMethodContext::COMMIT:
3221 InsertText( inputMethodContextEvent.predictiveString, Text::Controller::COMMIT );
3222 requestRelayout = true;
3223 retrieveCursor = true;
3226 case InputMethodContext::PRE_EDIT:
3228 InsertText( inputMethodContextEvent.predictiveString, Text::Controller::PRE_EDIT );
3229 requestRelayout = true;
3230 retrieveCursor = true;
3233 case InputMethodContext::DELETE_SURROUNDING:
3235 const bool textDeleted = RemoveText( inputMethodContextEvent.cursorOffset,
3236 inputMethodContextEvent.numberOfChars,
3237 DONT_UPDATE_INPUT_STYLE );
3241 if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
3242 !mImpl->IsPlaceholderAvailable() )
3244 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
3248 ShowPlaceholderText();
3250 mImpl->mEventData->mUpdateCursorPosition = true;
3251 mImpl->mEventData->mScrollAfterDelete = true;
3253 requestRelayout = true;
3257 case InputMethodContext::GET_SURROUNDING:
3259 retrieveText = true;
3260 retrieveCursor = true;
3263 case InputMethodContext::PRIVATE_COMMAND:
3265 // PRIVATECOMMAND event is just for getting the private command message
3266 retrieveText = true;
3267 retrieveCursor = true;
3270 case InputMethodContext::VOID:
3277 if( requestRelayout )
3279 mImpl->mOperationsPending = ALL_OPERATIONS;
3280 mImpl->RequestRelayout();
3284 CharacterIndex cursorPosition = 0u;
3285 Length numberOfWhiteSpaces = 0u;
3287 if( retrieveCursor )
3289 numberOfWhiteSpaces = mImpl->GetNumberOfWhiteSpaces( 0u );
3291 cursorPosition = mImpl->GetLogicalCursorPosition();
3293 if( cursorPosition < numberOfWhiteSpaces )
3295 cursorPosition = 0u;
3299 cursorPosition -= numberOfWhiteSpaces;
3305 if( !mImpl->IsShowingPlaceholderText() )
3307 // Retrieves the normal text string.
3308 mImpl->GetText( numberOfWhiteSpaces, text );
3312 // When the current text is Placeholder Text, the surrounding text should be empty string.
3313 // It means DALi should send empty string ("") to IME.
3318 InputMethodContext::CallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
3320 if( requestRelayout &&
3321 ( NULL != mImpl->mEditableControlInterface ) )
3323 // Do this last since it provides callbacks into application code
3324 mImpl->mEditableControlInterface->TextChanged();
3327 return callbackData;
3330 void Controller::PasteClipboardItemEvent()
3332 // Retrieve the clipboard contents first
3333 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
3334 std::string stringToPaste( notifier.GetContent() );
3336 // Commit the current pre-edit text; the contents of the clipboard should be appended
3337 mImpl->ResetInputMethodContext();
3339 // Temporary disable hiding clipboard
3340 mImpl->SetClipboardHideEnable( false );
3343 PasteText( stringToPaste );
3345 mImpl->SetClipboardHideEnable( true );
3348 // protected : Inherit from Text::Decorator::ControllerInterface.
3350 void Controller::GetTargetSize( Vector2& targetSize )
3352 targetSize = mImpl->mModel->mVisualModel->mControlSize;
3355 void Controller::AddDecoration( Actor& actor, bool needsClipping )
3357 if( NULL != mImpl->mEditableControlInterface )
3359 mImpl->mEditableControlInterface->AddDecoration( actor, needsClipping );
3363 void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
3365 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
3367 if( NULL != mImpl->mEventData )
3369 switch( handleType )
3373 Event event( Event::GRAB_HANDLE_EVENT );
3374 event.p1.mUint = state;
3375 event.p2.mFloat = x;
3376 event.p3.mFloat = y;
3378 mImpl->mEventData->mEventQueue.push_back( event );
3381 case LEFT_SELECTION_HANDLE:
3383 Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
3384 event.p1.mUint = state;
3385 event.p2.mFloat = x;
3386 event.p3.mFloat = y;
3388 mImpl->mEventData->mEventQueue.push_back( event );
3391 case RIGHT_SELECTION_HANDLE:
3393 Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
3394 event.p1.mUint = state;
3395 event.p2.mFloat = x;
3396 event.p3.mFloat = y;
3398 mImpl->mEventData->mEventQueue.push_back( event );
3401 case LEFT_SELECTION_HANDLE_MARKER:
3402 case RIGHT_SELECTION_HANDLE_MARKER:
3404 // Markers do not move the handles.
3407 case HANDLE_TYPE_COUNT:
3409 DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
3413 mImpl->RequestRelayout();
3417 // protected : Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
3419 void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button )
3421 if( NULL == mImpl->mEventData )
3428 case Toolkit::TextSelectionPopup::CUT:
3430 mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
3431 mImpl->mOperationsPending = ALL_OPERATIONS;
3433 if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
3434 !mImpl->IsPlaceholderAvailable() )
3436 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
3440 ShowPlaceholderText();
3443 mImpl->mEventData->mUpdateCursorPosition = true;
3444 mImpl->mEventData->mScrollAfterDelete = true;
3446 mImpl->RequestRelayout();
3448 if( NULL != mImpl->mEditableControlInterface )
3450 mImpl->mEditableControlInterface->TextChanged();
3454 case Toolkit::TextSelectionPopup::COPY:
3456 mImpl->SendSelectionToClipboard( false ); // Text not modified
3458 mImpl->mEventData->mUpdateCursorPosition = true;
3460 mImpl->RequestRelayout(); // Cursor, Handles, Selection Highlight, Popup
3463 case Toolkit::TextSelectionPopup::PASTE:
3465 mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
3468 case Toolkit::TextSelectionPopup::SELECT:
3470 const Vector2& currentCursorPosition = mImpl->mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
3472 if( mImpl->mEventData->mSelectionEnabled )
3474 // Creates a SELECT event.
3475 SelectEvent( currentCursorPosition.x, currentCursorPosition.y, SelectionType::INTERACTIVE );
3479 case Toolkit::TextSelectionPopup::SELECT_ALL:
3481 // Creates a SELECT_ALL event
3482 SelectEvent( 0.f, 0.f, SelectionType::ALL );
3485 case Toolkit::TextSelectionPopup::CLIPBOARD:
3487 mImpl->ShowClipboard();
3490 case Toolkit::TextSelectionPopup::NONE:
3498 void Controller::DisplayTimeExpired()
3500 mImpl->mEventData->mUpdateCursorPosition = true;
3501 // Apply modifications to the model
3502 mImpl->mOperationsPending = ALL_OPERATIONS;
3504 mImpl->RequestRelayout();
3507 // private : Update.
3509 void Controller::InsertText( const std::string& text, Controller::InsertType type )
3511 bool removedPrevious = false;
3512 bool removedSelected = false;
3513 bool maxLengthReached = false;
3515 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" )
3517 if( NULL == mImpl->mEventData )
3522 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n",
3523 this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
3524 mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
3526 // TODO: At the moment the underline runs are only for pre-edit.
3527 mImpl->mModel->mVisualModel->mUnderlineRuns.Clear();
3529 // Remove the previous InputMethodContext pre-edit.
3530 if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) )
3532 removedPrevious = RemoveText( -static_cast<int>( mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition ),
3533 mImpl->mEventData->mPreEditLength,
3534 DONT_UPDATE_INPUT_STYLE );
3536 mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
3537 mImpl->mEventData->mPreEditLength = 0u;
3541 // Remove the previous Selection.
3542 removedSelected = RemoveSelectedText();
3546 Vector<Character> utf32Characters;
3547 Length characterCount = 0u;
3551 // Convert text into UTF-32
3552 utf32Characters.Resize( text.size() );
3554 // This is a bit horrible but std::string returns a (signed) char*
3555 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
3557 // Transform a text array encoded in utf8 into an array encoded in utf32.
3558 // It returns the actual number of characters.
3559 characterCount = Utf8ToUtf32( utf8, text.size(), utf32Characters.Begin() );
3560 utf32Characters.Resize( characterCount );
3562 DALI_ASSERT_DEBUG( text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length" );
3563 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count() );
3566 if( 0u != utf32Characters.Count() ) // Check if Utf8ToUtf32 conversion succeeded
3568 // The placeholder text is no longer needed
3569 if( mImpl->IsShowingPlaceholderText() )
3574 mImpl->ChangeState( EventData::EDITING );
3576 // Handle the InputMethodContext (predicitive text) state changes
3577 if( COMMIT == type )
3579 // InputMethodContext is no longer handling key-events
3580 mImpl->ClearPreEditFlag();
3584 if( !mImpl->mEventData->mPreEditFlag )
3586 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state\n" );
3588 // Record the start of the pre-edit text
3589 mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
3592 mImpl->mEventData->mPreEditLength = utf32Characters.Count();
3593 mImpl->mEventData->mPreEditFlag = true;
3595 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
3598 const Length numberOfCharactersInModel = mImpl->mModel->mLogicalModel->mText.Count();
3600 // Restrict new text to fit within Maximum characters setting.
3601 Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
3602 maxLengthReached = ( characterCount > maxSizeOfNewText );
3604 // The cursor position.
3605 CharacterIndex& cursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
3607 // Update the text's style.
3609 // Updates the text style runs by adding characters.
3610 mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText );
3612 // Get the character index from the cursor index.
3613 const CharacterIndex styleIndex = ( cursorIndex > 0u ) ? cursorIndex - 1u : 0u;
3615 // Retrieve the text's style for the given index.
3617 mImpl->RetrieveDefaultInputStyle( style );
3618 mImpl->mModel->mLogicalModel->RetrieveStyle( styleIndex, style );
3620 // Whether to add a new text color run.
3621 const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor ) && !mImpl->mEventData->mInputStyle.isDefaultColor;
3623 // Whether to add a new font run.
3624 const bool addFontNameRun = ( style.familyName != mImpl->mEventData->mInputStyle.familyName ) && mImpl->mEventData->mInputStyle.isFamilyDefined;
3625 const bool addFontWeightRun = ( style.weight != mImpl->mEventData->mInputStyle.weight ) && mImpl->mEventData->mInputStyle.isWeightDefined;
3626 const bool addFontWidthRun = ( style.width != mImpl->mEventData->mInputStyle.width ) && mImpl->mEventData->mInputStyle.isWidthDefined;
3627 const bool addFontSlantRun = ( style.slant != mImpl->mEventData->mInputStyle.slant ) && mImpl->mEventData->mInputStyle.isSlantDefined;
3628 const bool addFontSizeRun = ( style.size != mImpl->mEventData->mInputStyle.size ) && mImpl->mEventData->mInputStyle.isSizeDefined ;
3633 const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
3634 mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
3636 ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
3637 colorRun.color = mImpl->mEventData->mInputStyle.textColor;
3638 colorRun.characterRun.characterIndex = cursorIndex;
3639 colorRun.characterRun.numberOfCharacters = maxSizeOfNewText;
3642 if( addFontNameRun ||
3648 const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Count();
3649 mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
3651 FontDescriptionRun& fontDescriptionRun = *( mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
3653 if( addFontNameRun )
3655 fontDescriptionRun.familyLength = mImpl->mEventData->mInputStyle.familyName.size();
3656 fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
3657 memcpy( fontDescriptionRun.familyName, mImpl->mEventData->mInputStyle.familyName.c_str(), fontDescriptionRun.familyLength );
3658 fontDescriptionRun.familyDefined = true;
3660 // The memory allocated for the font family name is freed when the font description is removed from the logical model.
3663 if( addFontWeightRun )
3665 fontDescriptionRun.weight = mImpl->mEventData->mInputStyle.weight;
3666 fontDescriptionRun.weightDefined = true;
3669 if( addFontWidthRun )
3671 fontDescriptionRun.width = mImpl->mEventData->mInputStyle.width;
3672 fontDescriptionRun.widthDefined = true;
3675 if( addFontSlantRun )
3677 fontDescriptionRun.slant = mImpl->mEventData->mInputStyle.slant;
3678 fontDescriptionRun.slantDefined = true;
3681 if( addFontSizeRun )
3683 fontDescriptionRun.size = static_cast<PointSize26Dot6>( mImpl->mEventData->mInputStyle.size * 64.f );
3684 fontDescriptionRun.sizeDefined = true;
3687 fontDescriptionRun.characterRun.characterIndex = cursorIndex;
3688 fontDescriptionRun.characterRun.numberOfCharacters = maxSizeOfNewText;
3691 // Insert at current cursor position.
3692 Vector<Character>& modifyText = mImpl->mModel->mLogicalModel->mText;
3694 if( cursorIndex < numberOfCharactersInModel )
3696 modifyText.Insert( modifyText.Begin() + cursorIndex, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
3700 modifyText.Insert( modifyText.End(), utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText );
3703 // Mark the first paragraph to be updated.
3704 if( Layout::Engine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() )
3706 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
3707 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
3708 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = numberOfCharactersInModel + maxSizeOfNewText;
3709 mImpl->mTextUpdateInfo.mClearAll = true;
3713 mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex );
3714 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd += maxSizeOfNewText;
3717 // Update the cursor index.
3718 cursorIndex += maxSizeOfNewText;
3720 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 );
3723 if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) &&
3724 mImpl->IsPlaceholderAvailable() )
3726 // Show place-holder if empty after removing the pre-edit text
3727 ShowPlaceholderText();
3728 mImpl->mEventData->mUpdateCursorPosition = true;
3729 mImpl->ClearPreEditFlag();
3731 else if( removedPrevious ||
3733 ( 0 != utf32Characters.Count() ) )
3735 // Queue an inserted event
3736 mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
3738 mImpl->mEventData->mUpdateCursorPosition = true;
3739 if( removedSelected )
3741 mImpl->mEventData->mScrollAfterDelete = true;
3745 mImpl->mEventData->mScrollAfterUpdatePosition = true;
3749 if( maxLengthReached )
3751 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mModel->mLogicalModel->mText.Count() );
3753 mImpl->ResetInputMethodContext();
3755 if( NULL != mImpl->mEditableControlInterface )
3757 // Do this last since it provides callbacks into application code
3758 mImpl->mEditableControlInterface->MaxLengthReached();
3763 void Controller::PasteText( const std::string& stringToPaste )
3765 InsertText( stringToPaste, Text::Controller::COMMIT );
3766 mImpl->ChangeState( EventData::EDITING );
3767 mImpl->RequestRelayout();
3769 if( NULL != mImpl->mEditableControlInterface )
3771 // Do this last since it provides callbacks into application code
3772 mImpl->mEditableControlInterface->TextChanged();
3776 bool Controller::RemoveText( int cursorOffset,
3777 int numberOfCharacters,
3778 UpdateInputStyleType type )
3780 bool removed = false;
3782 if( NULL == mImpl->mEventData )
3787 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n",
3788 this, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
3790 if( !mImpl->IsShowingPlaceholderText() )
3792 // Delete at current cursor position
3793 Vector<Character>& currentText = mImpl->mModel->mLogicalModel->mText;
3794 CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
3796 CharacterIndex cursorIndex = 0;
3798 // Validate the cursor position & number of characters
3799 if( ( static_cast< int >( mImpl->mEventData->mPrimaryCursorPosition ) + cursorOffset ) >= 0 )
3801 cursorIndex = mImpl->mEventData->mPrimaryCursorPosition + cursorOffset;
3804 if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )
3806 numberOfCharacters = currentText.Count() - cursorIndex;
3809 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.
3810 ( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) )
3812 // Mark the paragraphs to be updated.
3813 if( Layout::Engine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() )
3815 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
3816 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
3817 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters - numberOfCharacters;
3818 mImpl->mTextUpdateInfo.mClearAll = true;
3822 mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex );
3823 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove += numberOfCharacters;
3826 // Update the input style and remove the text's style before removing the text.
3828 if( UPDATE_INPUT_STYLE == type )
3830 // Keep a copy of the current input style.
3831 InputStyle currentInputStyle;
3832 currentInputStyle.Copy( mImpl->mEventData->mInputStyle );
3834 // Set first the default input style.
3835 mImpl->RetrieveDefaultInputStyle( mImpl->mEventData->mInputStyle );
3837 // Update the input style.
3838 mImpl->mModel->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
3840 // Compare if the input style has changed.
3841 const bool hasInputStyleChanged = !currentInputStyle.Equal( mImpl->mEventData->mInputStyle );
3843 if( hasInputStyleChanged )
3845 const InputStyle::Mask styleChangedMask = currentInputStyle.GetInputStyleChangeMask( mImpl->mEventData->mInputStyle );
3846 // Queue the input style changed signal.
3847 mImpl->mEventData->mInputStyleChangedQueue.PushBack( styleChangedMask );
3851 // If the number of current text and the number of characters to be deleted are same,
3852 // it means all texts should be removed and all Preedit variables should be initialized.
3853 if( ( currentText.Count() - numberOfCharacters == 0 ) && ( cursorIndex == 0 ) )
3855 mImpl->ClearPreEditFlag();
3856 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0;
3859 // Updates the text style runs by removing characters. Runs with no characters are removed.
3860 mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
3862 // Remove the characters.
3863 Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
3864 Vector<Character>::Iterator last = first + numberOfCharacters;
3866 currentText.Erase( first, last );
3868 // Cursor position retreat
3869 oldCursorIndex = cursorIndex;
3871 mImpl->mEventData->mScrollAfterDelete = true;
3873 if( EventData::INACTIVE == mImpl->mEventData->mState )
3875 mImpl->ChangeState( EventData::EDITING );
3878 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
3886 bool Controller::RemoveSelectedText()
3888 bool textRemoved( false );
3890 if( EventData::SELECTING == mImpl->mEventData->mState )
3892 std::string removedString;
3893 mImpl->RetrieveSelection( removedString, true );
3895 if( !removedString.empty() )
3898 mImpl->ChangeState( EventData::EDITING );
3905 std::string Controller::GetSelectedText()
3908 if( EventData::SELECTING == mImpl->mEventData->mState )
3910 mImpl->RetrieveSelection( text, false );
3915 // private : Relayout.
3917 bool Controller::DoRelayout( const Size& size,
3918 OperationsMask operationsRequired,
3921 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
3922 bool viewUpdated( false );
3924 // Calculate the operations to be done.
3925 const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
3927 const CharacterIndex startIndex = mImpl->mTextUpdateInfo.mParagraphCharacterIndex;
3928 const Length requestedNumberOfCharacters = mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters;
3930 // Get the current layout size.
3931 layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
3933 if( NO_OPERATION != ( LAYOUT & operations ) )
3935 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout LAYOUT & operations\n");
3937 // Some vectors with data needed to layout and reorder may be void
3938 // after the first time the text has been laid out.
3939 // Fill the vectors again.
3941 // Calculate the number of glyphs to layout.
3942 const Vector<GlyphIndex>& charactersToGlyph = mImpl->mModel->mVisualModel->mCharactersToGlyph;
3943 const Vector<Length>& glyphsPerCharacter = mImpl->mModel->mVisualModel->mGlyphsPerCharacter;
3944 const GlyphIndex* const charactersToGlyphBuffer = charactersToGlyph.Begin();
3945 const Length* const glyphsPerCharacterBuffer = glyphsPerCharacter.Begin();
3947 const CharacterIndex lastIndex = startIndex + ( ( requestedNumberOfCharacters > 0u ) ? requestedNumberOfCharacters - 1u : 0u );
3948 const GlyphIndex startGlyphIndex = mImpl->mTextUpdateInfo.mStartGlyphIndex;
3950 // Make sure the index is not out of bound
3951 if ( charactersToGlyph.Count() != glyphsPerCharacter.Count() ||
3952 requestedNumberOfCharacters > charactersToGlyph.Count() ||
3953 ( lastIndex > charactersToGlyph.Count() && charactersToGlyph.Count() > 0u ) )
3955 std::string currentText;
3956 GetText( currentText );
3958 DALI_LOG_ERROR( "Controller::DoRelayout: Attempting to access invalid buffer\n" );
3959 DALI_LOG_ERROR( "Current text is: %s\n", currentText.c_str() );
3960 DALI_LOG_ERROR( "startIndex: %u, lastIndex: %u, requestedNumberOfCharacters: %u, charactersToGlyph.Count = %lu, glyphsPerCharacter.Count = %lu\n", startIndex, lastIndex, requestedNumberOfCharacters, charactersToGlyph.Count(), glyphsPerCharacter.Count());
3965 const Length numberOfGlyphs = ( requestedNumberOfCharacters > 0u ) ? *( charactersToGlyphBuffer + lastIndex ) + *( glyphsPerCharacterBuffer + lastIndex ) - startGlyphIndex : 0u;
3966 const Length totalNumberOfGlyphs = mImpl->mModel->mVisualModel->mGlyphs.Count();
3968 if( 0u == totalNumberOfGlyphs )
3970 if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
3972 mImpl->mModel->mVisualModel->SetLayoutSize( Size::ZERO );
3975 // Nothing else to do if there is no glyphs.
3976 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
3980 // Set the layout parameters.
3981 Layout::Parameters layoutParameters( size,
3984 // Resize the vector of positions to have the same size than the vector of glyphs.
3985 Vector<Vector2>& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions;
3986 glyphPositions.Resize( totalNumberOfGlyphs );
3988 // Whether the last character is a new paragraph character.
3989 const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
3990 mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mModel->mLogicalModel->mText.Count() - 1u ) ) );
3991 layoutParameters.isLastNewParagraph = mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph;
3993 // The initial glyph and the number of glyphs to layout.
3994 layoutParameters.startGlyphIndex = startGlyphIndex;
3995 layoutParameters.numberOfGlyphs = numberOfGlyphs;
3996 layoutParameters.startLineIndex = mImpl->mTextUpdateInfo.mStartLineIndex;
3997 layoutParameters.estimatedNumberOfLines = mImpl->mTextUpdateInfo.mEstimatedNumberOfLines;
3999 // Update the ellipsis
4000 bool elideTextEnabled = mImpl->mModel->mElideEnabled;
4002 if( NULL != mImpl->mEventData )
4004 if( mImpl->mEventData->mPlaceholderEllipsisFlag && mImpl->IsShowingPlaceholderText() )
4006 elideTextEnabled = mImpl->mEventData->mIsPlaceholderElideEnabled;
4008 else if( EventData::INACTIVE != mImpl->mEventData->mState )
4010 // Disable ellipsis when editing
4011 elideTextEnabled = false;
4014 // Reset the scroll position in inactive state
4015 if( elideTextEnabled && ( mImpl->mEventData->mState == EventData::INACTIVE ) )
4017 ResetScrollPosition();
4021 // Update the visual model.
4022 bool isAutoScrollEnabled = mImpl->mIsAutoScrollEnabled;
4024 viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
4027 isAutoScrollEnabled );
4028 mImpl->mIsAutoScrollEnabled = isAutoScrollEnabled;
4030 viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );
4034 layoutSize = newLayoutSize;
4036 if( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
4038 mImpl->mIsTextDirectionRTL = false;
4041 if ( ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) && !mImpl->mModel->mVisualModel->mLines.Empty() )
4043 mImpl->mIsTextDirectionRTL = mImpl->mModel->mVisualModel->mLines[0u].direction;
4046 // Sets the layout size.
4047 if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
4049 mImpl->mModel->mVisualModel->SetLayoutSize( layoutSize );
4054 if( NO_OPERATION != ( ALIGN & operations ) )
4056 // The laid-out lines.
4057 Vector<LineRun>& lines = mImpl->mModel->mVisualModel->mLines;
4059 CharacterIndex alignStartIndex = startIndex;
4060 Length alignRequestedNumberOfCharacters = requestedNumberOfCharacters;
4062 // the whole text needs to be full aligned.
4063 // If you do not do a full aligned, only the last line of the multiline input is aligned.
4064 if( mImpl->mEventData && mImpl->mEventData->mUpdateAlignment )
4066 alignStartIndex = 0u;
4067 alignRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
4068 mImpl->mEventData->mUpdateAlignment = false;
4071 // Need to align with the control's size as the text may contain lines
4072 // starting either with left to right text or right to left.
4073 mImpl->mLayoutEngine.Align( size,
4075 alignRequestedNumberOfCharacters,
4076 mImpl->mModel->mHorizontalAlignment,
4078 mImpl->mModel->mAlignmentOffset,
4079 mImpl->mLayoutDirection,
4080 mImpl->mModel->mMatchSystemLanguageDirection );
4084 #if defined(DEBUG_ENABLED)
4085 std::string currentText;
4086 GetText( currentText );
4087 DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::DoRelayout [%p] mImpl->mIsTextDirectionRTL[%s] [%s]\n", this, (mImpl->mIsTextDirectionRTL)?"true":"false", currentText.c_str() );
4089 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
4093 void Controller::CalculateVerticalOffset( const Size& controlSize )
4095 Size layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
4097 if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 )
4099 // Get the line height of the default font.
4100 layoutSize.height = mImpl->GetDefaultFontLineHeight();
4103 switch( mImpl->mModel->mVerticalAlignment )
4105 case VerticalAlignment::TOP:
4107 mImpl->mModel->mScrollPosition.y = 0.f;
4110 case VerticalAlignment::CENTER:
4112 mImpl->mModel->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
4115 case VerticalAlignment::BOTTOM:
4117 mImpl->mModel->mScrollPosition.y = controlSize.height - layoutSize.height;
4123 // private : Events.
4125 void Controller::ProcessModifyEvents()
4127 Vector<ModifyEvent>& events = mImpl->mModifyEvents;
4129 if( 0u == events.Count() )
4135 for( Vector<ModifyEvent>::ConstIterator it = events.Begin(),
4136 endIt = events.End();
4140 const ModifyEvent& event = *it;
4142 if( ModifyEvent::TEXT_REPLACED == event.type )
4144 // A (single) replace event should come first, otherwise we wasted time processing NOOP events
4145 DALI_ASSERT_DEBUG( it == events.Begin() && "Unexpected TEXT_REPLACED event" );
4147 TextReplacedEvent();
4149 else if( ModifyEvent::TEXT_INSERTED == event.type )
4151 TextInsertedEvent();
4153 else if( ModifyEvent::TEXT_DELETED == event.type )
4155 // Placeholder-text cannot be deleted
4156 if( !mImpl->IsShowingPlaceholderText() )
4163 if( NULL != mImpl->mEventData )
4165 // When the text is being modified, delay cursor blinking
4166 mImpl->mEventData->mDecorator->DelayCursorBlink();
4168 // Update selection position after modifying the text
4169 mImpl->mEventData->mLeftSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
4170 mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
4173 // DISCARD temporary text
4177 void Controller::TextReplacedEvent()
4179 // The natural size needs to be re-calculated.
4180 mImpl->mRecalculateNaturalSize = true;
4182 // The text direction needs to be updated.
4183 mImpl->mUpdateTextDirection = true;
4185 // Apply modifications to the model
4186 mImpl->mOperationsPending = ALL_OPERATIONS;
4189 void Controller::TextInsertedEvent()
4191 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
4193 if( NULL == mImpl->mEventData )
4198 mImpl->mEventData->mCheckScrollAmount = true;
4200 // The natural size needs to be re-calculated.
4201 mImpl->mRecalculateNaturalSize = true;
4203 // The text direction needs to be updated.
4204 mImpl->mUpdateTextDirection = true;
4206 // Apply modifications to the model; TODO - Optimize this
4207 mImpl->mOperationsPending = ALL_OPERATIONS;
4210 void Controller::TextDeletedEvent()
4212 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
4214 if( NULL == mImpl->mEventData )
4219 mImpl->mEventData->mCheckScrollAmount = true;
4221 // The natural size needs to be re-calculated.
4222 mImpl->mRecalculateNaturalSize = true;
4224 // The text direction needs to be updated.
4225 mImpl->mUpdateTextDirection = true;
4227 // Apply modifications to the model; TODO - Optimize this
4228 mImpl->mOperationsPending = ALL_OPERATIONS;
4231 bool Controller::DeleteEvent( int keyCode )
4233 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p KeyCode : %d \n", this, keyCode );
4235 bool removed = false;
4237 if( NULL == mImpl->mEventData )
4242 // InputMethodContext is no longer handling key-events
4243 mImpl->ClearPreEditFlag();
4245 if( EventData::SELECTING == mImpl->mEventData->mState )
4247 removed = RemoveSelectedText();
4249 else if( ( mImpl->mEventData->mPrimaryCursorPosition > 0 ) && ( keyCode == Dali::DALI_KEY_BACKSPACE) )
4251 // Remove the character before the current cursor position
4252 removed = RemoveText( -1,
4254 UPDATE_INPUT_STYLE );
4256 else if( keyCode == Dali::DevelKey::DALI_KEY_DELETE )
4258 // Remove the character after the current cursor position
4259 removed = RemoveText( 0,
4261 UPDATE_INPUT_STYLE );
4266 if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
4267 !mImpl->IsPlaceholderAvailable() )
4269 mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
4273 ShowPlaceholderText();
4275 mImpl->mEventData->mUpdateCursorPosition = true;
4276 mImpl->mEventData->mScrollAfterDelete = true;
4282 // private : Helpers.
4284 void Controller::ResetText()
4287 mImpl->mModel->mLogicalModel->mText.Clear();
4289 // Reset the embedded images buffer.
4290 mImpl->mModel->mLogicalModel->ClearEmbeddedImages();
4292 // We have cleared everything including the placeholder-text
4293 mImpl->PlaceholderCleared();
4295 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
4296 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
4297 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0u;
4299 // Clear any previous text.
4300 mImpl->mTextUpdateInfo.mClearAll = true;
4302 // The natural size needs to be re-calculated.
4303 mImpl->mRecalculateNaturalSize = true;
4305 // The text direction needs to be updated.
4306 mImpl->mUpdateTextDirection = true;
4308 // Apply modifications to the model
4309 mImpl->mOperationsPending = ALL_OPERATIONS;
4312 void Controller::ShowPlaceholderText()
4314 if( mImpl->IsPlaceholderAvailable() )
4316 DALI_ASSERT_DEBUG( mImpl->mEventData && "No placeholder text available" );
4318 if( NULL == mImpl->mEventData )
4323 mImpl->mEventData->mIsShowingPlaceholderText = true;
4325 // Disable handles when showing place-holder text
4326 mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
4327 mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
4328 mImpl->mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
4330 const char* text( NULL );
4333 // TODO - Switch Placeholder text when changing state
4334 if( ( EventData::INACTIVE != mImpl->mEventData->mState ) &&
4335 ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) )
4337 text = mImpl->mEventData->mPlaceholderTextActive.c_str();
4338 size = mImpl->mEventData->mPlaceholderTextActive.size();
4342 text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
4343 size = mImpl->mEventData->mPlaceholderTextInactive.size();
4346 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
4347 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
4349 // Reset model for showing placeholder.
4350 mImpl->mModel->mLogicalModel->mText.Clear();
4351 mImpl->mModel->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
4353 // Convert text into UTF-32
4354 Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
4355 utf32Characters.Resize( size );
4357 // This is a bit horrible but std::string returns a (signed) char*
4358 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text );
4360 // Transform a text array encoded in utf8 into an array encoded in utf32.
4361 // It returns the actual number of characters.
4362 const Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
4363 utf32Characters.Resize( characterCount );
4365 // The characters to be added.
4366 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = characterCount;
4368 // Reset the cursor position
4369 mImpl->mEventData->mPrimaryCursorPosition = 0;
4371 // The natural size needs to be re-calculated.
4372 mImpl->mRecalculateNaturalSize = true;
4374 // The text direction needs to be updated.
4375 mImpl->mUpdateTextDirection = true;
4377 // Apply modifications to the model
4378 mImpl->mOperationsPending = ALL_OPERATIONS;
4380 // Update the rest of the model during size negotiation
4381 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
4385 void Controller::ClearFontData()
4387 if( mImpl->mFontDefaults )
4389 mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
4392 // Set flags to update the model.
4393 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
4394 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
4395 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
4397 mImpl->mTextUpdateInfo.mClearAll = true;
4398 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
4399 mImpl->mRecalculateNaturalSize = true;
4401 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
4407 UPDATE_LAYOUT_SIZE |
4412 void Controller::ClearStyleData()
4414 mImpl->mModel->mLogicalModel->mColorRuns.Clear();
4415 mImpl->mModel->mLogicalModel->ClearFontDescriptionRuns();
4418 void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
4420 // Reset the cursor position
4421 if( NULL != mImpl->mEventData )
4423 mImpl->mEventData->mPrimaryCursorPosition = cursorIndex;
4425 // Update the cursor if it's in editing mode.
4426 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
4428 mImpl->mEventData->mUpdateCursorPosition = true;
4433 void Controller::ResetScrollPosition()
4435 if( NULL != mImpl->mEventData )
4437 // Reset the scroll position.
4438 mImpl->mModel->mScrollPosition = Vector2::ZERO;
4439 mImpl->mEventData->mScrollAfterUpdatePosition = true;
4443 void Controller::SetControlInterface( ControlInterface* controlInterface )
4445 mImpl->mControlInterface = controlInterface;
4448 bool Controller::ShouldClearFocusOnEscape() const
4450 return mImpl->mShouldClearFocusOnEscape;
4453 Actor Controller::CreateBackgroundActor()
4455 return mImpl->CreateBackgroundActor();
4458 // private : Private contructors & copy operator.
4460 Controller::Controller()
4463 mImpl = new Controller::Impl( nullptr, nullptr, nullptr );
4466 Controller::Controller( ControlInterface* controlInterface )
4468 mImpl = new Controller::Impl( controlInterface, NULL, NULL );
4471 Controller::Controller( ControlInterface* controlInterface,
4472 EditableControlInterface* editableControlInterface,
4473 SelectableControlInterface* selectableControlInterface )
4475 mImpl = new Controller::Impl( controlInterface,
4476 editableControlInterface,
4477 selectableControlInterface );
4480 // The copy constructor and operator are left unimplemented.
4482 // protected : Destructor.
4484 Controller::~Controller()
4491 } // namespace Toolkit