- lineHeight( 0.0f ),
- grabDisplacementX( 0.f ),
- grabDisplacementY( 0.f ),
- active( false ),
- horizontallyVisible( false ),
- verticallyVisible( false ),
- pressed( false ),
- verticallyFlippedPreferred( false ),
- horizontallyFlipped( false ),
- verticallyFlipped( false ),
- verticallyFlippedOnTouch( false )
+ lineHeight(0.0f),
+ grabDisplacementX(0.f),
+ grabDisplacementY(0.f),
+ active(false),
+ horizontallyVisible(false),
+ verticallyVisible(false),
+ pressed(false),
+ verticallyFlippedPreferred(false),
+ horizontallyFlipped(false),
+ verticallyFlipped(false),
+ verticallyFlippedOnTouch(false)
- Impl( ControllerInterface& controller,
- TextSelectionPopupCallbackInterface& callbackInterface )
- : mController( controller ),
- mEnabledPopupButtons( TextSelectionPopup::NONE ),
- mTextSelectionPopupCallbackInterface( callbackInterface ),
- mHandleColor( HANDLE_COLOR ),
+ Impl(ControllerInterface& controller,
+ TextSelectionPopupCallbackInterface& callbackInterface)
+ : mController(controller),
+ mEnabledPopupButtons(TextSelectionPopup::NONE),
+ mTextSelectionPopupCallbackInterface(callbackInterface),
+ mHandleColor(HANDLE_COLOR),
- mHighlightColor( LIGHT_BLUE ),
- mHighlightPosition( Vector2::ZERO ),
- mHighlightSize( Vector2::ZERO ),
- mControlSize( Vector2::ZERO ),
- mHighlightOutlineOffset( 0.f ),
- mActiveCursor( ACTIVE_CURSOR_NONE ),
- mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ),
- mCursorBlinkDuration( 0.0f ),
- mCursorWidth( CURSOR_WIDTH ),
- mHandleScrolling( HANDLE_TYPE_COUNT ),
- mHandleReleased( HANDLE_TYPE_COUNT ),
- mScrollDirection( SCROLL_NONE ),
- mScrollThreshold( SCROLL_THRESHOLD ),
- mScrollSpeed( SCROLL_SPEED ),
- mScrollDistance( SCROLL_DISTANCE ),
- mTextDepth( 0u ),
- mActiveCopyPastePopup( false ),
- mPopupSetNewPosition( true ),
- mCursorBlinkStatus( true ),
- mDelayCursorBlink( false ),
- mPrimaryCursorVisible( false ),
- mSecondaryCursorVisible( false ),
- mFlipSelectionHandlesOnCross( false ),
- mFlipLeftSelectionHandleDirection( false ),
- mFlipRightSelectionHandleDirection( false ),
- mIsHandlePanning( false ),
- mIsHandleCurrentlyCrossed( false ),
- mIsHandlePreviouslyCrossed( false ),
- mNotifyEndOfScroll( false ),
- mHorizontalScrollingEnabled( false ),
- mVerticalScrollingEnabled( false ),
- mSmoothHandlePanEnabled( false ),
- mIsHighlightBoxActive( false ),
- mHidePrimaryCursorAndGrabHandle( false )
+ mHighlightColor(LIGHT_BLUE),
+ mHighlightPosition(Vector2::ZERO),
+ mHighlightSize(Vector2::ZERO),
+ mControlSize(Vector2::ZERO),
+ mHighlightOutlineOffset(0.f),
+ mActiveCursor(ACTIVE_CURSOR_NONE),
+ mCursorBlinkInterval(CURSOR_BLINK_INTERVAL),
+ mCursorBlinkDuration(0.0f),
+ mCursorWidth(CURSOR_WIDTH),
+ mHandleScrolling(HANDLE_TYPE_COUNT),
+ mHandleReleased(HANDLE_TYPE_COUNT),
+ mScrollDirection(SCROLL_NONE),
+ mScrollThreshold(SCROLL_THRESHOLD),
+ mScrollSpeed(SCROLL_SPEED),
+ mScrollDistance(SCROLL_DISTANCE),
+ mTextDepth(0u),
+ mActiveCopyPastePopup(false),
+ mPopupSetNewPosition(true),
+ mCursorBlinkStatus(true),
+ mDelayCursorBlink(false),
+ mPrimaryCursorVisible(false),
+ mSecondaryCursorVisible(false),
+ mFlipSelectionHandlesOnCross(false),
+ mFlipLeftSelectionHandleDirection(false),
+ mFlipRightSelectionHandleDirection(false),
+ mIsHandlePanning(false),
+ mIsHandleCurrentlyCrossed(false),
+ mIsHandlePreviouslyCrossed(false),
+ mNotifyEndOfScroll(false),
+ mHorizontalScrollingEnabled(false),
+ mVerticalScrollingEnabled(false),
+ mSmoothHandlePanEnabled(false),
+ mIsHighlightBoxActive(false),
+ mHidePrimaryCursorAndGrabHandle(false)
- HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
- HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
- bool newPrimaryHandlePosition = false;
- bool newSecondaryHandlePosition = false;
-
- primary.horizontallyVisible = ( ( mControlSize.width - primary.position.x > -Math::MACHINE_EPSILON_1000 ) &&
- ( primary.position.x > -Math::MACHINE_EPSILON_1000 ) );
- primary.verticallyVisible = ( ( ( mControlSize.height - primary.lineHeight ) - primary.position.y > -Math::MACHINE_EPSILON_1000 ) &&
- ( primary.position.y + ( primary.verticallyFlipped ? 0.f : primary.lineHeight ) > -Math::MACHINE_EPSILON_1000 ) );
- secondary.horizontallyVisible = ( ( mControlSize.width - secondary.position.x > -Math::MACHINE_EPSILON_1000 ) &&
- ( secondary.position.x > -Math::MACHINE_EPSILON_1000 ) );
- secondary.verticallyVisible = ( ( ( mControlSize.height - secondary.lineHeight ) - secondary.position.y > -Math::MACHINE_EPSILON_1000 ) &&
- ( secondary.position.y + ( secondary.verticallyFlipped ? 0.f : secondary.lineHeight ) > -Math::MACHINE_EPSILON_1000 ) );
-
- const bool primaryVisible = primary.horizontallyVisible && primary.verticallyVisible;
+ HandleImpl& primary = mHandle[LEFT_SELECTION_HANDLE];
+ HandleImpl& secondary = mHandle[RIGHT_SELECTION_HANDLE];
+ bool newPrimaryHandlePosition = false;
+ bool newSecondaryHandlePosition = false;
+
+ primary.horizontallyVisible = ((mControlSize.width - primary.position.x > -Math::MACHINE_EPSILON_1000) &&
+ (primary.position.x > -Math::MACHINE_EPSILON_1000));
+ primary.verticallyVisible = ((fabsf(mControlSize.height - primary.lineHeight) - primary.position.y > -Math::MACHINE_EPSILON_1000) &&
+ (primary.position.y + (primary.verticallyFlipped ? 0.f : primary.lineHeight) > -Math::MACHINE_EPSILON_1000));
+ secondary.horizontallyVisible = ((mControlSize.width - secondary.position.x > -Math::MACHINE_EPSILON_1000) &&
+ (secondary.position.x > -Math::MACHINE_EPSILON_1000));
+ secondary.verticallyVisible = ((fabsf(mControlSize.height - secondary.lineHeight) - secondary.position.y > -Math::MACHINE_EPSILON_1000) &&
+ (secondary.position.y + (secondary.verticallyFlipped ? 0.f : secondary.lineHeight) > -Math::MACHINE_EPSILON_1000));
+
+ const bool primaryVisible = primary.horizontallyVisible && primary.verticallyVisible;
- grabHandle.grabArea.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
- grabHandle.grabArea.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
- grabHandle.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
- grabHandle.grabArea.SetProperty( Actor::Property::SIZE_MODE_FACTOR, DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
- grabHandle.actor.Add( grabHandle.grabArea );
- grabHandle.actor.SetProperty( Actor::Property::COLOR, mHandleColor );
+ grabHandle.grabArea.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+ grabHandle.grabArea.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+ grabHandle.grabArea.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ grabHandle.grabArea.SetProperty(Actor::Property::SIZE_MODE_FACTOR, DEFAULT_GRAB_HANDLE_RELATIVE_SIZE);
+ grabHandle.actor.Add(grabHandle.grabArea);
+ grabHandle.actor.SetProperty(Actor::Property::COLOR, mHandleColor);
- handle.actor.SetProperty( Actor::Property::POSITION, Vector2( handle.position.x + ( mSmoothHandlePanEnabled ? handle.grabDisplacementX : 0.f ),
- yLocalPosition + ( mSmoothHandlePanEnabled ? handle.grabDisplacementY : 0.f ) ) );
+ float adjustedDisplacementX = 0.0f;
+ float adjustedDisplacementY = 0.0f;
+ if (mSmoothHandlePanEnabled)
+ {
+ adjustedDisplacementX = CalculateAdjustedDisplacement(handle.position.x, handle.grabDisplacementX, mControlSize.x);
+ adjustedDisplacementY = CalculateAdjustedDisplacement(handle.position.y, handle.grabDisplacementY, (mControlSize.y - handle.lineHeight));
+ }
+ handle.actor.SetProperty(Actor::Property::POSITION,
+ Vector2(handle.position.x + floor(0.5f * mCursorWidth) + adjustedDisplacementX,
+ yLocalPosition + adjustedDisplacementY));
+ }
+ }
+
+ float CalculateAdjustedDisplacement(float position, float displacement, float edge)
+ {
+ //Apply the displacement (on the X-axis & the Y-axis)
+ //as long as it does not exceed the control's edge.
+ float adjustedDisplacement = 0.0f;
+ if(position + displacement < 0.0f)
+ {
+ // -position to cancel it out and relocate to 0.
+ adjustedDisplacement = -position;
+ }
+ else if(position + displacement > edge)
+ {
+ // move in a displacement which is sufficient to reach the edge.
+ adjustedDisplacement = edge - position;
+ }
+ else
+ {
+ // move normally in the displacement.
+ adjustedDisplacement = displacement;
- mHighlightActor.SetProperty( Dali::Actor::Property::NAME, "HighlightActor" );
- mHighlightActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
- mHighlightActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
- mHighlightActor.SetProperty( Actor::Property::COLOR, mHighlightColor );
- mHighlightActor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
+ mHighlightActor.SetProperty(Dali::Actor::Property::NAME, "HighlightActor");
+ mHighlightActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ mHighlightActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ mHighlightActor.SetProperty(Actor::Property::COLOR, mHighlightColor);
+ mHighlightActor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
- std::string mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
- Vector4 mHandleColor;
-
- CursorImpl mCursor[CURSOR_COUNT];
- HandleImpl mHandle[HANDLE_TYPE_COUNT];
-
- VertexBuffer mQuadVertices;
- Geometry mQuadGeometry;
- QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight.
-
- Vector4 mBoundingBox; ///< The bounding box in world coords.
- Vector4 mHighlightColor; ///< Color of the highlight
- Vector2 mHighlightPosition; ///< The position of the highlight actor.
- Size mHighlightSize; ///< The size of the highlighted text.
- Size mControlSize; ///< The control's size. Set by the Relayout.
- float mHighlightOutlineOffset; ///< The outline's offset.
-
- unsigned int mActiveCursor;
- unsigned int mCursorBlinkInterval;
- float mCursorBlinkDuration;
- float mCursorWidth; ///< The width of the cursors in pixels.
- HandleType mHandleScrolling; ///< The handle which is scrolling.
- HandleType mHandleReleased; ///< The last handle released.
- ScrollDirection mScrollDirection; ///< The direction of the scroll.
- float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
- float mScrollSpeed; ///< The scroll speed in pixels per second.
- float mScrollDistance; ///< Distance the text scrolls during a scroll interval.
- int mTextDepth; ///< The depth used to render the text.
-
- bool mActiveCopyPastePopup : 1;
- bool mPopupSetNewPosition : 1;
- bool mCursorBlinkStatus : 1; ///< Flag to switch between blink on and blink off.
- bool mDelayCursorBlink : 1; ///< Used to avoid cursor blinking when entering text.
- bool mPrimaryCursorVisible : 1; ///< Whether the primary cursor is visible.
- bool mSecondaryCursorVisible : 1; ///< Whether the secondary cursor is visible.
- bool mFlipSelectionHandlesOnCross : 1; ///< Whether to flip the selection handles as soon as they cross.
- bool mFlipLeftSelectionHandleDirection : 1; ///< Whether to flip the left selection handle image because of the character's direction.
- bool mFlipRightSelectionHandleDirection : 1; ///< Whether to flip the right selection handle image because of the character's direction.
- bool mIsHandlePanning : 1; ///< Whether any of the handles is moving.
- bool mIsHandleCurrentlyCrossed : 1; ///< Whether the handles are crossed.
- bool mIsHandlePreviouslyCrossed : 1; ///< Whether the handles where crossed at the last handle touch up.
- bool mNotifyEndOfScroll : 1; ///< Whether to notify the end of the scroll.
- bool mHorizontalScrollingEnabled : 1; ///< Whether the horizontal scrolling is enabled.
- bool mVerticalScrollingEnabled : 1; ///< Whether the vertical scrolling is enabled.
- bool mSmoothHandlePanEnabled : 1; ///< Whether to pan smoothly the handles.
- bool mIsHighlightBoxActive : 1; ///< Whether the highlight box is active.
- bool mHidePrimaryCursorAndGrabHandle : 1; ///< Whether the primary cursor and grab are hidden always.
+ std::string mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
+ Vector4 mHandleColor;
+
+ CursorImpl mCursor[CURSOR_COUNT];
+ HandleImpl mHandle[HANDLE_TYPE_COUNT];
+
+ VertexBuffer mQuadVertices;
+ Geometry mQuadGeometry;
+ QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight.
+
+ Vector4 mBoundingBox; ///< The bounding box in world coords.
+ Vector4 mHighlightColor; ///< Color of the highlight
+ Vector2 mHighlightPosition; ///< The position of the highlight actor.
+ Size mHighlightSize; ///< The size of the highlighted text.
+ Size mControlSize; ///< The control's size. Set by the Relayout.
+ float mHighlightOutlineOffset; ///< The outline's offset.
+
+ unsigned int mActiveCursor;
+ unsigned int mCursorBlinkInterval;
+ float mCursorBlinkDuration;
+ float mCursorWidth; ///< The width of the cursors in pixels.
+ HandleType mHandleScrolling; ///< The handle which is scrolling.
+ HandleType mHandleReleased; ///< The last handle released.
+ ScrollDirection mScrollDirection; ///< The direction of the scroll.
+ float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
+ float mScrollSpeed; ///< The scroll speed in pixels per second.
+ float mScrollDistance; ///< Distance the text scrolls during a scroll interval.
+ int mTextDepth; ///< The depth used to render the text.
+
+ bool mActiveCopyPastePopup : 1;
+ bool mPopupSetNewPosition : 1;
+ bool mCursorBlinkStatus : 1; ///< Flag to switch between blink on and blink off.
+ bool mDelayCursorBlink : 1; ///< Used to avoid cursor blinking when entering text.
+ bool mPrimaryCursorVisible : 1; ///< Whether the primary cursor is visible.
+ bool mSecondaryCursorVisible : 1; ///< Whether the secondary cursor is visible.
+ bool mFlipSelectionHandlesOnCross : 1; ///< Whether to flip the selection handles as soon as they cross.
+ bool mFlipLeftSelectionHandleDirection : 1; ///< Whether to flip the left selection handle image because of the character's direction.
+ bool mFlipRightSelectionHandleDirection : 1; ///< Whether to flip the right selection handle image because of the character's direction.
+ bool mIsHandlePanning : 1; ///< Whether any of the handles is moving.
+ bool mIsHandleCurrentlyCrossed : 1; ///< Whether the handles are crossed.
+ bool mIsHandlePreviouslyCrossed : 1; ///< Whether the handles where crossed at the last handle touch up.
+ bool mNotifyEndOfScroll : 1; ///< Whether to notify the end of the scroll.
+ bool mHorizontalScrollingEnabled : 1; ///< Whether the horizontal scrolling is enabled.
+ bool mVerticalScrollingEnabled : 1; ///< Whether the vertical scrolling is enabled.
+ bool mSmoothHandlePanEnabled : 1; ///< Whether to pan smoothly the handles.
+ bool mIsHighlightBoxActive : 1; ///< Whether the highlight box is active.
+ bool mHidePrimaryCursorAndGrabHandle : 1; ///< Whether the primary cursor and grab are hidden always.