本文整理汇总了C++中CGUIControl::SetAction方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIControl::SetAction方法的具体用法?C++ CGUIControl::SetAction怎么用?C++ CGUIControl::SetAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIControl
的用法示例。
在下文中一共展示了CGUIControl::SetAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddControl
void CGUIControlGroupList::AddControl(CGUIControl *control, int position /*= -1*/)
{
// NOTE: We override control navigation here, but we don't override the <onleft> etc. builtins
// if specified.
if (position < 0 || position > (int)m_children.size()) // add at the end
position = (int)m_children.size();
if (control)
{ // set the navigation of items so that they form a list
CGUIAction beforeAction = GetAction((m_orientation == VERTICAL) ? ACTION_MOVE_UP : ACTION_MOVE_LEFT);
CGUIAction afterAction = GetAction((m_orientation == VERTICAL) ? ACTION_MOVE_DOWN : ACTION_MOVE_RIGHT);
if (m_children.size())
{
// we're inserting at the given position, so grab the items above and below and alter
// their navigation accordingly
CGUIControl *before = NULL;
CGUIControl *after = NULL;
if (position == 0)
{ // inserting at the beginning
after = m_children[0];
if (!afterAction.HasActionsMeetingCondition() || afterAction.GetNavigation() == GetID()) // we're wrapping around bottom->top, so we have to update the last item
before = m_children[m_children.size() - 1];
if (!beforeAction.HasActionsMeetingCondition() || beforeAction.GetNavigation() == GetID()) // we're wrapping around top->bottom
beforeAction = CGUIAction(m_children[m_children.size() - 1]->GetID());
afterAction = CGUIAction(after->GetID());
}
else if (position == (int)m_children.size())
{ // inserting at the end
before = m_children[m_children.size() - 1];
if (!beforeAction.HasActionsMeetingCondition() || beforeAction.GetNavigation() == GetID()) // we're wrapping around top->bottom, so we have to update the first item
after = m_children[0];
if (!afterAction.HasActionsMeetingCondition() || afterAction.GetNavigation() == GetID()) // we're wrapping around bottom->top
afterAction = CGUIAction(m_children[0]->GetID());
beforeAction = CGUIAction(before->GetID());
}
else
{ // inserting somewhere in the middle
before = m_children[position - 1];
after = m_children[position];
beforeAction = CGUIAction(before->GetID());
afterAction = CGUIAction(after->GetID());
}
if (m_orientation == VERTICAL)
{
if (before) // update the DOWN action to point to us
before->SetAction(ACTION_MOVE_DOWN, CGUIAction(control->GetID()));
if (after) // update the UP action to point to us
after->SetAction(ACTION_MOVE_UP, CGUIAction(control->GetID()));
}
else
{
if (before) // update the RIGHT action to point to us
before->SetAction(ACTION_MOVE_RIGHT, CGUIAction(control->GetID()));
if (after) // update the LEFT action to point to us
after->SetAction(ACTION_MOVE_LEFT, CGUIAction(control->GetID()));
}
}
// now the control's nav
// set navigation path on orientation axis
// and try to apply other nav actions from grouplist
// don't override them if child have already defined actions
if (m_orientation == VERTICAL)
{
control->SetAction(ACTION_MOVE_UP, beforeAction);
control->SetAction(ACTION_MOVE_DOWN, afterAction);
control->SetAction(ACTION_MOVE_LEFT, GetAction(ACTION_MOVE_LEFT), false);
control->SetAction(ACTION_MOVE_RIGHT, GetAction(ACTION_MOVE_RIGHT), false);
}
else
{
control->SetAction(ACTION_MOVE_LEFT, beforeAction);
control->SetAction(ACTION_MOVE_RIGHT, afterAction);
control->SetAction(ACTION_MOVE_UP, GetAction(ACTION_MOVE_UP), false);
control->SetAction(ACTION_MOVE_DOWN, GetAction(ACTION_MOVE_DOWN), false);
}
control->SetAction(ACTION_NAV_BACK, GetAction(ACTION_NAV_BACK), false);
if (!m_useControlPositions)
control->SetPosition(0,0);
CGUIControlGroup::AddControl(control, position);
m_totalSize = GetTotalSize();
}
}