diff options
author | jmarshallnz <jmarshallnz@svn> | 2010-01-09 09:05:41 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2010-01-09 09:05:41 +0000 |
commit | 8bd9964d8a756ac92149efe980e2616f8f2e5c4a (patch) | |
tree | 3e09129bec0c4c533d7d5fd1592faceca358dbb8 /guilib/GUIControlGroup.cpp | |
parent | f2508d4a464540428c7c0f293b356b5a5d1003b4 (diff) |
changed: Improved mouse event handling - we now pass events down through the control structure, giving better context for the performed event. Allows groups to react if their children don't.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@26577 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib/GUIControlGroup.cpp')
-rw-r--r-- | guilib/GUIControlGroup.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/guilib/GUIControlGroup.cpp b/guilib/GUIControlGroup.cpp index 42848a9668..663d88fce7 100644 --- a/guilib/GUIControlGroup.cpp +++ b/guilib/GUIControlGroup.cpp @@ -357,22 +357,28 @@ bool CGUIControlGroup::HasAnimation(ANIMATION_TYPE animType) return false; } -void CGUIControlGroup::GetControlsFromPoint(const CPoint &point, vector< std::pair<CGUIControl *, CPoint> > &controls) const +bool CGUIControlGroup::SendMouseEvent(const CPoint &point, const CMouseEvent &event) { - if (!CGUIControl::CanFocus()) - return; - CPoint controlCoords(point); - m_transform.InverseTransformPosition(controlCoords.x, controlCoords.y); - controlCoords -= GetPosition(); - for (crControls it = m_children.rbegin(); it != m_children.rend(); ++it) + // transform our position into child coordinates + CPoint childPoint(point); + m_transform.InverseTransformPosition(childPoint.x, childPoint.y); + childPoint -= GetPosition(); + + if (CanFocus()) { - CGUIControl *child = *it; - CPoint childCoords; - if (child->IsGroup()) - ((CGUIControlGroup *)child)->GetControlsFromPoint(controlCoords, controls); - else if (child->CanFocusFromPoint(controlCoords, childCoords)) - controls.push_back(make_pair(child, childCoords)); + // run through our controls in reverse order (so that last rendered is checked first) + for (crControls i = m_children.rbegin(); i != m_children.rend(); ++i) + { + CGUIControl *child = *i; + if (child->SendMouseEvent(childPoint, event)) + { // we've handled the action, and/or have focused an item + return true; + } + } } + // if we get here we haven't handled the event and thus do not have focus + m_focusedControl = 0; + return false; } void CGUIControlGroup::UnfocusFromPoint(const CPoint &point) |