aboutsummaryrefslogtreecommitdiff
path: root/guilib/GUIPanelContainer.cpp
diff options
context:
space:
mode:
authorjmarshallnz <jmarshallnz@svn>2010-03-25 01:51:33 +0000
committerjmarshallnz <jmarshallnz@svn>2010-03-25 01:51:33 +0000
commit002fb7812778df0dc924f5159236a19a052661cf (patch)
treecf431675891ca52d41f7d69c8a15cd1a101a7fd0 /guilib/GUIPanelContainer.cpp
parent4c60cde8e90155bc71d564adbad820f4f438133d (diff)
refactor: Split the cursor finding logic out of SelectItemFromPoint.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@28795 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib/GUIPanelContainer.cpp')
-rw-r--r--guilib/GUIPanelContainer.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/guilib/GUIPanelContainer.cpp b/guilib/GUIPanelContainer.cpp
index 94d1c5ae6f..3031c571b9 100644
--- a/guilib/GUIPanelContainer.cpp
+++ b/guilib/GUIPanelContainer.cpp
@@ -403,10 +403,10 @@ int CGUIPanelContainer::CorrectOffset(int offset, int cursor) const
return offset * m_itemsPerRow + cursor;
}
-bool CGUIPanelContainer::SelectItemFromPoint(const CPoint &point)
+int CGUIPanelContainer::GetCursorFromPoint(const CPoint &point, CPoint *itemPoint) const
{
if (!m_layout)
- return false;
+ return -1;
float sizeX = m_orientation == VERTICAL ? m_layout->Size(HORIZONTAL) : m_layout->Size(VERTICAL);
float sizeY = m_orientation == VERTICAL ? m_layout->Size(VERTICAL) : m_layout->Size(HORIZONTAL);
@@ -420,8 +420,7 @@ bool CGUIPanelContainer::SelectItemFromPoint(const CPoint &point)
int item = x + y * m_itemsPerRow;
if (posX < sizeX && posY < sizeY && item + m_offset < (int)m_items.size())
{ // found
- SetCursor(item);
- return true;
+ return item;
}
posX -= sizeX;
}
@@ -430,6 +429,15 @@ bool CGUIPanelContainer::SelectItemFromPoint(const CPoint &point)
return false;
}
+bool CGUIPanelContainer::SelectItemFromPoint(const CPoint &point)
+{
+ int cursor = GetCursorFromPoint(point);
+ if (cursor < 0)
+ return false;
+ SetCursor(cursor);
+ return true;
+}
+
bool CGUIPanelContainer::GetCondition(int condition, int data) const
{ // probably only works vertically atm...
int row = m_cursor / m_itemsPerRow;