mHandle[GRAB_HANDLE].actor.SetImage( imagePressed );
}
}
- else if( TouchPoint::Up == point.state )
+ else if( ( TouchPoint::Up == point.state ) ||
+ ( TouchPoint::Interrupted == point.state ) )
{
mHandle[GRAB_HANDLE].pressed = false;
Image imageReleased = mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED];
mHandle[LEFT_SELECTION_HANDLE].actor.SetImage( imagePressed );
}
}
- else if( TouchPoint::Up == point.state )
+ else if( ( TouchPoint::Up == point.state ) ||
+ ( TouchPoint::Interrupted == point.state ) )
{
mHandle[LEFT_SELECTION_HANDLE].pressed = false;
Image imageReleased = mHandleImages[flip ? RIGHT_SELECTION_HANDLE : LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED];
mHandle[RIGHT_SELECTION_HANDLE].actor.SetImage( imagePressed );
}
}
- else if( TouchPoint::Up == point.state )
+ else if( ( TouchPoint::Up == point.state ) ||
+ ( TouchPoint::Interrupted == point.state ) )
{
Image imageReleased = mHandleImages[flip ? LEFT_SELECTION_HANDLE : RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED];
mHandle[RIGHT_SELECTION_HANDLE].pressed = false;
void Decorator::SetHandleActive( HandleType handleType, bool active )
{
mImpl->mHandle[handleType].active = active;
+
+ if( !active )
+ {
+ // TODO: this is a work-around.
+ // The problem is the handle actor does not receive the touch event with the Interrupt
+ // state when the power button is pressed and the application goes to background.
+ mImpl->mHandle[handleType].pressed = false;
+ Image imageReleased = mImpl->mHandleImages[handleType][HANDLE_IMAGE_RELEASED];
+ ImageActor imageActor = mImpl->mHandle[handleType].actor;
+ if( imageReleased && imageActor )
+ {
+ imageActor.SetImage( imageReleased );
+ }
+ }
}
bool Decorator::IsHandleActive( HandleType handleType ) const
mUpdateLeftSelectionPosition( false ),
mUpdateRightSelectionPosition( false ),
mScrollAfterUpdatePosition( false ),
- mScrollAfterDelete( false )
+ mScrollAfterDelete( false ),
+ mAllTextSelected( false )
{}
EventData::~EventData()
leftScroll = true;
}
+ SetPopupButtons();
mEventData->mDecoratorUpdated = true;
mEventData->mUpdateLeftSelectionPosition = false;
}
rightScroll = true;
}
+ SetPopupButtons();
mEventData->mDecoratorUpdated = true;
mEventData->mUpdateRightSelectionPosition = false;
}
RepositionSelectionHandles( selectionStart, selectionEnd );
}
+void Controller::Impl::SetPopupButtons()
+{
+ /**
+ * Sets the Popup buttons to be shown depending on State.
+ *
+ * If SELECTING : CUT & COPY + ( PASTE & CLIPBOARD if content available to paste )
+ *
+ * If EDITING_WITH_POPUP : SELECT & SELECT_ALL
+ */
+
+ TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::NONE;
+
+ if ( ( EventData::SELECTING == mEventData->mState ) || ( EventData::SELECTION_CHANGED == mEventData->mState ) )
+ {
+ buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY );
+
+ if ( !IsClipboardEmpty() )
+ {
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
+ }
+
+ if ( !mEventData->mAllTextSelected )
+ {
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::SELECT_ALL ) );
+ }
+ }
+ else if ( EventData::EDITING_WITH_POPUP == mEventData->mState )
+ {
+ buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL );
+
+ if ( !IsClipboardEmpty() )
+ {
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
+ }
+ }
+
+ mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow );
+}
+
void Controller::Impl::ChangeState( EventData::State newState )
{
if( NULL == mEventData )
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
if( mEventData->mGrabHandlePopupEnabled )
{
- TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY );
- if ( !IsClipboardEmpty() )
- {
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
- }
-
- mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow );
+ SetPopupButtons();
mEventData->mDecorator->SetPopupActive( true );
}
mEventData->mDecoratorUpdated = true;
{
if( mEventData->mGrabHandlePopupEnabled )
{
- TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY );
- if ( !IsClipboardEmpty() )
- {
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
- }
+ SetPopupButtons();
mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
- mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow );
mEventData->mDecorator->SetPopupActive( true );
}
mEventData->mDecoratorUpdated = true;
}
if( mEventData->mGrabHandlePopupEnabled )
{
- TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL );
-
- if ( !IsClipboardEmpty() )
- {
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
- }
-
- mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow );
+ SetPopupButtons();
mEventData->mDecorator->SetPopupActive( true );
}
HideClipboard();
cursorPosition.x,
cursorPosition.y,
cursorInfo.lineHeight );
+
+ // If selection handle at start of the text and other at end of the text then all text is selected.
+ const CharacterIndex startOfSelection = std::min( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition );
+ const CharacterIndex endOfSelection = std::max ( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition );
+ mEventData->mAllTextSelected = ( startOfSelection == 0 ) && ( endOfSelection == mLogicalModel->mText.Count() );
}
void Controller::Impl::ClampHorizontalScroll( const Vector2& actualSize )
bool mUpdateRightSelectionPosition : 1; ///< True if the visual position of the right selection handle must be recalculated.
bool mScrollAfterUpdatePosition : 1; ///< Whether to scroll after the cursor position is updated.
bool mScrollAfterDelete : 1; ///< Whether to scroll after delete characters.
+ bool mAllTextSelected : 1; ///< True if the selection handles are selecting all the text
};
struct ModifyEvent
void RepositionSelectionHandles( CharacterIndex selectionStart, CharacterIndex selectionEnd );
void RepositionSelectionHandles( float visualX, float visualY );
- void ChangeState( EventData::State newState );
+ void SetPopupButtons();
+ void ChangeState( EventData::State newState );
LineIndex GetClosestLine( float y ) const;
void FindSelectionIndices( float visualX, float visualY, CharacterIndex& startIndex, CharacterIndex& endIndex );