From 3adcf1651bcf015c4d8812453f951faeebfda1e5 Mon Sep 17 00:00:00 2001 From: Park Kyoung Hee Date: Wed, 3 Apr 2013 17:47:23 +0900 Subject: [PATCH] fix issue VPSS-795 by modifying ScrollPanel modify core API on ScrollPanel Change-Id: I49a687a1293606f7919c98d5b21a3cfd9db20765 Signed-off-by: Park Kyoung Hee --- src/ui/controls/FUiCtrl_ScrollPanel.cpp | 12 +++- src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp | 84 ++++++++++++++++-------- src/ui/inc/FUiCtrl_IScrollableContainer.h | 2 +- src/ui/inc/FUiCtrl_ScrollPanel.h | 3 +- src/ui/inc/FUiCtrl_ScrollPanelPresenter.h | 3 +- 5 files changed, 73 insertions(+), 31 deletions(-) diff --git a/src/ui/controls/FUiCtrl_ScrollPanel.cpp b/src/ui/controls/FUiCtrl_ScrollPanel.cpp index 7e6f8af..d7ba9dd 100644 --- a/src/ui/controls/FUiCtrl_ScrollPanel.cpp +++ b/src/ui/controls/FUiCtrl_ScrollPanel.cpp @@ -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 diff --git a/src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp b/src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp index 5c1b53a..66a7283 100644 --- a/src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp +++ b/src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp @@ -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(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(); diff --git a/src/ui/inc/FUiCtrl_IScrollableContainer.h b/src/ui/inc/FUiCtrl_IScrollableContainer.h index 93b0e46..8845a78 100644 --- a/src/ui/inc/FUiCtrl_IScrollableContainer.h +++ b/src/ui/inc/FUiCtrl_IScrollableContainer.h @@ -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 diff --git a/src/ui/inc/FUiCtrl_ScrollPanel.h b/src/ui/inc/FUiCtrl_ScrollPanel.h index dc619ab..7e47210 100644 --- a/src/ui/inc/FUiCtrl_ScrollPanel.h +++ b/src/ui/inc/FUiCtrl_ScrollPanel.h @@ -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; diff --git a/src/ui/inc/FUiCtrl_ScrollPanelPresenter.h b/src/ui/inc/FUiCtrl_ScrollPanelPresenter.h index 12ef313..98ac1a8 100644 --- a/src/ui/inc/FUiCtrl_ScrollPanelPresenter.h +++ b/src/ui/inc/FUiCtrl_ScrollPanelPresenter.h @@ -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; -- 2.7.4