X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=592bc122750f9f2dbeffb864c2849780cce01730;hp=bcac0251e54dac6953c5a59898f6d49d37e90b44;hb=2039784e7811f5f68ffdfb13c6aa1bc39f2ab950;hpb=db3fc9592ec6897e668a62afa7ffdff3ad82c023 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index bcac025..592bc12 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -90,7 +90,8 @@ void Controller::SetText( const std::string& text ) // If popup shown then hide it by switching to Editing state if( ( EventData::SELECTING == mImpl->mEventData->mState ) || ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) || - ( EventData::EDITING_WITH_GRAB_HANDLE == mImpl->mEventData->mState ) ) + ( EventData::EDITING_WITH_GRAB_HANDLE == mImpl->mEventData->mState ) || + ( EventData::EDITING_WITH_PASTE_POPUP == mImpl->mEventData->mState ) ) { mImpl->ChangeState( EventData::EDITING ); } @@ -453,12 +454,12 @@ bool Controller::RemoveText( int cursorOffset, int numberOfChars ) cursorIndex = oldCursorIndex + cursorOffset; } - if( (cursorIndex + numberOfChars) > currentText.Count() ) + if( ( cursorIndex + numberOfChars ) > currentText.Count() ) { numberOfChars = currentText.Count() - cursorIndex; } - if( (cursorIndex + numberOfChars) <= currentText.Count() ) + if( ( cursorIndex + numberOfChars ) <= currentText.Count() ) { Vector::Iterator first = currentText.Begin() + cursorIndex; Vector::Iterator last = first + numberOfChars; @@ -667,7 +668,7 @@ float Controller::GetHeightForWidth( float width ) ProcessModifyEvents(); Size layoutSize; - if( width != mImpl->mVisualModel->mControlSize.width ) + if( fabsf( width - mImpl->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 ) { // Operations that can be done only once until the text changes. const OperationsMask onlyOnceOperations = static_cast( CONVERT_TO_UTF32 | @@ -843,9 +844,7 @@ void Controller::ResetCursorPosition( CharacterIndex cursorIndex ) mImpl->mEventData->mPrimaryCursorPosition = cursorIndex; // Update the cursor if it's in editing mode. - if( ( EventData::EDITING == mImpl->mEventData->mState ) || - ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) || - ( EventData::EDITING_WITH_GRAB_HANDLE == mImpl->mEventData->mState ) ) + if ( EventData::IsEditingState( mImpl->mEventData->mState ) ) { mImpl->mEventData->mUpdateCursorPosition = true; } @@ -898,9 +897,7 @@ void Controller::TextInsertedEvent() REORDER ); // Queue a cursor reposition event; this must wait until after DoRelayout() - if( ( EventData::EDITING == mImpl->mEventData->mState ) || - ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) || - ( EventData::EDITING_WITH_GRAB_HANDLE == mImpl->mEventData->mState ) ) + if ( EventData::IsEditingState( mImpl->mEventData->mState ) ) { mImpl->mEventData->mUpdateCursorPosition = true; mImpl->mEventData->mScrollAfterUpdatePosition = true; @@ -1505,33 +1502,48 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y ) if( NULL != mImpl->mEventData ) { + DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState ); + if( 1u == tapCount ) { // This is to avoid unnecessary relayouts when tapping an empty text-field bool relayoutNeeded( false ); - if( mImpl->IsShowingRealText() && - EventData::EDITING == mImpl->mEventData->mState ) + if ( EventData::EDITING_WITH_PASTE_POPUP == mImpl->mEventData->mState || EventData::EDITING_WITH_PASTE_POPUP == mImpl->mEventData->mState ) { - // Show grab handle on second tap - mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); - relayoutNeeded = true; + mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE); // If Popup shown hide it here so can be shown again if required. } - else if( EventData::EDITING != mImpl->mEventData->mState && - EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState ) + + if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != mImpl->mEventData->mState ) ) { - if( mImpl->IsShowingPlaceholderText() && ! mImpl->IsFocusedPlaceholderAvailable() ) + // Already in an active state so show a popup + if ( !mImpl->IsClipboardEmpty() ) { - // Hide placeholder text - ResetText(); + // Shows Paste popup but could show full popup with Selection options. ( EDITING_WITH_POPUP ) + mImpl->ChangeState( EventData::EDITING_WITH_PASTE_POPUP ); + } + else + { + mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); } - // Show cursor on first tap - mImpl->ChangeState( EventData::EDITING ); relayoutNeeded = true; } - else if( mImpl->IsShowingRealText() ) + else { - // Move the cursor + if( mImpl->IsShowingPlaceholderText() && !mImpl->IsFocusedPlaceholderAvailable() ) + { + // Hide placeholder text + ResetText(); + } + + if ( EventData::INACTIVE == mImpl->mEventData->mState ) + { + mImpl->ChangeState( EventData::EDITING ); + } + else if ( !mImpl->IsClipboardEmpty() ) + { + mImpl->ChangeState( EventData::EDITING_WITH_POPUP ); + } relayoutNeeded = true; } @@ -1562,6 +1574,7 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y ) } void Controller::PanEvent( Gesture::State state, const Vector2& displacement ) + // Show cursor and grabhandle on first tap, this matches the behaviour of tapping when already editing { DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" ); @@ -1619,6 +1632,8 @@ void Controller::LongPressEvent( Gesture::State state, float x, float y ) void Controller::SelectEvent( float x, float y, bool selectAll ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SelectEvent\n" ); + if( mImpl->mEventData ) { mImpl->ChangeState( EventData::SELECTING ); @@ -1716,8 +1731,14 @@ void Controller::PasteText( const std::string& stringToPaste ) void Controller::PasteClipboardItemEvent() { + // Retrieve the clipboard contents first ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); std::string stringToPaste( notifier.GetContent() ); + + // Commit the current pre-edit text; the contents of the clipboard should be appended + mImpl->ResetImfManager(); + + // Paste PasteText( stringToPaste ); } @@ -1800,7 +1821,7 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent ) { - bool update( false ); + bool update = false; bool requestRelayout = false; std::string text; @@ -1928,17 +1949,15 @@ void Controller::NotifyImfManager() { if( mImpl->mEventData ) { - ImfManager imfManager = ImfManager::Get(); - - if( imfManager ) + if( mImpl->mEventData->mImfManager ) { // Notifying IMF of a cursor change triggers a surrounding text request so updating it now. std::string text; GetText( text ); - imfManager.SetSurroundingText( text ); + mImpl->mEventData->mImfManager.SetSurroundingText( text ); - imfManager.SetCursorPosition( GetLogicalCursorPosition() ); - imfManager.NotifyCursorPosition(); + mImpl->mEventData->mImfManager.SetCursorPosition( GetLogicalCursorPosition() ); + mImpl->mEventData->mImfManager.NotifyCursorPosition(); } } }