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-impl.cpp;h=9637245e9daff4e2ee855a145c6f820d47f92bae;hp=6cf26fc5ad930cd6951352070160b87cb3d862a9;hb=refs%2Fchanges%2F31%2F80231%2F10;hpb=12fe9741661d0fefaabddd959d04566a0a2d2233 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 6cf26fc..9637245 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -91,6 +91,7 @@ EventData::EventData( DecoratorPtr decorator ) mUpdateGrabHandlePosition( false ), mUpdateLeftSelectionPosition( false ), mUpdateRightSelectionPosition( false ), + mIsLeftHandleSelected( false ), mUpdateHighlightBox( false ), mScrollAfterUpdatePosition( false ), mScrollAfterDelete( false ), @@ -218,16 +219,12 @@ bool Controller::Impl::ProcessInputEvents() GetCursorPosition( mEventData->mRightSelectionPosition, rightHandleInfo ); - if( mEventData->mScrollAfterUpdatePosition && mEventData->mUpdateLeftSelectionPosition ) + if( mEventData->mScrollAfterUpdatePosition && ( mEventData->mIsLeftHandleSelected ? mEventData->mUpdateLeftSelectionPosition : mEventData->mUpdateRightSelectionPosition ) ) { - const Vector2 currentCursorPosition( leftHandleInfo.primaryPosition.x, leftHandleInfo.lineOffset ); - ScrollToMakePositionVisible( currentCursorPosition, leftHandleInfo.lineHeight ); - } + CursorInfo& info = mEventData->mIsLeftHandleSelected ? leftHandleInfo : rightHandleInfo; - if( mEventData->mScrollAfterUpdatePosition && mEventData->mUpdateRightSelectionPosition ) - { - const Vector2 currentCursorPosition( rightHandleInfo.primaryPosition.x, rightHandleInfo.lineOffset ); - ScrollToMakePositionVisible( currentCursorPosition, rightHandleInfo.lineHeight ); + const Vector2 currentCursorPosition( info.primaryPosition.x, info.lineOffset ); + ScrollToMakePositionVisible( currentCursorPosition, info.lineHeight ); } } @@ -1203,17 +1200,31 @@ void Controller::Impl::OnPanEvent( const Event& event ) return; } - int state = event.p1.mInt; + const bool isHorizontalScrollEnabled = mEventData->mDecorator->IsHorizontalScrollEnabled(); + const bool isVerticalScrollEnabled = mEventData->mDecorator->IsVerticalScrollEnabled(); + + if( !isHorizontalScrollEnabled && !isVerticalScrollEnabled ) + { + // Nothing to do if scrolling is not enabled. + return; + } + + const int state = event.p1.mInt; - if( ( Gesture::Started == state ) || - ( Gesture::Continuing == state ) ) + switch( state ) { - if( mEventData->mDecorator ) + case Gesture::Started: + { + // Will remove the cursor, handles or text's popup, ... + ChangeState( EventData::TEXT_PANNING ); + break; + } + case Gesture::Continuing: { const Vector2& layoutSize = mVisualModel->GetLayoutSize(); const Vector2 currentScroll = mScrollPosition; - if( mEventData->mDecorator->IsHorizontalScrollEnabled() ) + if( isHorizontalScrollEnabled ) { const float displacementX = event.p2.mFloat; mScrollPosition.x += displacementX; @@ -1221,7 +1232,7 @@ void Controller::Impl::OnPanEvent( const Event& event ) ClampHorizontalScroll( layoutSize ); } - if( mEventData->mDecorator->IsVerticalScrollEnabled() ) + if( isVerticalScrollEnabled ) { const float displacementY = event.p3.mFloat; mScrollPosition.y += displacementY; @@ -1230,7 +1241,17 @@ void Controller::Impl::OnPanEvent( const Event& event ) } mEventData->mDecorator->UpdatePositions( mScrollPosition - currentScroll ); + break; + } + case Gesture::Finished: + case Gesture::Cancelled: // FALLTHROUGH + { + // Will go back to the previous state to show the cursor, handles, the text's popup, ... + ChangeState( mEventData->mPreviousState ); + break; } + default: + break; } } @@ -1302,6 +1323,9 @@ void Controller::Impl::OnHandleEvent( const Event& event ) // Updates the decorator if the soft handle panning is enabled. It triggers a relayout in the decorator and the new position of the handle is set. mEventData->mDecoratorUpdated = isSmoothHandlePanEnabled; + + // Will define the order to scroll the text to match the handle position. + mEventData->mIsLeftHandleSelected = true; } else if( Event::RIGHT_SELECTION_HANDLE_EVENT == event.type ) { @@ -1319,6 +1343,9 @@ void Controller::Impl::OnHandleEvent( const Event& event ) // Updates the decorator if the soft handle panning is enabled. It triggers a relayout in the decorator and the new position of the handle is set. mEventData->mDecoratorUpdated = isSmoothHandlePanEnabled; + + // Will define the order to scroll the text to match the handle position. + mEventData->mIsLeftHandleSelected = false; } } // end ( HANDLE_PRESSED == state ) else if( ( HANDLE_RELEASED == state ) || @@ -1361,6 +1388,7 @@ void Controller::Impl::OnHandleEvent( const Event& event ) mEventData->mUpdateHighlightBox = true; mEventData->mUpdateLeftSelectionPosition = true; + mEventData->mUpdateRightSelectionPosition = true; if( handleStopScrolling || isSmoothHandlePanEnabled ) { @@ -1379,6 +1407,7 @@ void Controller::Impl::OnHandleEvent( const Event& event ) mEventData->mUpdateHighlightBox = true; mEventData->mUpdateRightSelectionPosition = true; + mEventData->mUpdateLeftSelectionPosition = true; if( handleStopScrolling || isSmoothHandlePanEnabled ) { @@ -2152,6 +2181,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) if( mEventData->mState != newState ) { + mEventData->mPreviousState = mEventData->mState; mEventData->mState = newState; switch( mEventData->mState ) @@ -2163,6 +2193,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( false ); mEventData->mDecorator->SetPopupActive( false ); mEventData->mDecoratorUpdated = true; HideClipboard(); @@ -2173,6 +2204,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( false ); mEventData->mDecorator->SetPopupActive( false ); mEventData->mDecoratorUpdated = true; HideClipboard(); @@ -2185,6 +2217,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true ); + mEventData->mDecorator->SetHighlightActive( true ); if( mEventData->mGrabHandlePopupEnabled ) { SetPopupButtons(); @@ -2204,6 +2237,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( false ); if( mEventData->mGrabHandlePopupEnabled ) { mEventData->mDecorator->SetPopupActive( false ); @@ -2225,6 +2259,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) { mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( false ); } else { @@ -2252,6 +2287,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( false ); if( mEventData->mGrabHandlePopupEnabled ) { mEventData->mDecorator->SetPopupActive( false ); @@ -2267,6 +2303,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true ); + mEventData->mDecorator->SetHighlightActive( true ); if( mEventData->mGrabHandlePopupEnabled ) { mEventData->mDecorator->SetPopupActive( false ); @@ -2286,6 +2323,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( false ); if( mEventData->mGrabHandlePopupEnabled ) { mEventData->mDecorator->SetPopupActive( false ); @@ -2306,6 +2344,7 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true ); mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( false ); if( mEventData->mGrabHandlePopupEnabled ) { @@ -2316,6 +2355,27 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecoratorUpdated = true; break; } + case EventData::TEXT_PANNING: + { + mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE ); + mEventData->mDecorator->StopCursorBlink(); + mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false ); + if( mEventData->mDecorator->IsHandleActive( LEFT_SELECTION_HANDLE ) || + mEventData->mDecorator->IsHandleActive( RIGHT_SELECTION_HANDLE ) ) + { + mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false ); + mEventData->mDecorator->SetHighlightActive( true ); + } + + if( mEventData->mGrabHandlePopupEnabled ) + { + mEventData->mDecorator->SetPopupActive( false ); + } + + mEventData->mDecoratorUpdated = true; + break; + } } } }