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=18d79302e991b503b7e24745ab3d3df1ee415fa4;hp=35c43b09d5337deb350581454c7914739ee685a1;hb=c5867682354d37755781047add02d85e46078a47;hpb=dc403b5648fc5fe2f6c67eee7033cd7678485731 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 35c43b0..18d7930 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -135,7 +135,8 @@ EventData::EventData( DecoratorPtr decorator ) mUpdateCursorPosition( false ), mUpdateLeftSelectionPosition( false ), mUpdateRightSelectionPosition( false ), - mScrollAfterUpdateCursorPosition( false ) + mScrollAfterUpdateCursorPosition( false ), + mScrollAfterDelete( false ) {} EventData::~EventData() @@ -201,6 +202,12 @@ bool Controller::Impl::ProcessInputEvents() mEventData->mDecoratorUpdated = true; mEventData->mUpdateCursorPosition = false; } + else if( mEventData->mScrollAfterDelete ) + { + ScrollTextToMatchCursor(); + mEventData->mDecoratorUpdated = true; + mEventData->mScrollAfterDelete = false; + } else if( mEventData->mUpdateLeftSelectionPosition ) { UpdateSelectionHandle( LEFT_SELECTION_HANDLE ); @@ -1247,6 +1254,57 @@ void Controller::Impl::ScrollToMakeCursorVisible() // TODO : calculate the vertical scroll. } +void Controller::Impl::ScrollTextToMatchCursor() +{ + // Get the current cursor position in decorator coords. + const Vector2& currentCursorPosition = mEventData->mDecorator->GetPosition( PRIMARY_CURSOR ); + + // Calculate the new cursor position. + CursorInfo cursorInfo; + GetCursorPosition( mEventData->mPrimaryCursorPosition, + cursorInfo ); + + // Calculate the offset to match the cursor position before the character was deleted. + mEventData->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x - mAlignmentOffset.x; + + ClampHorizontalScroll( mVisualModel->GetActualSize() ); + bool updateCursorPosition = true; + + const Vector2 offset = mEventData->mScrollPosition + mAlignmentOffset; + const Vector2 cursorPosition = cursorInfo.primaryPosition + offset; + + if( updateCursorPosition ) + { + // Sets the cursor position. + mEventData->mDecorator->SetPosition( PRIMARY_CURSOR, + cursorPosition.x, + cursorPosition.y, + cursorInfo.primaryCursorHeight, + cursorInfo.lineHeight ); + + // Sets the grab handle position. + mEventData->mDecorator->SetPosition( GRAB_HANDLE, + cursorPosition.x, + cursorPosition.y, + cursorInfo.lineHeight ); + + if( cursorInfo.isSecondaryCursor ) + { + mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH ); + mEventData->mDecorator->SetPosition( SECONDARY_CURSOR, + cursorInfo.secondaryPosition.x + offset.x, + cursorInfo.secondaryPosition.y + offset.y, + cursorInfo.secondaryCursorHeight, + cursorInfo.lineHeight ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + offset.x, cursorInfo.secondaryPosition.y + offset.y ); + } + else + { + mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY ); + } + } +} + void Controller::Impl::RequestRelayout() { mControlInterface.RequestTextRelayout();