Skip to content
Browse files

split GUIAction::Execute into GUIAction::ExecuteActions and CGUIContr…

…ol::Navigate

GUIAction::ExecuteActions will simply execute all non-navigation actions
CGUIControl::Navigate is meant to start navigation from control in given direction until we find focusable control (executing actions on its path)
  • Loading branch information...
1 parent ea04d36 commit bf300a0fa69a6b04b33ff57fea87f11fe22bcb44 @pieh committed Oct 31, 2011
View
18 xbmc/guilib/GUIAction.cpp
@@ -38,7 +38,7 @@ CGUIAction::CGUIAction(int controlID)
SetNavigation(controlID);
}
-bool CGUIAction::Execute(int controlID, int parentID, int direction /*= 0*/) const
+bool CGUIAction::ExecuteActions(int controlID, int parentID) const
{
if (m_actions.size() == 0) return false;
bool retval = false;
@@ -47,21 +47,7 @@ bool CGUIAction::Execute(int controlID, int parentID, int direction /*= 0*/) con
{
if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
{
- if (StringUtils::IsInteger(it->action))
- {
- CGUIMessage msg(GUI_MSG_MOVE, parentID, controlID, direction);
- if (parentID)
- {
- CGUIWindow *pWindow = g_windowManager.GetWindow(parentID);
- if (pWindow)
- {
- retval |= pWindow->OnMessage(msg);
- continue;
- }
- }
- retval |= g_windowManager.SendMessage(msg);
- }
- else
+ if (!StringUtils::IsInteger(it->action))
{
CGUIMessage msg(GUI_MSG_EXECUTE, controlID, parentID);
msg.SetStringParam(it->action);
View
4 xbmc/guilib/GUIAction.h
@@ -35,9 +35,9 @@ class CGUIAction
CGUIAction(int controlID);
/**
- * Execute actions, if action is paired with condition - evaluate condition first
+ * Execute actions (no navigation paths), if action is paired with condition - evaluate condition first
*/
- bool Execute(int controlID, int parentID, int direction = 0) const;
+ bool ExecuteActions(int controlID, int parentID) const;
/**
* Check if there is any action that meet its condition
*/
View
2 xbmc/guilib/GUIBaseContainer.cpp
@@ -700,7 +700,7 @@ bool CGUIBaseContainer::OnClick(int actionID)
if (selected >= 0 && selected < (int)m_items.size())
{
CGUIStaticItemPtr item = boost::static_pointer_cast<CGUIStaticItem>(m_items[selected]);
- item->GetClickActions().Execute(GetID(), GetParentID());
+ item->GetClickActions().ExecuteActions(GetID(), GetParentID());
}
return true;
}
View
6 xbmc/guilib/GUIButtonControl.cpp
@@ -307,17 +307,17 @@ void CGUIButtonControl::OnClick()
CGUIMessage msg(GUI_MSG_CLICKED, controlID, parentID, 0);
SendWindowMessage(msg);
- clickActions.Execute(controlID, parentID);
+ clickActions.ExecuteActions(controlID, parentID);
}
void CGUIButtonControl::OnFocus()
{
- m_focusActions.Execute(GetID(), GetParentID());
+ m_focusActions.ExecuteActions(GetID(), GetParentID());
}
void CGUIButtonControl::OnUnFocus()
{
- m_unfocusActions.Execute(GetID(), GetParentID());
+ m_unfocusActions.ExecuteActions(GetID(), GetParentID());
}
void CGUIButtonControl::SetSelected(bool bSelected)
View
30 xbmc/guilib/GUIControl.cpp
@@ -224,46 +224,50 @@ bool CGUIControl::OnAction(const CAction &action)
return false;
}
+bool CGUIControl::Navigate(int direction)
+{
+ if (HasFocus())
+ {
+ CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), direction);
+ return SendWindowMessage(msg);
+ }
+ return false;
+}
+
// Movement controls (derived classes can override)
void CGUIControl::OnUp()
{
- if (HasFocus())
- m_actionUp.Execute(GetID(), GetParentID(), ACTION_MOVE_UP);
+ Navigate(ACTION_MOVE_UP);
}
void CGUIControl::OnDown()
{
- if (HasFocus())
- m_actionDown.Execute(GetID(), GetParentID(), ACTION_MOVE_DOWN);
+ Navigate(ACTION_MOVE_DOWN);
}
void CGUIControl::OnLeft()
{
- if (HasFocus())
- m_actionLeft.Execute(GetID(), GetParentID(), ACTION_MOVE_LEFT);
+ Navigate(ACTION_MOVE_LEFT);
}
void CGUIControl::OnRight()
{
- if (HasFocus())
- m_actionRight.Execute(GetID(), GetParentID(), ACTION_MOVE_RIGHT);
+ Navigate(ACTION_MOVE_RIGHT);
}
bool CGUIControl::OnBack()
{
- return HasFocus() ? m_actionBack.Execute(GetID(), GetParentID(), ACTION_NAV_BACK) : false;
+ return Navigate(ACTION_NAV_BACK);
}
void CGUIControl::OnNextControl()
{
- if (HasFocus())
- m_actionNext.Execute(GetID(), GetParentID(), ACTION_NEXT_CONTROL);
+ Navigate(ACTION_NEXT_CONTROL);
}
void CGUIControl::OnPrevControl()
{
- if (HasFocus())
- m_actionPrev.Execute(GetID(), GetParentID(), ACTION_PREV_CONTROL);
+ Navigate(ACTION_PREV_CONTROL);
}
bool CGUIControl::SendWindowMessage(CGUIMessage &message)
View
3 xbmc/guilib/GUIControl.h
@@ -200,6 +200,9 @@ class CGUIControl
int GetControlIdRight() const { return m_actionRight.GetNavigation(); };
int GetControlIdBack() const { return m_actionBack.GetNavigation(); };
bool GetNavigationAction(int direction, CGUIAction& action) const;
+ /*! \brief Start navigating in given direction.
+ */
+ bool Navigate(int direction);
virtual void SetFocus(bool focus);
virtual void SetWidth(float width);
virtual void SetHeight(float height);
View
2 xbmc/guilib/GUIEditControl.cpp
@@ -306,7 +306,7 @@ void CGUIEditControl::UpdateText(bool sendUpdate)
{
SEND_CLICK_MESSAGE(GetID(), GetParentID(), 0);
- m_textChangeActions.Execute(GetID(), GetParentID());
+ m_textChangeActions.ExecuteActions(GetID(), GetParentID());
}
SetInvalid();
}
View
5 xbmc/guilib/GUIWindow.cpp
@@ -836,6 +836,7 @@ bool CGUIWindow::OnMove(int fromControl, int moveAction)
CGUIAction action;
if (!control->GetNavigationAction(moveAction, action))
return false;
+ action.ExecuteActions(nextControl, GetParentID());
nextControl = action.GetNavigation();
if (!nextControl) // 0 isn't valid control id
return false;
@@ -956,12 +957,12 @@ void CGUIWindow::SetRunActionsManually()
void CGUIWindow::RunLoadActions()
{
- m_loadActions.Execute(GetID(), GetParentID());
+ m_loadActions.ExecuteActions(GetID(), GetParentID());
}
void CGUIWindow::RunUnloadActions()
{
- m_unloadActions.Execute(GetID(), GetParentID());
+ m_unloadActions.ExecuteActions(GetID(), GetParentID());
}
void CGUIWindow::ClearBackground()

0 comments on commit bf300a0

Please sign in to comment.
Something went wrong with that request. Please try again.