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=800a72187d5debe64d592477f1bd20bc44d6edc3;hp=29b5718c1f3c03fe87a73433000cfaa0492204d7;hb=73696fd1c7d5f263261a7114159aab66ead484ff;hpb=f1fd8ae285533109596e90f5598e91c5ce009659 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 29b5718..800a721 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -154,16 +154,19 @@ bool Controller::Impl::ProcessInputEvents() GetCursorPosition( mEventData->mPrimaryCursorPosition, cursorInfo ); - if( mEventData->mScrollAfterUpdatePosition ) + // Scroll first the text after delete ... + if( mEventData->mScrollAfterDelete ) { - ScrollToMakePositionVisible( cursorInfo.primaryPosition ); - mEventData->mScrollAfterUpdatePosition = false; + ScrollTextToMatchCursor( cursorInfo ); } - else if( mEventData->mScrollAfterDelete ) + + // ... then, text can be scrolled to make the cursor visible. + if( mEventData->mScrollAfterUpdatePosition ) { - ScrollTextToMatchCursor( cursorInfo ); - mEventData->mScrollAfterDelete = false; + ScrollToMakePositionVisible( cursorInfo.primaryPosition ); } + mEventData->mScrollAfterUpdatePosition = false; + mEventData->mScrollAfterDelete = false; UpdateCursorPosition( cursorInfo ); @@ -1302,6 +1305,7 @@ void Controller::Impl::OnSelectEvent( const Event& event ) mEventData->mUpdateLeftSelectionPosition = true; mEventData->mUpdateRightSelectionPosition = true; + mEventData->mUpdateCursorPosition = false; mEventData->mScrollAfterUpdatePosition = ( mEventData->mLeftSelectionPosition != mEventData->mRightSelectionPosition ); } @@ -1370,12 +1374,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete // Scroll after delete. mEventData->mPrimaryCursorPosition = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition; - mEventData->mScrollAfterDelete = true; } - // Udpade the cursor position and the decorator. - // Scroll after the position is updated if is not scrolling after delete. - mEventData->mUpdateCursorPosition = true; - mEventData->mScrollAfterUpdatePosition = !mEventData->mScrollAfterDelete; mEventData->mDecoratorUpdated = true; } } @@ -2457,8 +2456,10 @@ void Controller::Impl::ClampVerticalScroll( const Vector2& actualSize ) void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position ) { + const float cursorWidth = mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f; + // position is in actor's coords. - const float positionEnd = position.x + ( mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f ); + const float positionEnd = position.x + cursorWidth; // Transform the position to decorator coords. const float alignment = IsShowingRealText() ? mAlignmentOffset.x : 0.f; @@ -2485,6 +2486,9 @@ void Controller::Impl::ScrollTextToMatchCursor( const CursorInfo& cursorInfo ) mEventData->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x - mAlignmentOffset.x; ClampHorizontalScroll( mVisualModel->GetLayoutSize() ); + + // Makes the new cursor position visible if needed. + ScrollToMakePositionVisible( cursorInfo.primaryPosition ); } void Controller::Impl::RequestRelayout()