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 )
146 return ControllerPtr( new Controller( controlInterface,
147 editableControlInterface ) );
150 // public : Configure the text controller.
152 void Controller::EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext )
156 delete mImpl->mEventData;
157 mImpl->mEventData = NULL;
159 // Nothing else to do.
163 if( NULL == mImpl->mEventData )
165 mImpl->mEventData = new EventData( decorator, inputMethodContext );
169 void Controller::SetGlyphType( TextAbstraction::GlyphType glyphType )
171 // Metrics for bitmap & vector based glyphs are different
172 mImpl->mMetrics->SetGlyphType( glyphType );
174 // Clear the font-specific data
177 mImpl->RequestRelayout();
180 void Controller::SetMarkupProcessorEnabled( bool enable )
182 if( enable != mImpl->mMarkupProcessorEnabled )
184 //If Text was already set, call the SetText again for enabling or disabling markup
185 mImpl->mMarkupProcessorEnabled = enable;
192 bool Controller::IsMarkupProcessorEnabled() const
194 return mImpl->mMarkupProcessorEnabled;
197 void Controller::SetAutoScrollEnabled( bool enable )
199 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 );
201 if( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX )
205 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled for SINGLE_LINE_BOX\n" );
206 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
216 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled Disabling autoscroll\n");
217 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
224 mImpl->mIsAutoScrollEnabled = enable;
225 mImpl->RequestRelayout();
229 DALI_LOG_WARNING( "Attempted AutoScrolling on a non SINGLE_LINE_BOX, request ignored\n" );
230 mImpl->mIsAutoScrollEnabled = false;
234 bool Controller::IsAutoScrollEnabled() const
236 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::IsAutoScrollEnabled[%s]\n", mImpl->mIsAutoScrollEnabled?"true":"false" );
238 return mImpl->mIsAutoScrollEnabled;
241 CharacterDirection Controller::GetAutoScrollDirection() const
243 return mImpl->mIsTextDirectionRTL;
246 float Controller::GetAutoScrollLineAlignment() const
250 if( mImpl->mModel->mVisualModel &&
251 ( 0u != mImpl->mModel->mVisualModel->mLines.Count() ) )
253 offset = ( *mImpl->mModel->mVisualModel->mLines.Begin() ).alignmentOffset;
259 void Controller::SetHorizontalScrollEnabled( bool enable )
261 if( ( NULL != mImpl->mEventData ) &&
262 mImpl->mEventData->mDecorator )
264 mImpl->mEventData->mDecorator->SetHorizontalScrollEnabled( enable );
267 bool Controller::IsHorizontalScrollEnabled() const
269 if( ( NULL != mImpl->mEventData ) &&
270 mImpl->mEventData->mDecorator )
272 return mImpl->mEventData->mDecorator->IsHorizontalScrollEnabled();
278 void Controller::SetVerticalScrollEnabled( bool enable )
280 if( ( NULL != mImpl->mEventData ) &&
281 mImpl->mEventData->mDecorator )
283 if( mImpl->mEventData->mDecorator )
285 mImpl->mEventData->mDecorator->SetVerticalScrollEnabled( enable );
290 bool Controller::IsVerticalScrollEnabled() const
292 if( ( NULL != mImpl->mEventData ) &&
293 mImpl->mEventData->mDecorator )
295 return mImpl->mEventData->mDecorator->IsVerticalScrollEnabled();
301 void Controller::SetSmoothHandlePanEnabled( bool enable )
303 if( ( NULL != mImpl->mEventData ) &&
304 mImpl->mEventData->mDecorator )
306 mImpl->mEventData->mDecorator->SetSmoothHandlePanEnabled( enable );
310 bool Controller::IsSmoothHandlePanEnabled() const
312 if( ( NULL != mImpl->mEventData ) &&
313 mImpl->mEventData->mDecorator )
315 return mImpl->mEventData->mDecorator->IsSmoothHandlePanEnabled();
321 void Controller::SetMaximumNumberOfCharacters( Length maxCharacters )
323 mImpl->mMaximumNumberOfCharacters = maxCharacters;
326 int Controller::GetMaximumNumberOfCharacters()
328 return mImpl->mMaximumNumberOfCharacters;
331 void Controller::SetEnableCursorBlink( bool enable )
333 DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
335 if( NULL != mImpl->mEventData )
337 mImpl->mEventData->mCursorBlinkEnabled = enable;
340 mImpl->mEventData->mDecorator )
342 mImpl->mEventData->mDecorator->StopCursorBlink();
347 bool Controller::GetEnableCursorBlink() const
349 if( NULL != mImpl->mEventData )
351 return mImpl->mEventData->mCursorBlinkEnabled;
357 void Controller::SetMultiLineEnabled( bool enable )
359 const Layout::Engine::Type layout = enable ? Layout::Engine::MULTI_LINE_BOX : Layout::Engine::SINGLE_LINE_BOX;
361 if( layout != mImpl->mLayoutEngine.GetLayout() )
363 // Set the layout type.
364 mImpl->mLayoutEngine.SetLayout( layout );
366 // Set the flags to redo the layout operations
367 const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
372 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
373 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
375 // Need to recalculate natural size
376 mImpl->mRecalculateNaturalSize = true;
378 mImpl->RequestRelayout();
382 bool Controller::IsMultiLineEnabled() const
384 return Layout::Engine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
387 void Controller::SetHorizontalAlignment( Text::HorizontalAlignment::Type alignment )
389 if( alignment != mImpl->mModel->mHorizontalAlignment )
391 // Set the alignment.
392 mImpl->mModel->mHorizontalAlignment = alignment;
394 // Set the flag to redo the alignment operation.
395 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
397 if( mImpl->mEventData )
399 mImpl->mEventData->mUpdateAlignment = true;
401 // Update the cursor if it's in editing mode
402 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
404 mImpl->ChangeState( EventData::EDITING );
405 mImpl->mEventData->mUpdateCursorPosition = true;
409 mImpl->RequestRelayout();
413 Text::HorizontalAlignment::Type Controller::GetHorizontalAlignment() const
415 return mImpl->mModel->mHorizontalAlignment;
418 void Controller::SetVerticalAlignment( VerticalAlignment::Type alignment )
420 if( alignment != mImpl->mModel->mVerticalAlignment )
422 // Set the alignment.
423 mImpl->mModel->mVerticalAlignment = alignment;
425 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
427 mImpl->RequestRelayout();
431 VerticalAlignment::Type Controller::GetVerticalAlignment() const
433 return mImpl->mModel->mVerticalAlignment;
436 bool Controller::IsIgnoreSpacesAfterText() const
438 return mImpl->mModel->mIgnoreSpacesAfterText;
441 void Controller::SetIgnoreSpacesAfterText( bool ignore )
443 mImpl->mModel->mIgnoreSpacesAfterText = ignore;
446 bool Controller::IsMatchSystemLanguageDirection() const
448 return mImpl->mModel->mMatchSystemLanguageDirection;
451 void Controller::SetMatchSystemLanguageDirection( bool match )
453 mImpl->mModel->mMatchSystemLanguageDirection = match;
456 void Controller::SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection )
458 mImpl->mLayoutDirection = layoutDirection;
461 bool Controller::IsShowingRealText() const
463 return mImpl->IsShowingRealText();
467 void Controller::SetLineWrapMode( Text::LineWrap::Mode lineWrapMode )
469 if( lineWrapMode != mImpl->mModel->mLineWrapMode )
471 // Set the text wrap mode.
472 mImpl->mModel->mLineWrapMode = lineWrapMode;
475 // Update Text layout for applying wrap mode
476 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
481 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
482 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
483 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
486 mImpl->RequestRelayout();
490 Text::LineWrap::Mode Controller::GetLineWrapMode() const
492 return mImpl->mModel->mLineWrapMode;
495 void Controller::SetTextElideEnabled( bool enabled )
497 mImpl->mModel->mElideEnabled = enabled;
500 bool Controller::IsTextElideEnabled() const
502 return mImpl->mModel->mElideEnabled;
505 void Controller::SetTextFitEnabled(bool enabled)
507 mImpl->mTextFitEnabled = enabled;
510 bool Controller::IsTextFitEnabled() const
512 return mImpl->mTextFitEnabled;
515 void Controller::SetTextFitMinSize( float minSize, FontSizeType type )
521 mImpl->mTextFitMinSize = minSize;
526 mImpl->mTextFitMinSize = ConvertPixelToPint( minSize );
532 float Controller::GetTextFitMinSize() const
534 return mImpl->mTextFitMinSize;
537 void Controller::SetTextFitMaxSize( float maxSize, FontSizeType type )
543 mImpl->mTextFitMaxSize = maxSize;
548 mImpl->mTextFitMaxSize = ConvertPixelToPint( maxSize );
554 float Controller::GetTextFitMaxSize() const
556 return mImpl->mTextFitMaxSize;
559 void Controller::SetTextFitStepSize( float step, FontSizeType type )
565 mImpl->mTextFitStepSize = step;
570 mImpl->mTextFitStepSize = ConvertPixelToPint( step );
576 float Controller::GetTextFitStepSize() const
578 return mImpl->mTextFitStepSize;
581 void Controller::SetTextFitContentSize(Vector2 size)
583 mImpl->mTextFitContentSize = size;
586 Vector2 Controller::GetTextFitContentSize() const
588 return mImpl->mTextFitContentSize;
591 void Controller::SetPlaceholderTextElideEnabled( bool enabled )
593 mImpl->mEventData->mIsPlaceholderElideEnabled = enabled;
594 mImpl->mEventData->mPlaceholderEllipsisFlag = true;
596 // Update placeholder if there is no text
597 if( mImpl->IsShowingPlaceholderText() ||
598 ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
600 ShowPlaceholderText();
604 bool Controller::IsPlaceholderTextElideEnabled() const
606 return mImpl->mEventData->mIsPlaceholderElideEnabled;
609 void Controller::SetSelectionEnabled( bool enabled )
611 mImpl->mEventData->mSelectionEnabled = enabled;
614 bool Controller::IsSelectionEnabled() const
616 return mImpl->mEventData->mSelectionEnabled;
619 void Controller::SetShiftSelectionEnabled( bool enabled )
621 mImpl->mEventData->mShiftSelectionFlag = enabled;
624 bool Controller::IsShiftSelectionEnabled() const
626 return mImpl->mEventData->mShiftSelectionFlag;
629 void Controller::SetGrabHandleEnabled( bool enabled )
631 mImpl->mEventData->mGrabHandleEnabled = enabled;
634 bool Controller::IsGrabHandleEnabled() const
636 return mImpl->mEventData->mGrabHandleEnabled;
639 void Controller::SetGrabHandlePopupEnabled(bool enabled)
641 mImpl->mEventData->mGrabHandlePopupEnabled = enabled;
644 bool Controller::IsGrabHandlePopupEnabled() const
646 return mImpl->mEventData->mGrabHandlePopupEnabled;
651 void Controller::SetText( const std::string& text )
653 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" );
655 // Reset keyboard as text changed
656 mImpl->ResetInputMethodContext();
658 // Remove the previously set text and style.
664 CharacterIndex lastCursorIndex = 0u;
666 if( NULL != mImpl->mEventData )
668 // If popup shown then hide it by switching to Editing state
669 if( ( EventData::SELECTING == mImpl->mEventData->mState ) ||
670 ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) ||
671 ( EventData::EDITING_WITH_GRAB_HANDLE == mImpl->mEventData->mState ) ||
672 ( EventData::EDITING_WITH_PASTE_POPUP == mImpl->mEventData->mState ) )
674 mImpl->ChangeState( EventData::EDITING );
680 mImpl->mModel->mVisualModel->SetTextColor( mImpl->mTextColor );
682 MarkupProcessData markupProcessData( mImpl->mModel->mLogicalModel->mColorRuns,
683 mImpl->mModel->mLogicalModel->mFontDescriptionRuns,
684 mImpl->mModel->mLogicalModel->mEmbeddedItems );
686 Length textSize = 0u;
687 const uint8_t* utf8 = NULL;
688 if( mImpl->mMarkupProcessorEnabled )
690 ProcessMarkupString( text, markupProcessData );
691 textSize = markupProcessData.markupProcessedText.size();
693 // This is a bit horrible but std::string returns a (signed) char*
694 utf8 = reinterpret_cast<const uint8_t*>( markupProcessData.markupProcessedText.c_str() );
698 textSize = text.size();
700 // This is a bit horrible but std::string returns a (signed) char*
701 utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
704 // Convert text into UTF-32
705 Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
706 utf32Characters.Resize( textSize );
708 // Transform a text array encoded in utf8 into an array encoded in utf32.
709 // It returns the actual number of characters.
710 Length characterCount = Utf8ToUtf32( utf8, textSize, utf32Characters.Begin() );
711 utf32Characters.Resize( characterCount );
713 DALI_ASSERT_DEBUG( textSize >= characterCount && "Invalid UTF32 conversion length" );
714 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mModel->mLogicalModel->mText.Count() );
716 // The characters to be added.
717 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
719 // To reset the cursor position
720 lastCursorIndex = characterCount;
722 // Update the rest of the model during size negotiation
723 mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
725 // The natural size needs to be re-calculated.
726 mImpl->mRecalculateNaturalSize = true;
728 // The text direction needs to be updated.
729 mImpl->mUpdateTextDirection = true;
731 // Apply modifications to the model
732 mImpl->mOperationsPending = ALL_OPERATIONS;
736 ShowPlaceholderText();
739 // Resets the cursor position.
740 ResetCursorPosition( lastCursorIndex );
742 // Scrolls the text to make the cursor visible.
743 ResetScrollPosition();
745 mImpl->RequestRelayout();
747 if( NULL != mImpl->mEventData )
749 // Cancel previously queued events
750 mImpl->mEventData->mEventQueue.clear();
753 // Do this last since it provides callbacks into application code.
754 if( NULL != mImpl->mEditableControlInterface )
756 mImpl->mEditableControlInterface->TextChanged();
760 void Controller::GetText( std::string& text ) const
762 if( !mImpl->IsShowingPlaceholderText() )
764 // Retrieves the text string.
765 mImpl->GetText( 0u, text );
769 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::GetText %p empty (but showing placeholder)\n", this );
773 void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
775 if( NULL != mImpl->mEventData )
777 if( PLACEHOLDER_TYPE_INACTIVE == type )
779 mImpl->mEventData->mPlaceholderTextInactive = text;
783 mImpl->mEventData->mPlaceholderTextActive = text;
786 // Update placeholder if there is no text
787 if( mImpl->IsShowingPlaceholderText() ||
788 ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
790 ShowPlaceholderText();
795 void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
797 if( NULL != mImpl->mEventData )
799 if( PLACEHOLDER_TYPE_INACTIVE == type )
801 text = mImpl->mEventData->mPlaceholderTextInactive;
805 text = mImpl->mEventData->mPlaceholderTextActive;
810 void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
812 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::UpdateAfterFontChange\n");
814 if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
816 DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
817 mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
821 mImpl->RequestRelayout();
825 // public : Default style & Input style
827 void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
829 if( NULL == mImpl->mFontDefaults )
831 mImpl->mFontDefaults = new FontDefaults();
834 mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily;
835 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str());
836 mImpl->mFontDefaults->familyDefined = !defaultFontFamily.empty();
838 if( mImpl->mEventData )
840 // Update the cursor position if it's in editing mode
841 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
843 mImpl->mEventData->mDecoratorUpdated = true;
844 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font family is updated.
848 // Clear the font-specific data
851 mImpl->RequestRelayout();
854 const std::string& Controller::GetDefaultFontFamily() const
856 if( NULL != mImpl->mFontDefaults )
858 return mImpl->mFontDefaults->mFontDescription.family;
864 void Controller::SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily )
866 if( NULL != mImpl->mEventData )
868 if( NULL == mImpl->mEventData->mPlaceholderFont )
870 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
873 mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
874 DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
875 mImpl->mEventData->mPlaceholderFont->familyDefined = !placeholderTextFontFamily.empty();
877 mImpl->RequestRelayout();
881 const std::string& Controller::GetPlaceholderFontFamily() const
883 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
885 return mImpl->mEventData->mPlaceholderFont->mFontDescription.family;
891 void Controller::SetDefaultFontWeight( FontWeight weight )
893 if( NULL == mImpl->mFontDefaults )
895 mImpl->mFontDefaults = new FontDefaults();
898 mImpl->mFontDefaults->mFontDescription.weight = weight;
899 mImpl->mFontDefaults->weightDefined = true;
901 if( mImpl->mEventData )
903 // Update the cursor position if it's in editing mode
904 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
906 mImpl->mEventData->mDecoratorUpdated = true;
907 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font weight is updated.
911 // Clear the font-specific data
914 mImpl->RequestRelayout();
917 bool Controller::IsDefaultFontWeightDefined() const
919 if( NULL != mImpl->mFontDefaults )
921 return mImpl->mFontDefaults->weightDefined;
927 FontWeight Controller::GetDefaultFontWeight() const
929 if( NULL != mImpl->mFontDefaults )
931 return mImpl->mFontDefaults->mFontDescription.weight;
934 return TextAbstraction::FontWeight::NORMAL;
937 void Controller::SetPlaceholderTextFontWeight( FontWeight weight )
939 if( NULL != mImpl->mEventData )
941 if( NULL == mImpl->mEventData->mPlaceholderFont )
943 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
946 mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
947 mImpl->mEventData->mPlaceholderFont->weightDefined = true;
949 mImpl->RequestRelayout();
953 bool Controller::IsPlaceholderTextFontWeightDefined() const
955 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
957 return mImpl->mEventData->mPlaceholderFont->weightDefined;
962 FontWeight Controller::GetPlaceholderTextFontWeight() const
964 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
966 return mImpl->mEventData->mPlaceholderFont->mFontDescription.weight;
969 return TextAbstraction::FontWeight::NORMAL;
972 void Controller::SetDefaultFontWidth( FontWidth width )
974 if( NULL == mImpl->mFontDefaults )
976 mImpl->mFontDefaults = new FontDefaults();
979 mImpl->mFontDefaults->mFontDescription.width = width;
980 mImpl->mFontDefaults->widthDefined = true;
982 if( mImpl->mEventData )
984 // Update the cursor position if it's in editing mode
985 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
987 mImpl->mEventData->mDecoratorUpdated = true;
988 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font width is updated.
992 // Clear the font-specific data
995 mImpl->RequestRelayout();
998 bool Controller::IsDefaultFontWidthDefined() const
1000 if( NULL != mImpl->mFontDefaults )
1002 return mImpl->mFontDefaults->widthDefined;
1008 FontWidth Controller::GetDefaultFontWidth() const
1010 if( NULL != mImpl->mFontDefaults )
1012 return mImpl->mFontDefaults->mFontDescription.width;
1015 return TextAbstraction::FontWidth::NORMAL;
1018 void Controller::SetPlaceholderTextFontWidth( FontWidth width )
1020 if( NULL != mImpl->mEventData )
1022 if( NULL == mImpl->mEventData->mPlaceholderFont )
1024 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
1027 mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
1028 mImpl->mEventData->mPlaceholderFont->widthDefined = true;
1030 mImpl->RequestRelayout();
1034 bool Controller::IsPlaceholderTextFontWidthDefined() const
1036 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1038 return mImpl->mEventData->mPlaceholderFont->widthDefined;
1043 FontWidth Controller::GetPlaceholderTextFontWidth() const
1045 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1047 return mImpl->mEventData->mPlaceholderFont->mFontDescription.width;
1050 return TextAbstraction::FontWidth::NORMAL;
1053 void Controller::SetDefaultFontSlant( FontSlant slant )
1055 if( NULL == mImpl->mFontDefaults )
1057 mImpl->mFontDefaults = new FontDefaults();
1060 mImpl->mFontDefaults->mFontDescription.slant = slant;
1061 mImpl->mFontDefaults->slantDefined = true;
1063 if( mImpl->mEventData )
1065 // Update the cursor position if it's in editing mode
1066 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
1068 mImpl->mEventData->mDecoratorUpdated = true;
1069 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font slant is updated.
1073 // Clear the font-specific data
1076 mImpl->RequestRelayout();
1079 bool Controller::IsDefaultFontSlantDefined() const
1081 if( NULL != mImpl->mFontDefaults )
1083 return mImpl->mFontDefaults->slantDefined;
1088 FontSlant Controller::GetDefaultFontSlant() const
1090 if( NULL != mImpl->mFontDefaults )
1092 return mImpl->mFontDefaults->mFontDescription.slant;
1095 return TextAbstraction::FontSlant::NORMAL;
1098 void Controller::SetPlaceholderTextFontSlant( FontSlant slant )
1100 if( NULL != mImpl->mEventData )
1102 if( NULL == mImpl->mEventData->mPlaceholderFont )
1104 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
1107 mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
1108 mImpl->mEventData->mPlaceholderFont->slantDefined = true;
1110 mImpl->RequestRelayout();
1114 bool Controller::IsPlaceholderTextFontSlantDefined() const
1116 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1118 return mImpl->mEventData->mPlaceholderFont->slantDefined;
1123 FontSlant Controller::GetPlaceholderTextFontSlant() const
1125 if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
1127 return mImpl->mEventData->mPlaceholderFont->mFontDescription.slant;
1130 return TextAbstraction::FontSlant::NORMAL;
1133 void Controller::SetDefaultFontSize( float fontSize, FontSizeType type )
1135 if( NULL == mImpl->mFontDefaults )
1137 mImpl->mFontDefaults = new FontDefaults();
1144 mImpl->mFontDefaults->mDefaultPointSize = fontSize;
1145 mImpl->mFontDefaults->sizeDefined = true;
1150 // Point size = Pixel size * 72.f / DPI
1151 unsigned int horizontalDpi = 0u;
1152 unsigned int verticalDpi = 0u;
1153 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1154 fontClient.GetDpi( horizontalDpi, verticalDpi );
1156 mImpl->mFontDefaults->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
1157 mImpl->mFontDefaults->sizeDefined = true;
1162 if( mImpl->mEventData )
1164 // Update the cursor position if it's in editing mode
1165 if( EventData::IsEditingState( mImpl->mEventData->mState ) )
1167 mImpl->mEventData->mDecoratorUpdated = true;
1168 mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font size is updated.
1172 // Clear the font-specific data
1175 mImpl->RequestRelayout();
1178 float Controller::GetDefaultFontSize( FontSizeType type ) const
1181 if( NULL != mImpl->mFontDefaults )
1187 value = mImpl->mFontDefaults->mDefaultPointSize;
1192 // Pixel size = Point size * DPI / 72.f
1193 unsigned int horizontalDpi = 0u;
1194 unsigned int verticalDpi = 0u;
1195 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1196 fontClient.GetDpi( horizontalDpi, verticalDpi );
1198 value = mImpl->mFontDefaults->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
1208 void Controller::SetPlaceholderTextFontSize( float fontSize, FontSizeType type )
1210 if( NULL != mImpl->mEventData )
1212 if( NULL == mImpl->mEventData->mPlaceholderFont )
1214 mImpl->mEventData->mPlaceholderFont = new FontDefaults();
1221 mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = fontSize;
1222 mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
1223 mImpl->mEventData->mIsPlaceholderPixelSize = false; // Font size flag
1228 // Point size = Pixel size * 72.f / DPI
1229 unsigned int horizontalDpi = 0u;
1230 unsigned int verticalDpi = 0u;
1231 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1232 fontClient.GetDpi( horizontalDpi, verticalDpi );
1234 mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
1235 mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
1236 mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag
1241 mImpl->RequestRelayout();
1245 float Controller::GetPlaceholderTextFontSize( FontSizeType type ) const
1248 if( NULL != mImpl->mEventData )
1254 if( NULL != mImpl->mEventData->mPlaceholderFont )
1256 value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize;
1260 // If the placeholder text font size is not set, then return the default font size.
1261 value = GetDefaultFontSize( POINT_SIZE );
1267 if( NULL != mImpl->mEventData->mPlaceholderFont )
1269 // Pixel size = Point size * DPI / 72.f
1270 unsigned int horizontalDpi = 0u;
1271 unsigned int verticalDpi = 0u;
1272 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1273 fontClient.GetDpi( horizontalDpi, verticalDpi );
1275 value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
1279 // If the placeholder text font size is not set, then return the default font size.
1280 value = GetDefaultFontSize( PIXEL_SIZE );
1291 void Controller::SetDefaultColor( const Vector4& color )
1293 mImpl->mTextColor = color;
1295 if( !mImpl->IsShowingPlaceholderText() )
1297 mImpl->mModel->mVisualModel->SetTextColor( color );
1299 mImpl->mModel->mLogicalModel->mColorRuns.Clear();
1301 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | COLOR );
1303 mImpl->RequestRelayout();
1307 const Vector4& Controller::GetDefaultColor() const
1309 return mImpl->mTextColor;
1312 void Controller::SetPlaceholderTextColor( const Vector4& textColor )
1314 if( NULL != mImpl->mEventData )
1316 mImpl->mEventData->mPlaceholderTextColor = textColor;
1319 if( mImpl->IsShowingPlaceholderText() )
1321 mImpl->mModel->mVisualModel->SetTextColor( textColor );
1322 mImpl->RequestRelayout();
1326 const Vector4& Controller::GetPlaceholderTextColor() const
1328 if( NULL != mImpl->mEventData )
1330 return mImpl->mEventData->mPlaceholderTextColor;
1333 return Color::BLACK;
1336 void Controller::SetShadowOffset( const Vector2& shadowOffset )
1338 mImpl->mModel->mVisualModel->SetShadowOffset( shadowOffset );
1340 mImpl->RequestRelayout();
1343 const Vector2& Controller::GetShadowOffset() const
1345 return mImpl->mModel->mVisualModel->GetShadowOffset();
1348 void Controller::SetShadowColor( const Vector4& shadowColor )
1350 mImpl->mModel->mVisualModel->SetShadowColor( shadowColor );
1352 mImpl->RequestRelayout();
1355 const Vector4& Controller::GetShadowColor() const
1357 return mImpl->mModel->mVisualModel->GetShadowColor();
1360 void Controller::SetShadowBlurRadius( const float& shadowBlurRadius )
1362 if ( fabsf( GetShadowBlurRadius() - shadowBlurRadius ) > Math::MACHINE_EPSILON_1 )
1364 mImpl->mModel->mVisualModel->SetShadowBlurRadius( shadowBlurRadius );
1366 mImpl->RequestRelayout();
1370 const float& Controller::GetShadowBlurRadius() const
1372 return mImpl->mModel->mVisualModel->GetShadowBlurRadius();
1375 void Controller::SetUnderlineColor( const Vector4& color )
1377 mImpl->mModel->mVisualModel->SetUnderlineColor( color );
1379 mImpl->RequestRelayout();
1382 const Vector4& Controller::GetUnderlineColor() const
1384 return mImpl->mModel->mVisualModel->GetUnderlineColor();
1387 void Controller::SetUnderlineEnabled( bool enabled )
1389 mImpl->mModel->mVisualModel->SetUnderlineEnabled( enabled );
1391 mImpl->RequestRelayout();
1394 bool Controller::IsUnderlineEnabled() const
1396 return mImpl->mModel->mVisualModel->IsUnderlineEnabled();
1399 void Controller::SetUnderlineHeight( float height )
1401 mImpl->mModel->mVisualModel->SetUnderlineHeight( height );
1403 mImpl->RequestRelayout();
1406 float Controller::GetUnderlineHeight() const
1408 return mImpl->mModel->mVisualModel->GetUnderlineHeight();
1411 void Controller::SetOutlineColor( const Vector4& color )
1413 mImpl->mModel->mVisualModel->SetOutlineColor( color );
1415 mImpl->RequestRelayout();
1418 const Vector4& Controller::GetOutlineColor() const
1420 return mImpl->mModel->mVisualModel->GetOutlineColor();
1423 void Controller::SetOutlineWidth( uint16_t width )
1425 mImpl->mModel->mVisualModel->SetOutlineWidth( width );
1427 mImpl->RequestRelayout();
1430 uint16_t Controller::GetOutlineWidth() const
1432 return mImpl->mModel->mVisualModel->GetOutlineWidth();
1435 void Controller::SetBackgroundColor( const Vector4& color )
1437 mImpl->mModel->mVisualModel->SetBackgroundColor( color );
1439 mImpl->RequestRelayout();
1442 const Vector4& Controller::GetBackgroundColor() const
1444 return mImpl->mModel->mVisualModel->GetBackgroundColor();
1447 void Controller::SetBackgroundEnabled( bool enabled )
1449 mImpl->mModel->mVisualModel->SetBackgroundEnabled( enabled );
1451 mImpl->RequestRelayout();
1454 bool Controller::IsBackgroundEnabled() const
1456 return mImpl->mModel->mVisualModel->IsBackgroundEnabled();
1459 void Controller::SetDefaultEmbossProperties( const std::string& embossProperties )
1461 if( NULL == mImpl->mEmbossDefaults )
1463 mImpl->mEmbossDefaults = new EmbossDefaults();
1466 mImpl->mEmbossDefaults->properties = embossProperties;
1469 const std::string& Controller::GetDefaultEmbossProperties() const
1471 if( NULL != mImpl->mEmbossDefaults )
1473 return mImpl->mEmbossDefaults->properties;
1476 return EMPTY_STRING;
1479 void Controller::SetDefaultOutlineProperties( const std::string& outlineProperties )
1481 if( NULL == mImpl->mOutlineDefaults )
1483 mImpl->mOutlineDefaults = new OutlineDefaults();
1486 mImpl->mOutlineDefaults->properties = outlineProperties;
1489 const std::string& Controller::GetDefaultOutlineProperties() const
1491 if( NULL != mImpl->mOutlineDefaults )
1493 return mImpl->mOutlineDefaults->properties;
1496 return EMPTY_STRING;
1499 bool Controller::SetDefaultLineSpacing( float lineSpacing )
1501 if( std::fabs( lineSpacing - mImpl->mLayoutEngine.GetDefaultLineSpacing() ) > Math::MACHINE_EPSILON_1000 )
1503 mImpl->mLayoutEngine.SetDefaultLineSpacing(lineSpacing);
1504 mImpl->mRecalculateNaturalSize = true;
1510 float Controller::GetDefaultLineSpacing() const
1512 return mImpl->mLayoutEngine.GetDefaultLineSpacing();
1515 bool Controller::SetDefaultLineSize( float lineSize )
1517 if( std::fabs( lineSize - mImpl->mLayoutEngine.GetDefaultLineSize() ) > Math::MACHINE_EPSILON_1000 )
1519 mImpl->mLayoutEngine.SetDefaultLineSize(lineSize);
1520 mImpl->mRecalculateNaturalSize = true;
1526 float Controller::GetDefaultLineSize() const
1528 return mImpl->mLayoutEngine.GetDefaultLineSize();
1531 void Controller::SetInputColor( const Vector4& color )
1533 if( NULL != mImpl->mEventData )
1535 mImpl->mEventData->mInputStyle.textColor = color;
1536 mImpl->mEventData->mInputStyle.isDefaultColor = false;
1538 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1540 const bool handlesCrossed = mImpl->mEventData->mLeftSelectionPosition > mImpl->mEventData->mRightSelectionPosition;
1542 // Get start and end position of selection
1543 const CharacterIndex startOfSelectedText = handlesCrossed ? mImpl->mEventData->mRightSelectionPosition : mImpl->mEventData->mLeftSelectionPosition;
1544 const Length lengthOfSelectedText = ( handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition ) - startOfSelectedText;
1546 // Add the color run.
1547 const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
1548 mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
1550 ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
1551 colorRun.color = color;
1552 colorRun.characterRun.characterIndex = startOfSelectedText;
1553 colorRun.characterRun.numberOfCharacters = lengthOfSelectedText;
1555 // Request to relayout.
1556 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | COLOR );
1557 mImpl->RequestRelayout();
1559 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1560 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1561 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1566 const Vector4& Controller::GetInputColor() const
1568 if( NULL != mImpl->mEventData )
1570 return mImpl->mEventData->mInputStyle.textColor;
1573 // Return the default text's color if there is no EventData.
1574 return mImpl->mTextColor;
1578 void Controller::SetInputFontFamily( const std::string& fontFamily )
1580 if( NULL != mImpl->mEventData )
1582 mImpl->mEventData->mInputStyle.familyName = fontFamily;
1583 mImpl->mEventData->mInputStyle.isFamilyDefined = true;
1585 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1587 CharacterIndex startOfSelectedText = 0u;
1588 Length lengthOfSelectedText = 0u;
1590 if( EventData::SELECTING == mImpl->mEventData->mState )
1592 // Update a font description run for the selecting state.
1593 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1594 mImpl->mModel->mLogicalModel,
1595 startOfSelectedText,
1596 lengthOfSelectedText );
1598 fontDescriptionRun.familyLength = fontFamily.size();
1599 fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
1600 memcpy( fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength );
1601 fontDescriptionRun.familyDefined = true;
1603 // The memory allocated for the font family name is freed when the font description is removed from the logical model.
1605 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1606 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1607 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1611 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1612 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1613 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1616 // Request to relayout.
1617 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1622 UPDATE_LAYOUT_SIZE |
1625 mImpl->mRecalculateNaturalSize = true;
1626 mImpl->RequestRelayout();
1628 // As the font changes, recalculate the handle positions is needed.
1629 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1630 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1631 mImpl->mEventData->mUpdateHighlightBox = true;
1632 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1637 const std::string& Controller::GetInputFontFamily() const
1639 if( NULL != mImpl->mEventData )
1641 return mImpl->mEventData->mInputStyle.familyName;
1644 // Return the default font's family if there is no EventData.
1645 return GetDefaultFontFamily();
1648 void Controller::SetInputFontWeight( FontWeight weight )
1650 if( NULL != mImpl->mEventData )
1652 mImpl->mEventData->mInputStyle.weight = weight;
1653 mImpl->mEventData->mInputStyle.isWeightDefined = true;
1655 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1657 CharacterIndex startOfSelectedText = 0u;
1658 Length lengthOfSelectedText = 0u;
1660 if( EventData::SELECTING == mImpl->mEventData->mState )
1662 // Update a font description run for the selecting state.
1663 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1664 mImpl->mModel->mLogicalModel,
1665 startOfSelectedText,
1666 lengthOfSelectedText );
1668 fontDescriptionRun.weight = weight;
1669 fontDescriptionRun.weightDefined = true;
1671 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1672 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1673 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1677 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1678 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1679 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1682 // Request to relayout.
1683 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1688 UPDATE_LAYOUT_SIZE |
1691 mImpl->mRecalculateNaturalSize = true;
1692 mImpl->RequestRelayout();
1694 // As the font might change, recalculate the handle positions is needed.
1695 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1696 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1697 mImpl->mEventData->mUpdateHighlightBox = true;
1698 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1703 bool Controller::IsInputFontWeightDefined() const
1705 bool defined = false;
1707 if( NULL != mImpl->mEventData )
1709 defined = mImpl->mEventData->mInputStyle.isWeightDefined;
1715 FontWeight Controller::GetInputFontWeight() const
1717 if( NULL != mImpl->mEventData )
1719 return mImpl->mEventData->mInputStyle.weight;
1722 return GetDefaultFontWeight();
1725 void Controller::SetInputFontWidth( FontWidth width )
1727 if( NULL != mImpl->mEventData )
1729 mImpl->mEventData->mInputStyle.width = width;
1730 mImpl->mEventData->mInputStyle.isWidthDefined = true;
1732 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1734 CharacterIndex startOfSelectedText = 0u;
1735 Length lengthOfSelectedText = 0u;
1737 if( EventData::SELECTING == mImpl->mEventData->mState )
1739 // Update a font description run for the selecting state.
1740 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1741 mImpl->mModel->mLogicalModel,
1742 startOfSelectedText,
1743 lengthOfSelectedText );
1745 fontDescriptionRun.width = width;
1746 fontDescriptionRun.widthDefined = true;
1748 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1749 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1750 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1754 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1755 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1756 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1759 // Request to relayout.
1760 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1765 UPDATE_LAYOUT_SIZE |
1768 mImpl->mRecalculateNaturalSize = true;
1769 mImpl->RequestRelayout();
1771 // As the font might change, recalculate the handle positions is needed.
1772 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1773 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1774 mImpl->mEventData->mUpdateHighlightBox = true;
1775 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1780 bool Controller::IsInputFontWidthDefined() const
1782 bool defined = false;
1784 if( NULL != mImpl->mEventData )
1786 defined = mImpl->mEventData->mInputStyle.isWidthDefined;
1792 FontWidth Controller::GetInputFontWidth() const
1794 if( NULL != mImpl->mEventData )
1796 return mImpl->mEventData->mInputStyle.width;
1799 return GetDefaultFontWidth();
1802 void Controller::SetInputFontSlant( FontSlant slant )
1804 if( NULL != mImpl->mEventData )
1806 mImpl->mEventData->mInputStyle.slant = slant;
1807 mImpl->mEventData->mInputStyle.isSlantDefined = true;
1809 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1811 CharacterIndex startOfSelectedText = 0u;
1812 Length lengthOfSelectedText = 0u;
1814 if( EventData::SELECTING == mImpl->mEventData->mState )
1816 // Update a font description run for the selecting state.
1817 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1818 mImpl->mModel->mLogicalModel,
1819 startOfSelectedText,
1820 lengthOfSelectedText );
1822 fontDescriptionRun.slant = slant;
1823 fontDescriptionRun.slantDefined = true;
1825 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1826 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1827 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1831 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1832 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1833 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1836 // Request to relayout.
1837 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1842 UPDATE_LAYOUT_SIZE |
1845 mImpl->mRecalculateNaturalSize = true;
1846 mImpl->RequestRelayout();
1848 // As the font might change, recalculate the handle positions is needed.
1849 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1850 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1851 mImpl->mEventData->mUpdateHighlightBox = true;
1852 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1857 bool Controller::IsInputFontSlantDefined() const
1859 bool defined = false;
1861 if( NULL != mImpl->mEventData )
1863 defined = mImpl->mEventData->mInputStyle.isSlantDefined;
1869 FontSlant Controller::GetInputFontSlant() const
1871 if( NULL != mImpl->mEventData )
1873 return mImpl->mEventData->mInputStyle.slant;
1876 return GetDefaultFontSlant();
1879 void Controller::SetInputFontPointSize( float size )
1881 if( NULL != mImpl->mEventData )
1883 mImpl->mEventData->mInputStyle.size = size;
1884 mImpl->mEventData->mInputStyle.isSizeDefined = true;
1886 if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
1888 CharacterIndex startOfSelectedText = 0u;
1889 Length lengthOfSelectedText = 0u;
1891 if( EventData::SELECTING == mImpl->mEventData->mState )
1893 // Update a font description run for the selecting state.
1894 FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
1895 mImpl->mModel->mLogicalModel,
1896 startOfSelectedText,
1897 lengthOfSelectedText );
1899 fontDescriptionRun.size = static_cast<PointSize26Dot6>( size * 64.f );
1900 fontDescriptionRun.sizeDefined = true;
1902 mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
1903 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
1904 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
1908 mImpl->mTextUpdateInfo.mCharacterIndex = 0;
1909 mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
1910 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
1913 // Request to relayout.
1914 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
1919 UPDATE_LAYOUT_SIZE |
1922 mImpl->mRecalculateNaturalSize = true;
1923 mImpl->RequestRelayout();
1925 // As the font might change, recalculate the handle positions is needed.
1926 mImpl->mEventData->mUpdateLeftSelectionPosition = true;
1927 mImpl->mEventData->mUpdateRightSelectionPosition = true;
1928 mImpl->mEventData->mUpdateHighlightBox = true;
1929 mImpl->mEventData->mScrollAfterUpdatePosition = true;
1934 float Controller::GetInputFontPointSize() const
1936 if( NULL != mImpl->mEventData )
1938 return mImpl->mEventData->mInputStyle.size;
1941 // Return the default font's point size if there is no EventData.
1942 return GetDefaultFontSize( Text::Controller::POINT_SIZE );
1945 void Controller::SetInputLineSpacing( float lineSpacing )
1947 if( NULL != mImpl->mEventData )
1949 mImpl->mEventData->mInputStyle.lineSpacing = lineSpacing;
1950 mImpl->mEventData->mInputStyle.isLineSpacingDefined = true;
1954 float Controller::GetInputLineSpacing() const
1956 if( NULL != mImpl->mEventData )
1958 return mImpl->mEventData->mInputStyle.lineSpacing;
1964 void Controller::SetInputShadowProperties( const std::string& shadowProperties )
1966 if( NULL != mImpl->mEventData )
1968 mImpl->mEventData->mInputStyle.shadowProperties = shadowProperties;
1972 const std::string& Controller::GetInputShadowProperties() const
1974 if( NULL != mImpl->mEventData )
1976 return mImpl->mEventData->mInputStyle.shadowProperties;
1979 return EMPTY_STRING;
1982 void Controller::SetInputUnderlineProperties( const std::string& underlineProperties )
1984 if( NULL != mImpl->mEventData )
1986 mImpl->mEventData->mInputStyle.underlineProperties = underlineProperties;
1990 const std::string& Controller::GetInputUnderlineProperties() const
1992 if( NULL != mImpl->mEventData )
1994 return mImpl->mEventData->mInputStyle.underlineProperties;
1997 return EMPTY_STRING;
2000 void Controller::SetInputEmbossProperties( const std::string& embossProperties )
2002 if( NULL != mImpl->mEventData )
2004 mImpl->mEventData->mInputStyle.embossProperties = embossProperties;
2008 const std::string& Controller::GetInputEmbossProperties() const
2010 if( NULL != mImpl->mEventData )
2012 return mImpl->mEventData->mInputStyle.embossProperties;
2015 return GetDefaultEmbossProperties();
2018 void Controller::SetInputOutlineProperties( const std::string& outlineProperties )
2020 if( NULL != mImpl->mEventData )
2022 mImpl->mEventData->mInputStyle.outlineProperties = outlineProperties;
2026 const std::string& Controller::GetInputOutlineProperties() const
2028 if( NULL != mImpl->mEventData )
2030 return mImpl->mEventData->mInputStyle.outlineProperties;
2033 return GetDefaultOutlineProperties();
2036 void Controller::SetInputModePassword( bool passwordInput )
2038 if( NULL != mImpl->mEventData )
2040 mImpl->mEventData->mPasswordInput = passwordInput;
2044 bool Controller::IsInputModePassword()
2046 if( NULL != mImpl->mEventData )
2048 return mImpl->mEventData->mPasswordInput;
2053 void Controller::SetNoTextDoubleTapAction( NoTextTap::Action action )
2055 if( NULL != mImpl->mEventData )
2057 mImpl->mEventData->mDoubleTapAction = action;
2061 Controller::NoTextTap::Action Controller::GetNoTextDoubleTapAction() const
2063 NoTextTap::Action action = NoTextTap::NO_ACTION;
2065 if( NULL != mImpl->mEventData )
2067 action = mImpl->mEventData->mDoubleTapAction;
2073 void Controller::SetNoTextLongPressAction( NoTextTap::Action action )
2075 if( NULL != mImpl->mEventData )
2077 mImpl->mEventData->mLongPressAction = action;
2081 Controller::NoTextTap::Action Controller::GetNoTextLongPressAction() const
2083 NoTextTap::Action action = NoTextTap::NO_ACTION;
2085 if( NULL != mImpl->mEventData )
2087 action = mImpl->mEventData->mLongPressAction;
2093 bool Controller::IsUnderlineSetByString()
2095 return mImpl->mUnderlineSetByString;
2098 void Controller::UnderlineSetByString( bool setByString )
2100 mImpl->mUnderlineSetByString = setByString;
2103 bool Controller::IsShadowSetByString()
2105 return mImpl->mShadowSetByString;
2108 void Controller::ShadowSetByString( bool setByString )
2110 mImpl->mShadowSetByString = setByString;
2113 bool Controller::IsOutlineSetByString()
2115 return mImpl->mOutlineSetByString;
2118 void Controller::OutlineSetByString( bool setByString )
2120 mImpl->mOutlineSetByString = setByString;
2123 bool Controller::IsFontStyleSetByString()
2125 return mImpl->mFontStyleSetByString;
2128 void Controller::FontStyleSetByString( bool setByString )
2130 mImpl->mFontStyleSetByString = setByString;
2133 // public : Queries & retrieves.
2135 Layout::Engine& Controller::GetLayoutEngine()
2137 return mImpl->mLayoutEngine;
2140 View& Controller::GetView()
2142 return mImpl->mView;
2145 Vector3 Controller::GetNaturalSize()
2147 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
2148 Vector3 naturalSize;
2150 // Make sure the model is up-to-date before layouting
2151 ProcessModifyEvents();
2153 if( mImpl->mRecalculateNaturalSize )
2155 // Operations that can be done only once until the text changes.
2156 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2162 GET_GLYPH_METRICS );
2164 // Set the update info to relayout the whole text.
2165 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2166 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2168 // Make sure the model is up-to-date before layouting
2169 mImpl->UpdateModel( onlyOnceOperations );
2171 // Layout the text for the new width.
2172 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | LAYOUT | REORDER );
2174 // Store the actual control's size to restore later.
2175 const Size actualControlSize = mImpl->mModel->mVisualModel->mControlSize;
2177 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
2178 static_cast<OperationsMask>( onlyOnceOperations |
2180 naturalSize.GetVectorXY() );
2182 // Do not do again the only once operations.
2183 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
2185 // Do the size related operations again.
2186 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
2189 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
2191 // Stores the natural size to avoid recalculate it again
2192 // unless the text/style changes.
2193 mImpl->mModel->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
2195 mImpl->mRecalculateNaturalSize = false;
2197 // Clear the update info. This info will be set the next time the text is updated.
2198 mImpl->mTextUpdateInfo.Clear();
2199 mImpl->mTextUpdateInfo.mClearAll = true;
2201 // Restore the actual control's size.
2202 mImpl->mModel->mVisualModel->mControlSize = actualControlSize;
2204 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
2208 naturalSize = mImpl->mModel->mVisualModel->GetNaturalSize();
2210 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
2213 naturalSize.x = ConvertToEven( naturalSize.x );
2214 naturalSize.y = ConvertToEven( naturalSize.y );
2219 bool Controller::CheckForTextFit( float pointSize, Size& layoutSize )
2222 mImpl->mFontDefaults->mFitPointSize = pointSize;
2223 mImpl->mFontDefaults->sizeDefined = true;
2226 // Operations that can be done only once until the text changes.
2227 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2233 GET_GLYPH_METRICS );
2235 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2236 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2238 // Make sure the model is up-to-date before layouting
2239 mImpl->UpdateModel( onlyOnceOperations );
2241 DoRelayout( Size( layoutSize.width, MAX_FLOAT ),
2242 static_cast<OperationsMask>( onlyOnceOperations | LAYOUT),
2245 // Clear the update info. This info will be set the next time the text is updated.
2246 mImpl->mTextUpdateInfo.Clear();
2247 mImpl->mTextUpdateInfo.mClearAll = true;
2249 if( textSize.width > layoutSize.width || textSize.height > layoutSize.height )
2256 void Controller::FitPointSizeforLayout( Size layoutSize )
2258 const OperationsMask operations = mImpl->mOperationsPending;
2259 if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) || mImpl->mTextFitContentSize != layoutSize )
2261 bool actualellipsis = mImpl->mModel->mElideEnabled;
2262 float minPointSize = mImpl->mTextFitMinSize;
2263 float maxPointSize = mImpl->mTextFitMaxSize;
2264 float pointInterval = mImpl->mTextFitStepSize;
2266 mImpl->mModel->mElideEnabled = false;
2267 Vector<float> pointSizeArray;
2270 if( pointInterval < 1.f )
2272 mImpl->mTextFitStepSize = pointInterval = 1.0f;
2275 pointSizeArray.Reserve( static_cast< unsigned int >( ceil( ( maxPointSize - minPointSize ) / pointInterval ) ) );
2277 for( float i = minPointSize; i < maxPointSize; i += pointInterval )
2279 pointSizeArray.PushBack( i );
2282 pointSizeArray.PushBack( maxPointSize );
2284 int bestSizeIndex = 0;
2285 int min = bestSizeIndex + 1;
2286 int max = pointSizeArray.Size() - 1;
2289 int destI = ( min + max ) / 2;
2291 if( CheckForTextFit( pointSizeArray[destI], layoutSize ) )
2293 bestSizeIndex = min;
2299 bestSizeIndex = max;
2303 mImpl->mModel->mElideEnabled = actualellipsis;
2304 mImpl->mFontDefaults->mFitPointSize = pointSizeArray[bestSizeIndex];
2305 mImpl->mFontDefaults->sizeDefined = true;
2310 float Controller::GetHeightForWidth( float width )
2312 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", this, width );
2313 // Make sure the model is up-to-date before layouting
2314 ProcessModifyEvents();
2317 if( fabsf( width - mImpl->mModel->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 ||
2318 mImpl->mTextUpdateInfo.mFullRelayoutNeeded ||
2319 mImpl->mTextUpdateInfo.mClearAll )
2321 // Operations that can be done only once until the text changes.
2322 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2328 GET_GLYPH_METRICS );
2330 // Set the update info to relayout the whole text.
2331 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2332 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2334 // Make sure the model is up-to-date before layouting
2335 mImpl->UpdateModel( onlyOnceOperations );
2338 // Layout the text for the new width.
2339 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | LAYOUT );
2341 // Store the actual control's width.
2342 const float actualControlWidth = mImpl->mModel->mVisualModel->mControlSize.width;
2344 DoRelayout( Size( width, MAX_FLOAT ),
2345 static_cast<OperationsMask>( onlyOnceOperations |
2349 // Do not do again the only once operations.
2350 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
2352 // Do the size related operations again.
2353 const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
2357 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | sizeOperations );
2359 // Clear the update info. This info will be set the next time the text is updated.
2360 mImpl->mTextUpdateInfo.Clear();
2361 mImpl->mTextUpdateInfo.mClearAll = true;
2363 // Restore the actual control's width.
2364 mImpl->mModel->mVisualModel->mControlSize.width = actualControlWidth;
2366 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
2370 layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
2371 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
2374 return layoutSize.height;
2377 int Controller::GetLineCount( float width )
2379 GetHeightForWidth( width );
2380 int numberofLines = mImpl->mModel->GetNumberOfLines();
2381 return numberofLines;
2384 const ModelInterface* const Controller::GetTextModel() const
2386 return mImpl->mModel.Get();
2389 float Controller::GetScrollAmountByUserInput()
2391 float scrollAmount = 0.0f;
2393 if (NULL != mImpl->mEventData && mImpl->mEventData->mCheckScrollAmount)
2395 scrollAmount = mImpl->mModel->mScrollPosition.y - mImpl->mModel->mScrollPositionLast.y;
2396 mImpl->mEventData->mCheckScrollAmount = false;
2398 return scrollAmount;
2401 bool Controller::GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight )
2403 const Vector2& layout = mImpl->mModel->mVisualModel->GetLayoutSize();
2406 controlHeight = mImpl->mModel->mVisualModel->mControlSize.height;
2407 layoutHeight = layout.height;
2408 scrollPosition = mImpl->mModel->mScrollPosition.y;
2409 isScrolled = !Equals( mImpl->mModel->mScrollPosition.y, mImpl->mModel->mScrollPositionLast.y, Math::MACHINE_EPSILON_1 );
2413 void Controller::SetHiddenInputOption(const Property::Map& options )
2415 if( NULL == mImpl->mHiddenInput )
2417 mImpl->mHiddenInput = new HiddenText( this );
2419 mImpl->mHiddenInput->SetProperties(options);
2422 void Controller::GetHiddenInputOption(Property::Map& options )
2424 if( NULL != mImpl->mHiddenInput )
2426 mImpl->mHiddenInput->GetProperties(options);
2430 void Controller::SetPlaceholderProperty( const Property::Map& map )
2432 const Property::Map::SizeType count = map.Count();
2434 for( Property::Map::SizeType position = 0; position < count; ++position )
2436 KeyValuePair keyValue = map.GetKeyValue( position );
2437 Property::Key& key = keyValue.first;
2438 Property::Value& value = keyValue.second;
2440 if( key == Toolkit::Text::PlaceHolder::Property::TEXT || key == PLACEHOLDER_TEXT )
2442 std::string text = "";
2444 SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
2446 else if( key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED )
2448 std::string text = "";
2450 SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
2452 else if( key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR )
2455 value.Get( textColor );
2456 if( GetPlaceholderTextColor() != textColor )
2458 SetPlaceholderTextColor( textColor );
2461 else if( key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY )
2463 std::string fontFamily = "";
2464 value.Get( fontFamily );
2465 SetPlaceholderFontFamily( fontFamily );
2467 else if( key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE )
2469 SetFontStyleProperty( this, value, Text::FontStyle::PLACEHOLDER );
2471 else if( key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE )
2474 value.Get( pointSize );
2475 if( !Equals( GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
2477 SetPlaceholderTextFontSize( pointSize, Text::Controller::POINT_SIZE );
2480 else if( key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE )
2483 value.Get( pixelSize );
2484 if( !Equals( GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
2486 SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
2489 else if( key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS )
2492 value.Get( ellipsis );
2493 SetPlaceholderTextElideEnabled( ellipsis );
2498 void Controller::GetPlaceholderProperty( Property::Map& map )
2500 if( NULL != mImpl->mEventData )
2502 if( !mImpl->mEventData->mPlaceholderTextActive.empty() )
2504 map[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive;
2506 if( !mImpl->mEventData->mPlaceholderTextInactive.empty() )
2508 map[ Text::PlaceHolder::Property::TEXT ] = mImpl->mEventData->mPlaceholderTextInactive;
2511 map[ Text::PlaceHolder::Property::COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
2512 map[ Text::PlaceHolder::Property::FONT_FAMILY ] = GetPlaceholderFontFamily();
2514 Property::Value fontStyleMapGet;
2515 GetFontStyleProperty( this, fontStyleMapGet, Text::FontStyle::PLACEHOLDER );
2516 map[ Text::PlaceHolder::Property::FONT_STYLE ] = fontStyleMapGet;
2518 // Choose font size : POINT_SIZE or PIXEL_SIZE
2519 if( !mImpl->mEventData->mIsPlaceholderPixelSize )
2521 map[ Text::PlaceHolder::Property::POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE );
2525 map[ Text::PlaceHolder::Property::PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE );
2528 if( mImpl->mEventData->mPlaceholderEllipsisFlag )
2530 map[ Text::PlaceHolder::Property::ELLIPSIS ] = IsPlaceholderTextElideEnabled();
2535 Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection()
2537 // Make sure the model is up-to-date before layouting
2538 ProcessModifyEvents();
2540 if ( mImpl->mUpdateTextDirection )
2542 // Operations that can be done only once until the text changes.
2543 const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
2549 GET_GLYPH_METRICS );
2551 // Set the update info to relayout the whole text.
2552 mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
2553 mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
2555 // Make sure the model is up-to-date before layouting
2556 mImpl->UpdateModel( onlyOnceOperations );
2558 Vector3 naturalSize;
2559 DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
2560 static_cast<OperationsMask>( onlyOnceOperations |
2561 LAYOUT | REORDER | UPDATE_DIRECTION ),
2562 naturalSize.GetVectorXY() );
2564 // Do not do again the only once operations.
2565 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending & ~onlyOnceOperations );
2567 // Clear the update info. This info will be set the next time the text is updated.
2568 mImpl->mTextUpdateInfo.Clear();
2570 // FullRelayoutNeeded should be true because DoRelayout is MAX_FLOAT, MAX_FLOAT.
2571 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
2573 mImpl->mUpdateTextDirection = false;
2576 return mImpl->mIsTextDirectionRTL ? Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT : Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
2579 Toolkit::DevelText::VerticalLineAlignment::Type Controller::GetVerticalLineAlignment() const
2581 return mImpl->mModel->GetVerticalLineAlignment();
2584 void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment )
2586 mImpl->mModel->mVerticalLineAlignment = alignment;
2589 // public : Relayout.
2591 Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection )
2593 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f, autoScroll[%s]\n", this, size.width, size.height, mImpl->mIsAutoScrollEnabled ?"true":"false" );
2595 UpdateTextType updateTextType = NONE_UPDATED;
2597 if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
2599 if( 0u != mImpl->mModel->mVisualModel->mGlyphPositions.Count() )
2601 mImpl->mModel->mVisualModel->mGlyphPositions.Clear();
2602 updateTextType = MODEL_UPDATED;
2605 // Clear the update info. This info will be set the next time the text is updated.
2606 mImpl->mTextUpdateInfo.Clear();
2608 // Not worth to relayout if width or height is equal to zero.
2609 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
2611 return updateTextType;
2614 // Whether a new size has been set.
2615 const bool newSize = ( size != mImpl->mModel->mVisualModel->mControlSize );
2619 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mModel->mVisualModel->mControlSize.width, mImpl->mModel->mVisualModel->mControlSize.height );
2621 if( ( 0 == mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd ) &&
2622 ( 0 == mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) &&
2623 ( ( mImpl->mModel->mVisualModel->mControlSize.width < Math::MACHINE_EPSILON_1000 ) || ( mImpl->mModel->mVisualModel->mControlSize.height < Math::MACHINE_EPSILON_1000 ) ) )
2625 mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
2628 // Layout operations that need to be done if the size changes.
2629 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2632 UPDATE_LAYOUT_SIZE |
2634 // Set the update info to relayout the whole text.
2635 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
2636 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
2638 // Store the size used to layout the text.
2639 mImpl->mModel->mVisualModel->mControlSize = size;
2642 // Whether there are modify events.
2643 if( 0u != mImpl->mModifyEvents.Count() )
2645 // Style operations that need to be done if the text is modified.
2646 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2650 // Set the update info to elide the text.
2651 if( mImpl->mModel->mElideEnabled ||
2652 ( ( NULL != mImpl->mEventData ) && mImpl->mEventData->mIsPlaceholderElideEnabled ) )
2654 // Update Text layout for applying elided
2655 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2658 UPDATE_LAYOUT_SIZE |
2660 mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
2661 mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
2664 if( mImpl->mModel->mMatchSystemLanguageDirection && mImpl->mLayoutDirection != layoutDirection )
2666 // Clear the update info. This info will be set the next time the text is updated.
2667 mImpl->mTextUpdateInfo.mClearAll = true;
2668 // Apply modifications to the model
2669 // Shape the text again is needed because characters like '()[]{}' have to be mirrored and the glyphs generated again.
2670 mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
2677 mImpl->mLayoutDirection = layoutDirection;
2680 // Make sure the model is up-to-date before layouting.
2681 ProcessModifyEvents();
2682 bool updated = mImpl->UpdateModel( mImpl->mOperationsPending );
2686 updated = DoRelayout( size,
2687 mImpl->mOperationsPending,
2688 layoutSize ) || updated;
2693 updateTextType = MODEL_UPDATED;
2696 // Do not re-do any operation until something changes.
2697 mImpl->mOperationsPending = NO_OPERATION;
2698 mImpl->mModel->mScrollPositionLast = mImpl->mModel->mScrollPosition;
2700 // Whether the text control is editable
2701 const bool isEditable = NULL != mImpl->mEventData;
2703 // Keep the current offset as it will be used to update the decorator's positions (if the size changes).
2705 if( newSize && isEditable )
2707 offset = mImpl->mModel->mScrollPosition;
2710 if( !isEditable || !IsMultiLineEnabled() )
2712 // After doing the text layout, the vertical offset to place the actor in the desired position can be calculated.
2713 CalculateVerticalOffset( size );
2720 // If there is a new size, the scroll position needs to be clamped.
2721 mImpl->ClampHorizontalScroll( layoutSize );
2723 // Update the decorator's positions is needed if there is a new size.
2724 mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mModel->mScrollPosition - offset );
2727 // Move the cursor, grab handle etc.
2728 if( mImpl->ProcessInputEvents() )
2730 updateTextType = static_cast<UpdateTextType>( updateTextType | DECORATOR_UPDATED );
2734 // Clear the update info. This info will be set the next time the text is updated.
2735 mImpl->mTextUpdateInfo.Clear();
2736 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
2738 return updateTextType;
2741 void Controller::RequestRelayout()
2743 mImpl->RequestRelayout();
2746 // public : Input style change signals.
2748 bool Controller::IsInputStyleChangedSignalsQueueEmpty()
2750 return ( NULL == mImpl->mEventData ) || ( 0u == mImpl->mEventData->mInputStyleChangedQueue.Count() );
2753 void Controller::ProcessInputStyleChangedSignals()
2755 if( NULL == mImpl->mEventData )
2761 for( Vector<InputStyle::Mask>::ConstIterator it = mImpl->mEventData->mInputStyleChangedQueue.Begin(),
2762 endIt = mImpl->mEventData->mInputStyleChangedQueue.End();
2766 const InputStyle::Mask mask = *it;
2768 if( NULL != mImpl->mEditableControlInterface )
2770 // Emit the input style changed signal.
2771 mImpl->mEditableControlInterface->InputStyleChanged( mask );
2775 mImpl->mEventData->mInputStyleChangedQueue.Clear();
2778 // public : Text-input Event Queuing.
2780 void Controller::KeyboardFocusGainEvent()
2782 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
2784 if( NULL != mImpl->mEventData )
2786 if( ( EventData::INACTIVE == mImpl->mEventData->mState ) ||
2787 ( EventData::INTERRUPTED == mImpl->mEventData->mState ) )
2789 mImpl->ChangeState( EventData::EDITING );
2790 mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered.
2791 mImpl->mEventData->mUpdateInputStyle = true;
2792 mImpl->mEventData->mScrollAfterUpdatePosition = true;
2794 mImpl->NotifyInputMethodContextMultiLineStatus();
2795 if( mImpl->IsShowingPlaceholderText() )
2797 // Show alternative placeholder-text when editing
2798 ShowPlaceholderText();
2801 mImpl->RequestRelayout();
2805 void Controller::KeyboardFocusLostEvent()
2807 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
2809 if( NULL != mImpl->mEventData )
2811 if( EventData::INTERRUPTED != mImpl->mEventData->mState )
2813 mImpl->ChangeState( EventData::INACTIVE );
2815 if( !mImpl->IsShowingRealText() )
2817 // Revert to regular placeholder-text when not editing
2818 ShowPlaceholderText();
2822 mImpl->RequestRelayout();
2825 bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
2827 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
2829 bool textChanged = false;
2830 bool relayoutNeeded = false;
2832 if( ( NULL != mImpl->mEventData ) &&
2833 ( keyEvent.GetState() == KeyEvent::DOWN ) )
2835 int keyCode = keyEvent.GetKeyCode();
2836 const std::string& keyString = keyEvent.GetKeyString();
2837 const std::string keyName = keyEvent.GetKeyName();
2839 const bool isNullKey = ( 0 == keyCode ) && ( keyString.empty() );
2841 // Pre-process to separate modifying events from non-modifying input events.
2844 // In some platforms arrive key events with no key code.
2848 else if( Dali::DALI_KEY_ESCAPE == keyCode || Dali::DALI_KEY_BACK == keyCode || Dali::DALI_KEY_SEARCH == keyCode )
2853 else if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode ) ||
2854 ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) ||
2855 ( Dali::DALI_KEY_CURSOR_UP == keyCode ) ||
2856 ( Dali::DALI_KEY_CURSOR_DOWN == keyCode ) )
2858 // If don't have any text, do nothing.
2859 if( !mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters )
2864 uint32_t cursorPosition = mImpl->mEventData->mPrimaryCursorPosition;
2865 uint32_t numberOfCharacters = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
2866 uint32_t cursorLine = mImpl->mModel->mVisualModel->GetLineOfCharacter( cursorPosition );
2867 uint32_t numberOfLines = mImpl->mModel->GetNumberOfLines();
2869 // Logic to determine whether this text control will lose focus or not.
2870 if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode && 0 == cursorPosition && !keyEvent.IsShiftModifier() ) ||
2871 ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode && numberOfCharacters == cursorPosition && !keyEvent.IsShiftModifier() ) ||
2872 ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && cursorLine == numberOfLines -1 ) ||
2873 ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && numberOfCharacters == cursorPosition && cursorLine -1 == numberOfLines -1 ) ||
2874 ( Dali::DALI_KEY_CURSOR_UP == keyCode && cursorLine == 0 ) ||
2875 ( Dali::DALI_KEY_CURSOR_UP == keyCode && numberOfCharacters == cursorPosition && cursorLine == 1 ) )
2877 // Release the active highlight.
2878 if( mImpl->mEventData->mState == EventData::SELECTING )
2880 mImpl->ChangeState( EventData::EDITING );
2882 // Update selection position.
2883 mImpl->mEventData->mLeftSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
2884 mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
2885 mImpl->mEventData->mUpdateCursorPosition = true;
2886 mImpl->RequestRelayout();
2891 mImpl->mEventData->mCheckScrollAmount = true;
2892 Event event( Event::CURSOR_KEY_EVENT );
2893 event.p1.mInt = keyCode;
2894 event.p2.mBool = keyEvent.IsShiftModifier();
2895 mImpl->mEventData->mEventQueue.push_back( event );
2897 // Will request for relayout.
2898 relayoutNeeded = true;
2900 else if ( Dali::DevelKey::DALI_KEY_CONTROL_LEFT == keyCode || Dali::DevelKey::DALI_KEY_CONTROL_RIGHT == keyCode )
2902 // Left or Right Control key event is received before Ctrl-C/V/X key event is received
2903 // If not handle it here, any selected text will be deleted
2908 else if ( keyEvent.IsCtrlModifier() )
2910 bool consumed = false;
2911 if (keyName == KEY_C_NAME)
2913 // Ctrl-C to copy the selected text
2914 TextPopupButtonTouched( Toolkit::TextSelectionPopup::COPY );
2917 else if (keyName == KEY_V_NAME)
2919 // Ctrl-V to paste the copied text
2920 TextPopupButtonTouched( Toolkit::TextSelectionPopup::PASTE );
2923 else if (keyName == KEY_X_NAME)
2925 // Ctrl-X to cut the selected text
2926 TextPopupButtonTouched( Toolkit::TextSelectionPopup::CUT );
2931 else if( ( Dali::DALI_KEY_BACKSPACE == keyCode ) ||
2932 ( Dali::DevelKey::DALI_KEY_DELETE == keyCode ) )
2934 textChanged = DeleteEvent( keyCode );
2936 // Will request for relayout.
2937 relayoutNeeded = true;
2939 else if( IsKey( keyEvent, Dali::DALI_KEY_POWER ) ||
2940 IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
2941 IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
2943 // Power key/Menu/Home key behaviour does not allow edit mode to resume.
2944 mImpl->ChangeState( EventData::INACTIVE );
2946 // Will request for relayout.
2947 relayoutNeeded = true;
2949 // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text.
2951 else if( ( Dali::DALI_KEY_SHIFT_LEFT == keyCode ) || ( Dali::DALI_KEY_SHIFT_RIGHT == keyCode ) )
2953 // 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
2954 // and a character is typed after the type of a upper case latin character.
2959 else if( ( Dali::DALI_KEY_VOLUME_UP == keyCode ) || ( Dali::DALI_KEY_VOLUME_DOWN == keyCode ) )
2961 // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text.
2967 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
2969 if( !keyString.empty() )
2971 // InputMethodContext is no longer handling key-events
2972 mImpl->ClearPreEditFlag();
2974 InsertText( keyString, COMMIT );
2978 // Will request for relayout.
2979 relayoutNeeded = true;
2984 if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
2985 ( mImpl->mEventData->mState != EventData::INACTIVE ) &&
2987 ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) &&
2988 ( Dali::DALI_KEY_SHIFT_RIGHT != keyCode ) &&
2989 ( Dali::DALI_KEY_VOLUME_UP != keyCode ) &&
2990 ( Dali::DALI_KEY_VOLUME_DOWN != keyCode ) )
2992 // Should not change the state if the key is the shift send by the InputMethodContext.
2993 // Otherwise, when the state is SELECTING the text controller can't send the right
2994 // surrounding info to the InputMethodContext.
2995 mImpl->ChangeState( EventData::EDITING );
2997 // Will request for relayout.
2998 relayoutNeeded = true;
3001 if( relayoutNeeded )
3003 mImpl->RequestRelayout();
3008 ( NULL != mImpl->mEditableControlInterface ) )
3010 // Do this last since it provides callbacks into application code
3011 mImpl->mEditableControlInterface->TextChanged();
3017 void Controller::TapEvent( unsigned int tapCount, float x, float y )
3019 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
3021 if( NULL != mImpl->mEventData )
3023 DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState );
3024 EventData::State state( mImpl->mEventData->mState );
3025 bool relayoutNeeded( false ); // to avoid unnecessary relayouts when tapping an empty text-field
3027 if( mImpl->IsClipboardVisible() )
3029 if( EventData::INACTIVE == state || EventData::EDITING == state)
3031 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
3033 relayoutNeeded = true;
3035 else if( 1u == tapCount )
3037 if( EventData::EDITING_WITH_POPUP == state || EventData::EDITING_WITH_PASTE_POPUP == state )
3039 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); // If Popup shown hide it here so can be shown again if required.
3042 if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != state ) )
3044 mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
3045 relayoutNeeded = true;
3049 if( mImpl->IsShowingPlaceholderText() && !mImpl->IsFocusedPlaceholderAvailable() )
3051 // Hide placeholder text
3055 if( EventData::INACTIVE == state )
3057 mImpl->ChangeState( EventData::EDITING );
3059 else if( !mImpl->IsClipboardEmpty() )
3061 mImpl->ChangeState( EventData::EDITING_WITH_POPUP );
3063 relayoutNeeded = true;
3066 else if( 2u == tapCount )
3068 if( mImpl->mEventData->mSelectionEnabled &&
3069 mImpl->IsShowingRealText() )
3071 relayoutNeeded = true;
3072 mImpl->mEventData->mIsLeftHandleSelected = true;
3073 mImpl->mEventData->mIsRightHandleSelected = true;
3077 // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
3078 if( relayoutNeeded )
3080 Event event( Event::TAP_EVENT );
3081 event.p1.mUint = tapCount;
3082 event.p2.mFloat = x;
3083 event.p3.mFloat = y;
3084 mImpl->mEventData->mEventQueue.push_back( event );
3086 mImpl->RequestRelayout();
3090 // Reset keyboard as tap event has occurred.
3091 mImpl->ResetInputMethodContext();
3094 void Controller::PanEvent( GestureState state, const Vector2& displacement )
3096 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
3098 if( NULL != mImpl->mEventData )
3100 Event event( Event::PAN_EVENT );
3101 event.p1.mInt = static_cast<int>( state );
3102 event.p2.mFloat = displacement.x;
3103 event.p3.mFloat = displacement.y;
3104 mImpl->mEventData->mEventQueue.push_back( event );
3106 mImpl->RequestRelayout();
3110 void Controller::LongPressEvent( GestureState state, float x, float y )
3112 DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected LongPressEvent" );
3114 if( ( state == GestureState::STARTED ) &&
3115 ( NULL != mImpl->mEventData ) )
3117 // The 1st long-press on inactive text-field is treated as tap
3118 if( EventData::INACTIVE == mImpl->mEventData->mState )
3120 mImpl->ChangeState( EventData::EDITING );
3122 Event event( Event::TAP_EVENT );
3124 event.p2.mFloat = x;
3125 event.p3.mFloat = y;
3126 mImpl->mEventData->mEventQueue.push_back( event );
3128 mImpl->RequestRelayout();
3130 else if( !mImpl->IsShowingRealText() )
3132 Event event( Event::LONG_PRESS_EVENT );
3133 event.p1.mInt = static_cast<int>( state );
3134 event.p2.mFloat = x;
3135 event.p3.mFloat = y;
3136 mImpl->mEventData->mEventQueue.push_back( event );
3137 mImpl->RequestRelayout();
3139 else if( !mImpl->IsClipboardVisible() )
3141 // Reset the InputMethodContext to commit the pre-edit before selecting the text.
3142 mImpl->ResetInputMethodContext();
3144 Event event( Event::LONG_PRESS_EVENT );
3145 event.p1.mInt = static_cast<int>( state );
3146 event.p2.mFloat = x;
3147 event.p3.mFloat = y;
3148 mImpl->mEventData->mEventQueue.push_back( event );
3149 mImpl->RequestRelayout();
3151 mImpl->mEventData->mIsLeftHandleSelected = true;
3152 mImpl->mEventData->mIsRightHandleSelected = true;
3157 void Controller::SelectEvent( float x, float y, SelectionType selectType )
3159 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SelectEvent\n" );
3161 if( NULL != mImpl->mEventData )
3163 if( selectType == SelectionType::ALL )