}
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
{
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));
}
}
}
}
+
+ 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
{
}
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;
}
{
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)
{
bounds.width = __pScrollPanel->GetBoundsF().width;
}
+ if (bounds == GetScrollAreaBounds())
+ {
+ return E_SUCCESS;
+ }
+
// before change model ScrollPosition fix
RollbackBouncing(false);
result r = GetLastResult();