Fix for Cursor scrolling while FocusUi Change
authorKunal Sinha <kunal.sinha@samsung.com>
Thu, 6 Jun 2013 09:32:47 +0000 (15:02 +0530)
committerKunal Sinha <kunal.sinha@samsung.com>
Thu, 6 Jun 2013 09:32:47 +0000 (15:02 +0530)
Change-Id: I286639973181c8bef67a70cba1174ed02e1dcf0c
Signed-off-by: Kunal Sinha <kunal.sinha@samsung.com>
src/ui/controls/FUiCtrl_TokenEditPresenter.cpp
src/ui/inc/FUiCtrl_TokenEditPresenter.h

index 5718962..f450b93 100644 (file)
@@ -2431,12 +2431,10 @@ _TokenEditPresenter::CheckTokenScrolling(bool scrollToCursorPosition)
        bool needToScroll = false;
        float tokenTopMargin = 0.0f;
        float tokenBottomMargin = 0.0f;
-       float tokenVerticalSpacing = 0.0f;
        _ControlOrientation orientation = __pTokenEdit->GetOrientation();
 
        GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin);
-       GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing);
 
        int tokenCount = GetTokenCount();
        if (tokenCount == 0)        // There is no token to scroll
@@ -4019,16 +4017,19 @@ _TokenEditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
        if (focusChanged)
        {
                StopCursorTimer();
+
                if (__focusedTokenIndex != -1)
                {
                        SetCursorDisabled(true);
+                       ScrollToFocusedToken();
                }
                else
                {
                        SetCursorDisabled(false);
+                       CheckTokenScrolling();
                }
+
                StartCursorTimer();
-               ScrollToFocussedToken();
        }
 
        return _EditPresenter::OnKeyPressed(source, keyInfo);
@@ -4379,20 +4380,26 @@ _TokenEditPresenter::OnAccessibilityFocusOut(const _AccessibilityContainer& cont
 }
 
 result
-_TokenEditPresenter::ScrollToFocussedToken(void)
+_TokenEditPresenter::ScrollToFocusedToken(void)
 {
        result r = E_SUCCESS;
        FloatRectangle focussedTokenRectangle;
        float newScrollValue = 0.0f;
        float tokenTopMargin = 0.0f;
        float tokenBottomMargin = 0.0f;
+       float tokenHeight = 0.0f;
+       float textBoundsAlignValue = 0.0f;
        _ControlOrientation orientation = __pTokenEdit->GetOrientation();
 
 
        GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin);
+       GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight);
 
        FloatRectangle tokenEditRect = __pTokenEdit->GetBoundsF();
+       float textObjectMaxHeight = GetMaxTextHeight();
+       textBoundsAlignValue = (tokenHeight - textObjectMaxHeight) / 2.0f;
+
        if (__focusedTokenIndex == -1)
        {
                //Focus bitmap to be reset when no token is focused.
@@ -4422,7 +4429,7 @@ _TokenEditPresenter::ScrollToFocussedToken(void)
                        else
                        {
                                //Focused token is below the lower boundary
-                               newScrollValue = focussedTokenPosition - tokenEditRect.height + tokenBottomMargin - __scrollValue;
+                               newScrollValue = focussedTokenPosition - textBoundsAlignValue - tokenEditRect.height + tokenBottomMargin - __scrollValue;
                        }
 
                        r = RecalculateTokenBounds(newScrollValue);
index 989f2c7..9df3e97 100644 (file)
@@ -169,7 +169,7 @@ public:
        bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element);
        bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element);
 
-       result ScrollToFocussedToken(void);
+       result ScrollToFocusedToken(void);
        result AttachCursorToToken(void);
        result DetachCursorFromToken(void);
        void ExitTokenEditingMode(void);