mUpdateGrabHandlePosition( false ),
mUpdateLeftSelectionPosition( false ),
mUpdateRightSelectionPosition( false ),
+ mIsLeftHandleSelected( false ),
mUpdateHighlightBox( false ),
mScrollAfterUpdatePosition( false ),
mScrollAfterDelete( false ),
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 );
}
}
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;
ClampHorizontalScroll( layoutSize );
}
- if( mEventData->mDecorator->IsVerticalScrollEnabled() )
+ if( isVerticalScrollEnabled )
{
const float displacementY = event.p3.mFloat;
mScrollPosition.y += displacementY;
}
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;
}
}
// 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 )
{
// 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 ) ||
mEventData->mUpdateHighlightBox = true;
mEventData->mUpdateLeftSelectionPosition = true;
+ mEventData->mUpdateRightSelectionPosition = true;
if( handleStopScrolling || isSmoothHandlePanEnabled )
{
mEventData->mUpdateHighlightBox = true;
mEventData->mUpdateRightSelectionPosition = true;
+ mEventData->mUpdateLeftSelectionPosition = true;
if( handleStopScrolling || isSmoothHandlePanEnabled )
{
if( mEventData->mState != newState )
{
+ mEventData->mPreviousState = mEventData->mState;
mEventData->mState = newState;
switch( mEventData->mState )
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();
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();
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();
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 );
{
mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHighlightActive( false );
}
else
{
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 );
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 );
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 );
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->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;
+ }
}
}
}