void
_ScrollPanelPresenter::OnChildAttached(const _Control& child)
{
- if (&child != __pScrollPanel->GetVerticalScrollBar()
- && &child != __pScrollPanel->GetHorizontalScrollBar())
+ if (child.GetArea() != _CONTROL_AREA_SYSTEM)
{
if (__pScrollPanel->IsScrollAreaAutoResizingEnabled())
{
void
_ScrollPanelPresenter::OnChildDetached(const _Control& child)
{
- if (&child != __pScrollPanel->GetVerticalScrollBar()
- && &child != __pScrollPanel->GetHorizontalScrollBar())
+ if (child.GetArea() != _CONTROL_AREA_SYSTEM)
{
if (__pScrollPanel->IsScrollAreaAutoResizingEnabled())
{
void
_ScrollPanelPresenter::OnChildBoundsChanged(const _Control& child)
{
- if (&child != __pScrollPanel->GetVerticalScrollBar()
- && &child != __pScrollPanel->GetHorizontalScrollBar())
+ if (child.GetArea() != _CONTROL_AREA_SYSTEM)
{
if (__pScrollPanel->IsScrollAreaAutoResizingEnabled())
{
float
_ScrollPanelPresenter::FixScrollPositionIntoScrollAreaBounds(float position, FloatRectangle bounds, FloatRectangle scrollArea) const
{
- float minScrollPos = 0.0f;
- float maxScrollPos = 0.0f;
+ float minScrollPosition = 0.0f;
+ float maxScrollPosition = 0.0f;
if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
{
- minScrollPos = scrollArea.x;
- maxScrollPos = scrollArea.x + scrollArea.width - bounds.width;
+ minScrollPosition = scrollArea.x;
+ maxScrollPosition = scrollArea.x + scrollArea.width - bounds.width;
}
else
{
- minScrollPos = scrollArea.y;
- maxScrollPos = scrollArea.y + scrollArea.height - bounds.height;
+ minScrollPosition = scrollArea.y;
+ maxScrollPosition = scrollArea.y + scrollArea.height - bounds.height;
+ }
+
+ if (minScrollPosition > maxScrollPosition)
+ {
+ maxScrollPosition = minScrollPosition;
+ }
+ if (position < minScrollPosition)
+ {
+ position = minScrollPosition;
+ }
+ if (position > maxScrollPosition)
+ {
+ position = maxScrollPosition;
}
- position = position < minScrollPos ? minScrollPos : position;
- position = position > maxScrollPos ? maxScrollPos : position;
return position;
}
if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
{
pageSize = __pScrollPanel->GetPageScrollAlignSize().width;
- maxPosition = GetScrollAreaBounds().width - pageSize;
+ maxPosition = GetScrollAreaBounds().width - __pScrollPanel->GetBoundsF().width;
currentPosition = GetHorizontalScrollPosition();
}
else
{
pageSize = __pScrollPanel->GetPageScrollAlignSize().height;
- maxPosition = GetScrollAreaBounds().height - pageSize;
+ maxPosition = GetScrollAreaBounds().height - __pScrollPanel->GetBoundsF().height;
currentPosition = GetVerticalScrollPosition();
}
float targetPosition = 0.0f;
- float pageGap = currentPosition - (((int)(currentPosition / pageSize)) * pageSize);
int lowerPageIndex = currentPosition / pageSize;
float currentPageMin = pageSize * lowerPageIndex;
+ float pageGap = currentPosition - currentPageMin;
float currentPageMax = currentPageMin + pageSize;
- currentPageMin = currentPageMax > maxPosition ? (maxPosition / pageSize) * pageSize : currentPageMin;
- currentPageMax = currentPageMax > maxPosition ? maxPosition : currentPageMax;
+ if (currentPageMax > maxPosition)
+ {
+ currentPageMax = maxPosition;
+ }
if (pageGap <= currentPageMax - currentPageMin - pageGap)
{
if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
{
pageSize = __pScrollPanel->GetPageScrollAlignSize().width;
- maxPosition = scrollArea.width - pageSize;
+ maxPosition = scrollArea.width - scrollPanelBounds.width;
scrollPosition = __pScrollPanelModel->GetCurrentHorizontalScrollPosition();
}
else
{
pageSize = __pScrollPanel->GetPageScrollAlignSize().height;
- maxPosition = scrollArea.height - pageSize;
+ maxPosition = scrollArea.height - scrollPanelBounds.height;
scrollPosition = __pScrollPanelModel->GetCurrentVerticalScrollPosition();
}
- float pageGap = scrollPosition - (((int)(scrollPosition / pageSize)) * pageSize);
int lowerPageIndex = (scrollPosition + moveAmount) / pageSize;
float targetPageMin = pageSize * lowerPageIndex;
+ float pageGap = (scrollPosition + moveAmount) - targetPageMin;
float targetPageMax = targetPageMin + pageSize;
- targetPageMin = targetPageMax > maxPosition ? (maxPosition / pageSize) * pageSize : targetPageMin;
- targetPageMax = targetPageMax > maxPosition ? maxPosition : targetPageMax;
if (pageGap <= targetPageMax - targetPageMin - pageGap)
{
_Control* pControl = __pScrollPanel->GetChild(i);
SysTryReturnVoidResult(NID_UI_CTRL, pControl != null, E_SYSTEM, "[%s] pControl(child) is invalid pointer.", GetErrorMessage(E_SYSTEM));
- if (pControl == pVerticalScrollBar || pControl == pHorizontalScrollBar)
+ if (pControl->GetArea() == _CONTROL_AREA_SYSTEM)
{
continue;
}
float targetMaxPos = pControl->GetBoundsF().GetBottomRight().y;
- scrollArea.height = (scrollArea.height < targetMaxPos) ? targetMaxPos : scrollArea.height;
+ if (scrollArea.height < targetMaxPos)
+ {
+ scrollArea.height = targetMaxPos;
+ }
}
}
else if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
_Control* pControl = __pScrollPanel->GetChild(i);
SysTryReturnVoidResult(NID_UI_CTRL, pControl != null, E_SYSTEM, "[%s] pControl(child) is invalid pointer.", GetErrorMessage(E_SYSTEM));
- if (pControl == pVerticalScrollBar || pControl == pHorizontalScrollBar)
+ if (pControl->GetArea() == _CONTROL_AREA_SYSTEM)
{
continue;
}
float targetMaxPos = pControl->GetBoundsF().GetBottomRight().x;
- scrollArea.width = (scrollArea.width < targetMaxPos) ? targetMaxPos : scrollArea.width;
+ if (scrollArea.width < targetMaxPos)
+ {
+ scrollArea.width = targetMaxPos;
+ }
}
}
}
scrollArea = GetScrollAreaBounds();
if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL)
{
- scrollArea.width = scrollArea.width < scrollPanelBounds.width ? scrollPanelBounds.width : scrollArea.width;
+ if (scrollArea.width < scrollPanelBounds.width)
+ {
+ scrollArea.width = scrollPanelBounds.width;
+ }
scrollArea.height = scrollPanelBounds.height;
}
else
{
scrollArea.width = scrollPanelBounds.width;
- scrollArea.height = scrollArea.height < scrollPanelBounds.height ? scrollPanelBounds.height : scrollArea.height;
+ if (scrollArea.height < scrollPanelBounds.height)
+ {
+ scrollArea.height = scrollPanelBounds.height;
+ }
}
}