X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fdecorator%2Ftext-decorator.cpp;h=c586debcf371a9a21285b5b91a42adcf2c6e82cc;hb=00758f1301dd0bfbf6dc87659a6db9d0ba2c6816;hp=237649a4e4340b587bfa20b6f0ca3514bff9e0c5;hpb=f2039d47f9bed8104575da80a2ecf0bb6e37ff8d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 237649a..c586deb 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -971,10 +971,7 @@ struct Decorator::Impl : public ConnectionTracker // The SetGrabHandleImage() method will change the orientation. const float yLocalPosition = grabHandle.verticallyFlipped ? grabHandle.position.y : grabHandle.position.y + grabHandle.lineHeight; - if(grabHandle.actor) - { - grabHandle.actor.SetProperty(Actor::Property::POSITION, Vector2(grabHandle.position.x + floor(0.5f * mCursorWidth) + (mSmoothHandlePanEnabled ? grabHandle.grabDisplacementX : 0.f), yLocalPosition + (mSmoothHandlePanEnabled ? grabHandle.grabDisplacementY : 0.f))); - } + ApplyDisplacement(grabHandle, yLocalPosition); } void SetSelectionHandlePosition(HandleType type) @@ -1063,10 +1060,47 @@ struct Decorator::Impl : public ConnectionTracker // The SetHandleImage() method will change the orientation. const float yLocalPosition = handle.verticallyFlipped ? handle.position.y : handle.position.y + handle.lineHeight; - if(handle.actor) + ApplyDisplacement(handle, yLocalPosition); + } + + void ApplyDisplacement(HandleImpl& handle, float yLocalPosition) + { + if( handle.actor ) + { + 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 { - handle.actor.SetProperty(Actor::Property::POSITION, Vector2(handle.position.x + (mSmoothHandlePanEnabled ? handle.grabDisplacementX : 0.f), yLocalPosition + (mSmoothHandlePanEnabled ? handle.grabDisplacementY : 0.f))); + // move normally in the displacement. + adjustedDisplacement = displacement; } + return adjustedDisplacement; } void SetHandleImage(HandleType type)