fix issue VPSS-795 by modifying ScrollPanel
authorPark Kyoung Hee <kh1979.park@samsung.com>
Wed, 3 Apr 2013 08:47:23 +0000 (17:47 +0900)
committerPark Kyoung Hee <kh1979.park@samsung.com>
Thu, 4 Apr 2013 09:46:35 +0000 (18:46 +0900)
modify core API on ScrollPanel

Change-Id: I49a687a1293606f7919c98d5b21a3cfd9db20765
Signed-off-by: Park Kyoung Hee <kh1979.park@samsung.com>
src/ui/controls/FUiCtrl_ScrollPanel.cpp
src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp
src/ui/inc/FUiCtrl_IScrollableContainer.h
src/ui/inc/FUiCtrl_ScrollPanel.h
src/ui/inc/FUiCtrl_ScrollPanelPresenter.h

index 7e6f8af..d7ba9dd 100644 (file)
@@ -707,6 +707,14 @@ _ScrollPanel::SetScrollPosition(float position, bool withAnimation)
        __pScrollPanelPresenter->SetScrollPosition(position, withAnimation);
 }
 
+void
+_ScrollPanel::SetScrollPosition(Tizen::Graphics::FloatPoint position, bool withAnimation)
+{
+       ClearLastResult();
+
+       __pScrollPanelPresenter->SetScrollPosition(position, withAnimation);
+}
+
 float
 _ScrollPanel::GetScrollPosition(void) const
 {
@@ -748,11 +756,11 @@ _ScrollPanel::SetHorizontalScrollPosition(float position)
 }
 
 bool
-_ScrollPanel::ScrollToControl(const _Control& source)
+_ScrollPanel::ScrollToControl(const _Control& source, bool recursive)
 {
        ClearLastResult();
 
-       return __pScrollPanelPresenter->ScrollToControl(source);
+       return __pScrollPanelPresenter->ScrollToControl(source, recursive);
 }
 
 void
index 5c1b53a..66a7283 100644 (file)
@@ -252,6 +252,19 @@ _ScrollPanelPresenter::OnChildBoundsChanged(const _Control& child)
 }
 
 void
+_ScrollPanelPresenter::SetScrollPosition(FloatPoint position, bool withAnimation)
+{
+       if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
+       {
+               SetScrollPosition(position.x, withAnimation);
+       }
+       else
+       {
+               SetScrollPosition(position.y, withAnimation);
+       }
+}
+
+void
 _ScrollPanelPresenter::SetScrollPosition(float position, bool withAnimation)
 {
        // change scroll position
@@ -1165,7 +1178,7 @@ _ScrollPanelPresenter::ScrollToControlWhenOutOfView(const _Control& control)
 {
        if (IsControlOutOfView(control))
        {
-               ScrollToControl(const_cast<const _Control&>(control));
+               ScrollToControl(control, false);
                result r = GetLastResult();
                SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
        }
@@ -1408,6 +1421,14 @@ _ScrollPanelPresenter::AdjustModel()
                                }
                        }
                }
+
+               if (scrollArea != GetScrollAreaBounds())
+               {
+                       // before change model ScrollPosition fix
+                       RollbackBouncing(false);
+                       result r = GetLastResult();
+                       SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
        }
        else
        {
@@ -1495,37 +1516,43 @@ _ScrollPanelPresenter::AdjustModel()
 }
 
 bool
-_ScrollPanelPresenter::ScrollToControl(const _Control& source)
+_ScrollPanelPresenter::ScrollToControl(const _Control& source, bool recursive)
 {
-       if (__pScrollPanel->GetChildCount() == 0)
-       {
-               SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[%s] ScrollPanel have no child control.", GetErrorMessage(E_INVALID_ARG));
-               return false;
-       }
-
-       int validNum = __pScrollPanel->GetChildIndex(source);
+       SysTryReturn(NID_UI_CTRL, __pScrollPanel->GetChildCount() != 0, false, E_INVALID_ARG, "[%s] ScrollPanel have no child control.", GetErrorMessage(E_INVALID_ARG));
 
-       if (validNum == -1)
+       FloatPoint controlPosition = source.GetPositionF();
+       if (!recursive)
        {
-               SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[%s] source is not a child control.", GetErrorMessage(E_INVALID_ARG));
-               return false;
-       }
-
-       if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
-       {
-               //align source control to left position.
-               SetHorizontalScrollPosition(source.GetBoundsF().x);
-               result r = GetLastResult();
-               SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_UI_CTRL, __pScrollPanel->GetChildIndex(source) != -1, false, E_INVALID_ARG, "[%s] source is not a child control.", GetErrorMessage(E_INVALID_ARG));
        }
        else
        {
-               //align source control to top position.
-               SetVerticalScrollPosition(source.GetBoundsF().y);
-               result r = GetLastResult();
-               SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_UI_CTRL, __pScrollPanel->IsAncestorOf(source), false, E_INVALID_ARG, "[%s] source is not a child control.", GetErrorMessage(E_INVALID_ARG));
+
+               _Control* pParent = source.GetParent();
+               while (pParent != null && pParent != __pScrollPanel)
+               {
+                       _ScrollPanel* pScrollPanelParent = dynamic_cast<_ScrollPanel*> (pParent);
+                       if (pScrollPanelParent != null)
+                       {
+                               pScrollPanelParent->SetScrollPosition(controlPosition, false);
+
+                               controlPosition.x -= pScrollPanelParent->GetHorizontalScrollPosition();
+                               controlPosition.y -= pScrollPanelParent->GetVerticalScrollPosition();
+                       }
+
+                       FloatPoint parentPosition = pParent->GetPositionF();
+                       controlPosition.x += parentPosition.x;
+                       controlPosition.y += parentPosition.y;
+
+                       pParent = pParent->GetParent();
+               }
        }
 
+       SetScrollPosition(controlPosition, true);
+       result r = GetLastResult();
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+
        return true;
 }
 
@@ -1930,8 +1957,8 @@ _ScrollPanelPresenter::SetScrollAreaBounds(FloatRectangle& bounds)
 {
        SysTryReturn(NID_UI_CTRL, !__pScrollPanel->IsScrollAreaAutoResizingEnabled(), E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The width of the client area cannot be set when auto resizing of the client area is off.", GetErrorMessage(E_INVALID_OPERATION));
 
-       bounds.x = 0;
-       bounds.y = 0;
+       bounds.x = 0.0f;
+       bounds.y = 0.0f;
 
        if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
        {
@@ -1944,6 +1971,11 @@ _ScrollPanelPresenter::SetScrollAreaBounds(FloatRectangle& bounds)
                bounds.width = __pScrollPanel->GetBoundsF().width;
        }
 
+       if (bounds == GetScrollAreaBounds())
+       {
+               return E_SUCCESS;
+       }
+
        // before change model ScrollPosition fix
        RollbackBouncing(false);
        result r = GetLastResult();
index 93b0e46..8845a78 100644 (file)
@@ -43,7 +43,7 @@ public:
 
 // Operations
 public:
-       virtual bool ScrollToControl(const _Control& source) = 0;
+       virtual bool ScrollToControl(const _Control& source, bool recursive = false) = 0;
 
 protected:
 //     reserved virtual methods for later extension
index dc619ab..7e47210 100644 (file)
@@ -150,11 +150,12 @@ public:
        void ScrollToRight(void) const;
 
        // scrollable container interface
-       virtual bool ScrollToControl(const _Control& source);
+       virtual bool ScrollToControl(const _Control& source, bool recursive = false);
 
        // Accessor
        float GetScrollPosition(void) const;
        void SetScrollPosition(float position, bool withAnimation = false);
+       void SetScrollPosition(Tizen::Graphics::FloatPoint position, bool withAnimation = false);
 
        // scroll position
        float GetVerticalScrollPosition(void) const;
index 12ef313..98ac1a8 100644 (file)
@@ -122,7 +122,7 @@ public:
        void ScrollToRight(void);
 
        // scrollable container interface
-       bool ScrollToControl(const _Control& source);
+       bool ScrollToControl(const _Control& source, bool recursive);
 
        // Accessor
        bool IsScrollable(void) const;
@@ -138,6 +138,7 @@ public:
 
        // scroll position
        void SetScrollPosition(float position, bool withAnimation);     // sets and move
+       void SetScrollPosition(Tizen::Graphics::FloatPoint position, bool withAnimation);       // sets and move
        float GetScrollPosition(void) const;
 
        float GetVerticalScrollPosition(void) const;