Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mayaswell make m_cursor and m_offset private so that invalidation is …

…ensured
  • Loading branch information...
commit 4b3092cfd420fcc446a27acd389e2f08e6374f50 1 parent 6f7c3dc
Jonathan Marshall authored
View
44 xbmc/guilib/GUIBaseContainer.cpp
@@ -100,7 +100,7 @@ void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirt
// we offset our draw position to take into account scrolling and whether or not our focused
// item is offscreen "above" the list.
float drawOffset = (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scrollOffset;
- if (m_offset + m_cursor < offset)
+ if (GetOffset() + GetCursor() < offset)
drawOffset += m_focusedLayout->Size(m_orientation) - m_layout->Size(m_orientation);
pos += drawOffset;
end += cacheAfter * m_layout->Size(m_orientation);
@@ -111,7 +111,7 @@ void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirt
int itemNo = CorrectOffset(current, 0);
if (itemNo >= (int)m_items.size())
break;
- bool focused = (current == m_offset + m_cursor);
+ bool focused = (current == GetOffset() + GetCursor());
if (itemNo >= 0)
{
CGUIListItemPtr item = m_items[itemNo];
@@ -201,7 +201,7 @@ void CGUIBaseContainer::Render()
// we offset our draw position to take into account scrolling and whether or not our focused
// item is offscreen "above" the list.
float drawOffset = (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scrollOffset;
- if (m_offset + m_cursor < offset)
+ if (GetOffset() + GetCursor() < offset)
drawOffset += m_focusedLayout->Size(m_orientation) - m_layout->Size(m_orientation);
pos += drawOffset;
end += cacheAfter * m_layout->Size(m_orientation);
@@ -214,7 +214,7 @@ void CGUIBaseContainer::Render()
int itemNo = CorrectOffset(current, 0);
if (itemNo >= (int)m_items.size())
break;
- bool focused = (current == m_offset + m_cursor);
+ bool focused = (current == GetOffset() + GetCursor());
if (itemNo >= 0)
{
CGUIListItemPtr item = m_items[itemNo];
@@ -397,7 +397,7 @@ bool CGUIBaseContainer::OnMessage(CGUIMessage& message)
{
if (message.GetSenderId() == m_pageControl && IsVisible())
{ // update our page if we're visible - not much point otherwise
- if ((int)message.GetParam1() != m_offset)
+ if ((int)message.GetParam1() != GetOffset())
m_pageChangeTimer.StartZero();
ScrollToOffset(message.GetParam1());
return true;
@@ -475,7 +475,7 @@ void CGUIBaseContainer::OnRight()
void CGUIBaseContainer::OnNextLetter()
{
- int offset = CorrectOffset(m_offset, m_cursor);
+ int offset = CorrectOffset(GetOffset(), GetCursor());
for (unsigned int i = 0; i < m_letterOffsets.size(); i++)
{
if (m_letterOffsets[i].first > offset)
@@ -488,7 +488,7 @@ void CGUIBaseContainer::OnNextLetter()
void CGUIBaseContainer::OnPrevLetter()
{
- int offset = CorrectOffset(m_offset, m_cursor);
+ int offset = CorrectOffset(GetOffset(), GetCursor());
if (!m_letterOffsets.size())
return;
for (int i = (int)m_letterOffsets.size() - 1; i >= 0; i--)
@@ -515,7 +515,7 @@ void CGUIBaseContainer::OnJumpLetter(char letter)
return;
// find the current letter we're focused on
- unsigned int offset = CorrectOffset(m_offset, m_cursor);
+ unsigned int offset = CorrectOffset(GetOffset(), GetCursor());
for (unsigned int i = (offset + 1) % m_items.size(); i != offset; i = (i+1) % m_items.size())
{
CGUIListItemPtr item = m_items[i];
@@ -543,7 +543,7 @@ void CGUIBaseContainer::OnJumpSMS(int letter)
const CStdString letters = letterMap[letter - 2];
// find where we currently are
- int offset = CorrectOffset(m_offset, m_cursor);
+ int offset = CorrectOffset(GetOffset(), GetCursor());
unsigned int currentLetter = 0;
while (currentLetter + 1 < m_letterOffsets.size() && m_letterOffsets[currentLetter + 1].first <= offset)
currentLetter++;
@@ -583,12 +583,12 @@ bool CGUIBaseContainer::MoveDown(bool wrapAround)
// scrolls the said amount
void CGUIBaseContainer::Scroll(int amount)
{
- ScrollToOffset(m_offset + amount);
+ ScrollToOffset(GetOffset() + amount);
}
int CGUIBaseContainer::GetSelectedItem() const
{
- return CorrectOffset(m_offset, m_cursor);
+ return CorrectOffset(GetOffset(), GetCursor());
}
CGUIListItemPtr CGUIBaseContainer::GetListItem(int offset, unsigned int flag) const
@@ -871,7 +871,7 @@ void CGUIBaseContainer::CalculateLayout()
m_itemsPerPage = (int)((Size() - m_focusedLayout->Size(m_orientation)) / m_layout->Size(m_orientation)) + 1;
// ensure that the scroll offset is a multiple of our size
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
+ m_scrollOffset = GetOffset() * m_layout->Size(m_orientation);
}
void CGUIBaseContainer::UpdateScrollByLetter()
@@ -923,7 +923,7 @@ void CGUIBaseContainer::ScrollToOffset(int offset)
m_scrollSpeed = (offset * size - m_scrollOffset) / m_scrollTime;
if (!m_wasReset)
{
- SetContainerMoving(offset - m_offset);
+ SetContainerMoving(offset - GetOffset());
if (m_scrollSpeed)
m_scrollTimer.Start();
else
@@ -943,10 +943,10 @@ void CGUIBaseContainer::UpdateScrollOffset(unsigned int currentTime)
if (m_scrollSpeed)
MarkDirtyRegion();
m_scrollOffset += m_scrollSpeed * (currentTime - m_scrollLastTime);
- if ((m_scrollSpeed < 0 && m_scrollOffset < m_offset * m_layout->Size(m_orientation)) ||
- (m_scrollSpeed > 0 && m_scrollOffset > m_offset * m_layout->Size(m_orientation)))
+ if ((m_scrollSpeed < 0 && m_scrollOffset < GetOffset() * m_layout->Size(m_orientation)) ||
+ (m_scrollSpeed > 0 && m_scrollOffset > GetOffset() * m_layout->Size(m_orientation)))
{
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
+ m_scrollOffset = GetOffset() * m_layout->Size(m_orientation);
m_scrollSpeed = 0;
m_scrollTimer.Stop();
}
@@ -1068,11 +1068,11 @@ bool CGUIBaseContainer::GetCondition(int condition, int data) const
switch (condition)
{
case CONTAINER_ROW:
- return (m_orientation == VERTICAL) ? (m_cursor == data) : true;
+ return (m_orientation == VERTICAL) ? (GetCursor() == data) : true;
case CONTAINER_COLUMN:
- return (m_orientation == HORIZONTAL) ? (m_cursor == data) : true;
+ return (m_orientation == HORIZONTAL) ? (GetCursor() == data) : true;
case CONTAINER_POSITION:
- return (m_cursor == data);
+ return (GetCursor() == data);
case CONTAINER_HAS_NEXT:
return (HasNextPage());
case CONTAINER_HAS_PREVIOUS:
@@ -1140,7 +1140,7 @@ CStdString CGUIBaseContainer::GetLabel(int info) const
label.Format("%u", GetCurrentPage());
break;
case CONTAINER_POSITION:
- label.Format("%i", m_cursor);
+ label.Format("%i", GetCursor());
break;
case CONTAINER_NUM_ITEMS:
{
@@ -1159,9 +1159,9 @@ CStdString CGUIBaseContainer::GetLabel(int info) const
int CGUIBaseContainer::GetCurrentPage() const
{
- if (m_offset + m_itemsPerPage >= (int)GetRows()) // last page
+ if (GetOffset() + m_itemsPerPage >= (int)GetRows()) // last page
return (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage;
- return m_offset / m_itemsPerPage + 1;
+ return GetOffset() / m_itemsPerPage + 1;
}
void CGUIBaseContainer::GetCacheOffsets(int &cacheBefore, int &cacheAfter)
View
7 xbmc/guilib/GUIBaseContainer.h
@@ -129,8 +129,6 @@ class CGUIBaseContainer : public CGUIControl
CPoint m_renderOffset; ///< \brief render offset of the first item in the list \sa SetRenderOffset
- int m_offset;
- int m_cursor;
float m_analogScrollCount;
unsigned int m_lastHoldTime;
@@ -183,13 +181,18 @@ class CGUIBaseContainer : public CGUIControl
this also marks the control as dirty (if needed)
*/
virtual void SetCursor(int cursor);
+ inline int GetCursor() const { return m_cursor; };
/*! \brief Set the container offset
Should be used by all base classes rather than directly setting it, as
this also marks the control as dirty (if needed)
*/
void SetOffset(int offset);
+ inline int GetOffset() const { return m_offset; };
+
private:
+ int m_cursor;
+ int m_offset;
int m_cacheItems;
float m_scrollSpeed;
CStopWatch m_scrollTimer;
View
40 xbmc/guilib/GUIFixedListContainer.cpp
@@ -119,7 +119,7 @@ void CGUIFixedListContainer::Scroll(int amount)
// increase or decrease the offset within [-minCursor, m_items.size() - maxCursor]
int minCursor, maxCursor;
GetCursorRange(minCursor, maxCursor);
- int offset = m_offset + amount;
+ int offset = GetOffset() + amount;
if (offset < -minCursor)
{
offset = -minCursor;
@@ -145,18 +145,18 @@ void CGUIFixedListContainer::ValidateOffset()
int minCursor, maxCursor;
GetCursorRange(minCursor, maxCursor);
// assure our cursor is between these limits
- SetCursor(std::max(m_cursor, minCursor));
- SetCursor(std::min(m_cursor, maxCursor));
+ SetCursor(std::max(GetCursor(), minCursor));
+ SetCursor(std::min(GetCursor(), maxCursor));
// and finally ensure our offset is valid
- if (m_offset + maxCursor >= (int)m_items.size() || m_scrollOffset > ((int)m_items.size() - maxCursor - 1) * m_layout->Size(m_orientation))
+ if (GetOffset() + maxCursor >= (int)m_items.size() || m_scrollOffset > ((int)m_items.size() - maxCursor - 1) * m_layout->Size(m_orientation))
{
SetOffset(std::max(-minCursor, (int)m_items.size() - maxCursor - 1));
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
+ m_scrollOffset = GetOffset() * m_layout->Size(m_orientation);
}
- if (m_offset < -minCursor || m_scrollOffset < -minCursor * m_layout->Size(m_orientation))
+ if (GetOffset() < -minCursor || m_scrollOffset < -minCursor * m_layout->Size(m_orientation))
{
SetOffset(-minCursor);
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
+ m_scrollOffset = GetOffset() * m_layout->Size(m_orientation);
}
}
@@ -175,7 +175,7 @@ int CGUIFixedListContainer::GetCursorFromPoint(const CPoint &point, CPoint *item
pos -= minCursor * m_layout->Size(m_orientation);
for (int row = minCursor; row <= maxCursor; row++)
{
- const CGUIListItemLayout *layout = (row == m_cursor) ? m_focusedLayout : m_layout;
+ const CGUIListItemLayout *layout = (row == GetCursor()) ? m_focusedLayout : m_layout;
if (pos < layout->Size(m_orientation))
{
if (!InsideLayout(layout, point))
@@ -202,7 +202,7 @@ bool CGUIFixedListContainer::SelectItemFromPoint(const CPoint &point)
float start = (minCursor + 0.2f) * sizeOfItem;
float end = (maxCursor - 0.2f) * sizeOfItem + m_focusedLayout->Size(m_orientation);
float pos = (m_orientation == VERTICAL) ? point.y : point.x;
- if (pos < start && m_offset > -minCursor)
+ if (pos < start && GetOffset() > -minCursor)
{ // scroll backward
if (!InsideLayout(m_layout, point))
return false;
@@ -210,12 +210,12 @@ bool CGUIFixedListContainer::SelectItemFromPoint(const CPoint &point)
m_analogScrollCount += amount * amount * mouse_scroll_speed;
if (m_analogScrollCount > 1)
{
- ScrollToOffset(m_offset - 1);
+ ScrollToOffset(GetOffset() - 1);
m_analogScrollCount = 0;
}
return true;
}
- else if (pos > end && m_offset + maxCursor < (int)m_items.size() - 1)
+ else if (pos > end && GetOffset() + maxCursor < (int)m_items.size() - 1)
{
if (!InsideLayout(m_layout, point))
return false;
@@ -224,7 +224,7 @@ bool CGUIFixedListContainer::SelectItemFromPoint(const CPoint &point)
m_analogScrollCount += amount * amount * mouse_scroll_speed;
if (m_analogScrollCount > 1)
{
- ScrollToOffset(m_offset + 1);
+ ScrollToOffset(GetOffset() + 1);
m_analogScrollCount = 0;
}
return true;
@@ -243,7 +243,7 @@ bool CGUIFixedListContainer::SelectItemFromPoint(const CPoint &point)
void CGUIFixedListContainer::SelectItem(int item)
{
- // Check that m_offset is valid
+ // Check that GetOffset() is valid
ValidateOffset();
// only select an item if it's in a valid range
if (item >= 0 && item < (int)m_items.size())
@@ -260,27 +260,27 @@ void CGUIFixedListContainer::SelectItem(int item)
cursor = std::min(m_fixedCursor, minCursor + item);
else
cursor = m_fixedCursor;
- if (cursor != m_cursor)
- SetContainerMoving(cursor - m_cursor);
+ if (cursor != GetCursor())
+ SetContainerMoving(cursor - GetCursor());
SetCursor(cursor);
- ScrollToOffset(item - m_cursor);
+ ScrollToOffset(item - GetCursor());
}
}
bool CGUIFixedListContainer::HasPreviousPage() const
{
- return (m_offset > 0);
+ return (GetOffset() > 0);
}
bool CGUIFixedListContainer::HasNextPage() const
{
- return (m_offset != (int)m_items.size() - m_itemsPerPage && (int)m_items.size() >= m_itemsPerPage);
+ return (GetOffset() != (int)m_items.size() - m_itemsPerPage && (int)m_items.size() >= m_itemsPerPage);
}
int CGUIFixedListContainer::GetCurrentPage() const
{
- int offset = CorrectOffset(m_offset, m_cursor);
- if (offset + m_itemsPerPage - m_cursor >= (int)GetRows()) // last page
+ int offset = CorrectOffset(GetOffset(), GetCursor());
+ if (offset + m_itemsPerPage - GetCursor() >= (int)GetRows()) // last page
return (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage;
return offset / m_itemsPerPage + 1;
}
View
68 xbmc/guilib/GUIListContainer.cpp
@@ -41,7 +41,7 @@ bool CGUIListContainer::OnAction(const CAction &action)
{
case ACTION_PAGE_UP:
{
- if (m_offset == 0)
+ if (GetOffset() == 0)
{ // already on the first page, so move to the first item
SetCursor(0);
}
@@ -54,9 +54,9 @@ bool CGUIListContainer::OnAction(const CAction &action)
break;
case ACTION_PAGE_DOWN:
{
- if (m_offset == (int)m_items.size() - m_itemsPerPage || (int)m_items.size() < m_itemsPerPage)
+ if (GetOffset() == (int)m_items.size() - m_itemsPerPage || (int)m_items.size() < m_itemsPerPage)
{ // already at the last page, so move to the last item.
- SetCursor(m_items.size() - m_offset - 1);
+ SetCursor(m_items.size() - GetOffset() - 1);
}
else
{ // scroll down to the next page
@@ -74,13 +74,13 @@ bool CGUIListContainer::OnAction(const CAction &action)
{
handled = true;
m_analogScrollCount -= 0.4f;
- if (m_offset > 0 && m_cursor <= m_itemsPerPage / 2)
+ if (GetOffset() > 0 && GetCursor() <= m_itemsPerPage / 2)
{
Scroll(-1);
}
- else if (m_cursor > 0)
+ else if (GetCursor() > 0)
{
- SetCursor(m_cursor - 1);
+ SetCursor(GetCursor() - 1);
}
}
return handled;
@@ -94,13 +94,13 @@ bool CGUIListContainer::OnAction(const CAction &action)
{
handled = true;
m_analogScrollCount -= 0.4f;
- if (m_offset + m_itemsPerPage < (int)m_items.size() && m_cursor >= m_itemsPerPage / 2)
+ if (GetOffset() + m_itemsPerPage < (int)m_items.size() && GetCursor() >= m_itemsPerPage / 2)
{
Scroll(1);
}
- else if (m_cursor < m_itemsPerPage - 1 && m_offset + m_cursor < (int)m_items.size() - 1)
+ else if (GetCursor() < m_itemsPerPage - 1 && GetOffset() + GetCursor() < (int)m_items.size() - 1)
{
- SetCursor(m_cursor + 1);
+ SetCursor(GetCursor() + 1);
}
}
return handled;
@@ -122,7 +122,7 @@ bool CGUIListContainer::OnMessage(CGUIMessage& message)
{
if (message.GetParam1()) // subfocus item is specified, so set the offset appropriately
{
- int item = std::min(m_offset + (int)message.GetParam1() - 1, (int)m_items.size() - 1);
+ int item = std::min(GetOffset() + (int)message.GetParam1() - 1, (int)m_items.size() - 1);
SelectItem(item);
}
}
@@ -132,13 +132,13 @@ bool CGUIListContainer::OnMessage(CGUIMessage& message)
bool CGUIListContainer::MoveUp(bool wrapAround)
{
- if (m_cursor > 0)
+ if (GetCursor() > 0)
{
- SetCursor(m_cursor - 1);
+ SetCursor(GetCursor() - 1);
}
- else if (m_cursor == 0 && m_offset)
+ else if (GetCursor() == 0 && GetOffset())
{
- ScrollToOffset(m_offset - 1);
+ ScrollToOffset(GetOffset() - 1);
}
else if (wrapAround)
{
@@ -158,15 +158,15 @@ bool CGUIListContainer::MoveUp(bool wrapAround)
bool CGUIListContainer::MoveDown(bool wrapAround)
{
- if (m_offset + m_cursor + 1 < (int)m_items.size())
+ if (GetOffset() + GetCursor() + 1 < (int)m_items.size())
{
- if (m_cursor + 1 < m_itemsPerPage)
+ if (GetCursor() + 1 < m_itemsPerPage)
{
- SetCursor(m_cursor + 1);
+ SetCursor(GetCursor() + 1);
}
else
{
- ScrollToOffset(m_offset + 1);
+ ScrollToOffset(GetOffset() + 1);
}
}
else if(wrapAround)
@@ -184,7 +184,7 @@ bool CGUIListContainer::MoveDown(bool wrapAround)
void CGUIListContainer::Scroll(int amount)
{
// increase or decrease the offset
- int offset = m_offset + amount;
+ int offset = GetOffset() + amount;
if (offset > (int)m_items.size() - m_itemsPerPage)
{
offset = m_items.size() - m_itemsPerPage;
@@ -194,14 +194,14 @@ void CGUIListContainer::Scroll(int amount)
}
void CGUIListContainer::ValidateOffset()
-{ // first thing is we check the range of m_offset
+{ // first thing is we check the range of our offset
if (!m_layout) return;
- if (m_offset > (int)m_items.size() - m_itemsPerPage || m_scrollOffset > ((int)m_items.size() - m_itemsPerPage) * m_layout->Size(m_orientation))
+ if (GetOffset() > (int)m_items.size() - m_itemsPerPage || m_scrollOffset > ((int)m_items.size() - m_itemsPerPage) * m_layout->Size(m_orientation))
{
SetOffset(std::max(0, (int)m_items.size() - m_itemsPerPage));
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
+ m_scrollOffset = GetOffset() * m_layout->Size(m_orientation);
}
- if (m_offset < 0 || m_scrollOffset < 0)
+ if (GetOffset() < 0 || m_scrollOffset < 0)
{
SetOffset(0);
m_scrollOffset = 0;
@@ -213,31 +213,31 @@ void CGUIListContainer::SetCursor(int cursor)
if (cursor > m_itemsPerPage - 1) cursor = m_itemsPerPage - 1;
if (cursor < 0) cursor = 0;
if (!m_wasReset)
- SetContainerMoving(cursor - m_cursor);
+ SetContainerMoving(cursor - GetCursor());
CGUIBaseContainer::SetCursor(cursor);
}
void CGUIListContainer::SelectItem(int item)
{
- // Check that m_offset is valid
+ // Check that our offset is valid
ValidateOffset();
// only select an item if it's in a valid range
if (item >= 0 && item < (int)m_items.size())
{
// Select the item requested
- if (item >= m_offset && item < m_offset + m_itemsPerPage)
+ if (item >= GetOffset() && item < GetOffset() + m_itemsPerPage)
{ // the item is on the current page, so don't change it.
- SetCursor(item - m_offset);
+ SetCursor(item - GetOffset());
}
- else if (item < m_offset)
+ else if (item < GetOffset())
{ // item is on a previous page - make it the first item on the page
SetCursor(0);
ScrollToOffset(item);
}
- else // (item >= m_offset+m_itemsPerPage)
+ else // (item >= GetOffset()+m_itemsPerPage)
{ // item is on a later page - make it the last item on the page
SetCursor(m_itemsPerPage - 1);
- ScrollToOffset(item - m_cursor);
+ ScrollToOffset(item - GetCursor());
}
}
}
@@ -251,8 +251,8 @@ int CGUIListContainer::GetCursorFromPoint(const CPoint &point, CPoint *itemPoint
float pos = (m_orientation == VERTICAL) ? point.y : point.x;
while (row < m_itemsPerPage + 1) // 1 more to ensure we get the (possible) half item at the end.
{
- const CGUIListItemLayout *layout = (row == m_cursor) ? m_focusedLayout : m_layout;
- if (pos < layout->Size(m_orientation) && row + m_offset < (int)m_items.size())
+ const CGUIListItemLayout *layout = (row == GetCursor()) ? m_focusedLayout : m_layout;
+ if (pos < layout->Size(m_orientation) && row + GetOffset() < (int)m_items.size())
{ // found correct "row" -> check horizontal
if (!InsideLayout(layout, point))
return -1;
@@ -304,10 +304,10 @@ CGUIListContainer::CGUIListContainer(int parentID, int controlID, float posX, fl
bool CGUIListContainer::HasNextPage() const
{
- return (m_offset != (int)m_items.size() - m_itemsPerPage && (int)m_items.size() >= m_itemsPerPage);
+ return (GetOffset() != (int)m_items.size() - m_itemsPerPage && (int)m_items.size() >= m_itemsPerPage);
}
bool CGUIListContainer::HasPreviousPage() const
{
- return (m_offset > 0);
+ return (GetOffset() > 0);
}
View
108 xbmc/guilib/GUIPanelContainer.cpp
@@ -72,7 +72,7 @@ void CGUIPanelContainer::Process(unsigned int currentTime, CDirtyRegionList &dir
if (current >= 0)
{
CGUIListItemPtr item = m_items[current];
- bool focused = (current == m_offset * m_itemsPerRow + m_cursor) && m_bHasFocus;
+ bool focused = (current == GetOffset() * m_itemsPerRow + GetCursor()) && m_bHasFocus;
if (m_orientation == VERTICAL)
ProcessItem(origin.x + col * m_layout->Size(HORIZONTAL), pos, item.get(), focused, currentTime, dirtyregions);
@@ -127,7 +127,7 @@ void CGUIPanelContainer::Render()
if (current >= 0)
{
CGUIListItemPtr item = m_items[current];
- bool focused = (current == m_offset * m_itemsPerRow + m_cursor) && m_bHasFocus;
+ bool focused = (current == GetOffset() * m_itemsPerRow + GetCursor()) && m_bHasFocus;
// render our item
if (focused)
{
@@ -173,7 +173,7 @@ bool CGUIPanelContainer::OnAction(const CAction &action)
{
case ACTION_PAGE_UP:
{
- if (m_offset == 0)
+ if (GetOffset() == 0)
{ // already on the first page, so move to the first item
SetCursor(0);
}
@@ -186,9 +186,9 @@ bool CGUIPanelContainer::OnAction(const CAction &action)
break;
case ACTION_PAGE_DOWN:
{
- if ((m_offset + m_itemsPerPage) * m_itemsPerRow >= (int)m_items.size() || (int)m_items.size() < m_itemsPerPage)
+ if ((GetOffset() + m_itemsPerPage) * m_itemsPerRow >= (int)m_items.size() || (int)m_items.size() < m_itemsPerPage)
{ // already at the last page, so move to the last item.
- SetCursor(m_items.size() - m_offset * m_itemsPerRow - 1);
+ SetCursor(m_items.size() - GetOffset() * m_itemsPerRow - 1);
}
else
{ // scroll down to the next page
@@ -206,13 +206,13 @@ bool CGUIPanelContainer::OnAction(const CAction &action)
{
handled = true;
m_analogScrollCount -= AnalogScrollSpeed();
- if (m_offset > 0)// && m_cursor <= m_itemsPerPage * m_itemsPerRow / 2)
+ if (GetOffset() > 0)// && GetCursor() <= m_itemsPerPage * m_itemsPerRow / 2)
{
Scroll(-1);
}
- else if (m_cursor > 0)
+ else if (GetCursor() > 0)
{
- SetCursor(m_cursor - 1);
+ SetCursor(GetCursor() - 1);
}
}
return handled;
@@ -226,13 +226,13 @@ bool CGUIPanelContainer::OnAction(const CAction &action)
{
handled = true;
m_analogScrollCount -= AnalogScrollSpeed();
- if ((m_offset + m_itemsPerPage) * m_itemsPerRow < (int)m_items.size())// && m_cursor >= m_itemsPerPage * m_itemsPerRow / 2)
+ if ((GetOffset() + m_itemsPerPage) * m_itemsPerRow < (int)m_items.size())// && GetCursor() >= m_itemsPerPage * m_itemsPerRow / 2)
{
Scroll(1);
}
- else if (m_cursor < m_itemsPerPage * m_itemsPerRow - 1 && m_offset * m_itemsPerRow + m_cursor < (int)m_items.size() - 1)
+ else if (GetCursor() < m_itemsPerPage * m_itemsPerRow - 1 && GetOffset() * m_itemsPerRow + GetCursor() < (int)m_items.size() - 1)
{
- SetCursor(m_cursor + 1);
+ SetCursor(GetCursor() + 1);
}
}
return handled;
@@ -297,22 +297,22 @@ void CGUIPanelContainer::OnDown()
bool CGUIPanelContainer::MoveDown(bool wrapAround)
{
- if (m_cursor + m_itemsPerRow < m_itemsPerPage * m_itemsPerRow && (m_offset + 1 + m_cursor / m_itemsPerRow) * m_itemsPerRow < (int)m_items.size())
+ if (GetCursor() + m_itemsPerRow < m_itemsPerPage * m_itemsPerRow && (GetOffset() + 1 + GetCursor() / m_itemsPerRow) * m_itemsPerRow < (int)m_items.size())
{ // move to last item if necessary
- if ((m_offset + 1)*m_itemsPerRow + m_cursor >= (int)m_items.size())
- SetCursor((int)m_items.size() - 1 - m_offset*m_itemsPerRow);
+ if ((GetOffset() + 1)*m_itemsPerRow + GetCursor() >= (int)m_items.size())
+ SetCursor((int)m_items.size() - 1 - GetOffset()*m_itemsPerRow);
else
- SetCursor(m_cursor + m_itemsPerRow);
+ SetCursor(GetCursor() + m_itemsPerRow);
}
- else if ((m_offset + 1 + m_cursor / m_itemsPerRow) * m_itemsPerRow < (int)m_items.size())
+ else if ((GetOffset() + 1 + GetCursor() / m_itemsPerRow) * m_itemsPerRow < (int)m_items.size())
{ // we scroll to the next row, and move to last item if necessary
- if ((m_offset + 1)*m_itemsPerRow + m_cursor >= (int)m_items.size())
- SetCursor((int)m_items.size() - 1 - (m_offset + 1)*m_itemsPerRow);
- ScrollToOffset(m_offset + 1);
+ if ((GetOffset() + 1)*m_itemsPerRow + GetCursor() >= (int)m_items.size())
+ SetCursor((int)m_items.size() - 1 - (GetOffset() + 1)*m_itemsPerRow);
+ ScrollToOffset(GetOffset() + 1);
}
else if (wrapAround)
{ // move first item in list
- SetCursor(m_cursor % m_itemsPerRow);
+ SetCursor(GetCursor() % m_itemsPerRow);
ScrollToOffset(0);
SetContainerMoving(1);
}
@@ -323,16 +323,16 @@ bool CGUIPanelContainer::MoveDown(bool wrapAround)
bool CGUIPanelContainer::MoveUp(bool wrapAround)
{
- if (m_cursor >= m_itemsPerRow)
- SetCursor(m_cursor - m_itemsPerRow);
- else if (m_offset > 0)
- ScrollToOffset(m_offset - 1);
+ if (GetCursor() >= m_itemsPerRow)
+ SetCursor(GetCursor() - m_itemsPerRow);
+ else if (GetOffset() > 0)
+ ScrollToOffset(GetOffset() - 1);
else if (wrapAround)
{ // move last item in list in this column
- SetCursor((m_cursor % m_itemsPerRow) + (m_itemsPerPage - 1) * m_itemsPerRow);
+ SetCursor((GetCursor() % m_itemsPerRow) + (m_itemsPerPage - 1) * m_itemsPerRow);
int offset = max((int)GetRows() - m_itemsPerPage, 0);
// should check here whether cursor is actually allowed here, and reduce accordingly
- if (offset * m_itemsPerRow + m_cursor >= (int)m_items.size())
+ if (offset * m_itemsPerRow + GetCursor() >= (int)m_items.size())
SetCursor((int)m_items.size() - offset * m_itemsPerRow - 1);
ScrollToOffset(offset);
SetContainerMoving(-1);
@@ -344,14 +344,14 @@ bool CGUIPanelContainer::MoveUp(bool wrapAround)
bool CGUIPanelContainer::MoveLeft(bool wrapAround)
{
- int col = m_cursor % m_itemsPerRow;
+ int col = GetCursor() % m_itemsPerRow;
if (col > 0)
- SetCursor(m_cursor - 1);
+ SetCursor(GetCursor() - 1);
else if (wrapAround)
{ // wrap around
- SetCursor(m_cursor + m_itemsPerRow - 1);
- if (m_offset * m_itemsPerRow + m_cursor >= (int)m_items.size())
- SetCursor((int)m_items.size() - m_offset * m_itemsPerRow);
+ SetCursor(GetCursor() + m_itemsPerRow - 1);
+ if (GetOffset() * m_itemsPerRow + GetCursor() >= (int)m_items.size())
+ SetCursor((int)m_items.size() - GetOffset() * m_itemsPerRow);
}
else
return false;
@@ -360,11 +360,11 @@ bool CGUIPanelContainer::MoveLeft(bool wrapAround)
bool CGUIPanelContainer::MoveRight(bool wrapAround)
{
- int col = m_cursor % m_itemsPerRow;
- if (col + 1 < m_itemsPerRow && m_offset * m_itemsPerRow + m_cursor + 1 < (int)m_items.size())
- SetCursor(m_cursor + 1);
+ int col = GetCursor() % m_itemsPerRow;
+ if (col + 1 < m_itemsPerRow && GetOffset() * m_itemsPerRow + GetCursor() + 1 < (int)m_items.size())
+ SetCursor(GetCursor() + 1);
else if (wrapAround) // move first item in row
- SetCursor(m_cursor - col);
+ SetCursor(GetCursor() - col);
else
return false;
return true;
@@ -374,7 +374,7 @@ bool CGUIPanelContainer::MoveRight(bool wrapAround)
void CGUIPanelContainer::Scroll(int amount)
{
// increase or decrease the offset
- int offset = m_offset + amount;
+ int offset = GetOffset() + amount;
if (offset > ((int)GetRows() - m_itemsPerPage) * m_itemsPerRow)
{
offset = ((int)GetRows() - m_itemsPerPage) * m_itemsPerRow;
@@ -384,14 +384,14 @@ void CGUIPanelContainer::Scroll(int amount)
}
void CGUIPanelContainer::ValidateOffset()
-{ // first thing is we check the range of m_offset
+{ // first thing is we check the range of our offset
if (!m_layout) return;
- if (m_offset > (int)GetRows() - m_itemsPerPage || m_scrollOffset > ((int)GetRows() - m_itemsPerPage) * m_layout->Size(m_orientation))
+ if (GetOffset() > (int)GetRows() - m_itemsPerPage || m_scrollOffset > ((int)GetRows() - m_itemsPerPage) * m_layout->Size(m_orientation))
{
SetOffset(std::max(0, (int)GetRows() - m_itemsPerPage));
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
+ m_scrollOffset = GetOffset() * m_layout->Size(m_orientation);
}
- if (m_offset < 0 || m_scrollOffset < 0)
+ if (GetOffset() < 0 || m_scrollOffset < 0)
{
SetOffset(0);
m_scrollOffset = 0;
@@ -404,7 +404,7 @@ void CGUIPanelContainer::SetCursor(int cursor)
if (cursor > (m_itemsPerPage + 1)*m_itemsPerRow - 1) cursor = (m_itemsPerPage + 1)*m_itemsPerRow - 1;
if (cursor < 0) cursor = 0;
if (!m_wasReset)
- SetContainerMoving(cursor - m_cursor);
+ SetContainerMoving(cursor - GetCursor());
CGUIBaseContainer::SetCursor(cursor);
}
@@ -428,7 +428,7 @@ void CGUIPanelContainer::CalculateLayout()
if (m_itemsPerPage < 1) m_itemsPerPage = 1;
// ensure that the scroll offset is a multiple of our size
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
+ m_scrollOffset = GetOffset() * m_layout->Size(m_orientation);
}
unsigned int CGUIPanelContainer::GetRows() const
@@ -462,7 +462,7 @@ int CGUIPanelContainer::GetCursorFromPoint(const CPoint &point, CPoint *itemPoin
for (int x = 0; x < m_itemsPerRow; x++)
{
int item = x + y * m_itemsPerRow;
- if (posX < sizeX && posY < sizeY && item + m_offset < (int)m_items.size())
+ if (posX < sizeX && posY < sizeY && item + GetOffset() < (int)m_items.size())
{ // found
return item;
}
@@ -484,8 +484,8 @@ bool CGUIPanelContainer::SelectItemFromPoint(const CPoint &point)
bool CGUIPanelContainer::GetCondition(int condition, int data) const
{ // probably only works vertically atm...
- int row = m_cursor / m_itemsPerRow;
- int col = m_cursor % m_itemsPerRow;
+ int row = GetCursor() / m_itemsPerRow;
+ int col = GetCursor() % m_itemsPerRow;
if (m_orientation == HORIZONTAL)
swap(row, col);
switch (condition)
@@ -501,36 +501,36 @@ bool CGUIPanelContainer::GetCondition(int condition, int data) const
void CGUIPanelContainer::SelectItem(int item)
{
- // Check that m_offset is valid
+ // Check that our offset is valid
ValidateOffset();
// only select an item if it's in a valid range
if (item >= 0 && item < (int)m_items.size())
{
// Select the item requested
- if (item >= m_offset * m_itemsPerRow && item < (m_offset + m_itemsPerPage) * m_itemsPerRow)
+ if (item >= GetOffset() * m_itemsPerRow && item < (GetOffset() + m_itemsPerPage) * m_itemsPerRow)
{ // the item is on the current page, so don't change it.
- SetCursor(item - m_offset * m_itemsPerRow);
+ SetCursor(item - GetOffset() * m_itemsPerRow);
}
- else if (item < m_offset * m_itemsPerRow)
+ else if (item < GetOffset() * m_itemsPerRow)
{ // item is on a previous page - make it the first item on the page
SetCursor(item % m_itemsPerRow);
- ScrollToOffset((item - m_cursor) / m_itemsPerRow);
+ ScrollToOffset((item - GetCursor()) / m_itemsPerRow);
}
- else // (item >= m_offset+m_itemsPerPage)
+ else // (item >= GetOffset()+m_itemsPerPage)
{ // item is on a later page - make it the last row on the page
SetCursor(item % m_itemsPerRow + m_itemsPerRow * (m_itemsPerPage - 1));
- ScrollToOffset((item - m_cursor) / m_itemsPerRow);
+ ScrollToOffset((item - GetCursor()) / m_itemsPerRow);
}
}
}
bool CGUIPanelContainer::HasPreviousPage() const
{
- return (m_offset > 0);
+ return (GetOffset() > 0);
}
bool CGUIPanelContainer::HasNextPage() const
{
- return (m_offset != (int)GetRows() - m_itemsPerPage && (int)GetRows() > m_itemsPerPage);
+ return (GetOffset() != (int)GetRows() - m_itemsPerPage && (int)GetRows() > m_itemsPerPage);
}
View
16 xbmc/guilib/GUIWrappingListContainer.cpp
@@ -41,7 +41,7 @@ void CGUIWrappingListContainer::UpdatePageControl(int offset)
{
if (m_pageControl)
{ // tell our pagecontrol (scrollbar or whatever) to update (offset it by our cursor position)
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, CorrectOffset(offset, m_cursor));
+ CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, CorrectOffset(offset, GetCursor()));
SendWindowMessage(msg);
}
}
@@ -95,7 +95,7 @@ bool CGUIWrappingListContainer::OnMessage(CGUIMessage& message)
{
if (message.GetSenderId() == m_pageControl && IsVisible())
{ // offset by our cursor position
- message.SetParam1(message.GetParam1() - m_cursor);
+ message.SetParam1(message.GetParam1() - GetCursor());
}
}
}
@@ -117,7 +117,7 @@ bool CGUIWrappingListContainer::MoveDown(bool wrapAround)
// scrolls the said amount
void CGUIWrappingListContainer::Scroll(int amount)
{
- ScrollToOffset(m_offset + amount);
+ ScrollToOffset(GetOffset() + amount);
}
void CGUIWrappingListContainer::ValidateOffset()
@@ -159,7 +159,7 @@ int CGUIWrappingListContainer::GetSelectedItem() const
if (m_items.size() > m_extraItems)
{
int numItems = (int)(m_items.size() - m_extraItems);
- int correctOffset = (m_offset + m_cursor) % numItems;
+ int correctOffset = (GetOffset() + GetCursor()) % numItems;
if (correctOffset < 0) correctOffset += numItems;
return correctOffset;
}
@@ -175,7 +175,7 @@ bool CGUIWrappingListContainer::SelectItemFromPoint(const CPoint &point)
const float mouse_max_amount = 1.0f; // max speed: 1 item per frame
float sizeOfItem = m_layout->Size(m_orientation);
// see if the point is either side of our focused item
- float start = m_cursor * sizeOfItem;
+ float start = GetCursor() * sizeOfItem;
float end = start + m_focusedLayout->Size(m_orientation);
float pos = (m_orientation == VERTICAL) ? point.y : point.x;
if (pos < start - 0.5f * sizeOfItem)
@@ -211,7 +211,7 @@ bool CGUIWrappingListContainer::SelectItemFromPoint(const CPoint &point)
void CGUIWrappingListContainer::SelectItem(int item)
{
if (item >= 0 && item < (int)m_items.size())
- ScrollToOffset(item - m_cursor);
+ ScrollToOffset(item - GetCursor());
}
void CGUIWrappingListContainer::ResetExtraItems()
@@ -230,8 +230,8 @@ void CGUIWrappingListContainer::Reset()
int CGUIWrappingListContainer::GetCurrentPage() const
{
- int offset = CorrectOffset(m_offset, m_cursor);
- if (offset + m_itemsPerPage - m_cursor >= (int)GetRows()) // last page
+ int offset = CorrectOffset(GetOffset(), GetCursor());
+ if (offset + m_itemsPerPage - GetCursor() >= (int)GetRows()) // last page
return (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage;
return offset / m_itemsPerPage + 1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.