本文整理汇总了C++中CContextButtons::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CContextButtons::empty方法的具体用法?C++ CContextButtons::empty怎么用?C++ CContextButtons::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContextButtons
的用法示例。
在下文中一共展示了CContextButtons::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnClick
bool CContextMenuManager::OnClick(unsigned int id, const CFileItemPtr& item)
{
if (!item)
return false;
auto it = std::find_if(m_items.begin(), m_items.end(),
[id](const Item& kv){ return kv.first == id; });
if (it == m_items.end())
{
CLog::Log(LOGERROR, "CContextMenuManager: unknown button id '%u'", id);
return false;
}
CContextMenuItem menuItem = it->second;
if (menuItem.IsGroup())
{
CLog::Log(LOGDEBUG, "CContextMenuManager: showing group '%s'", menuItem.ToString().c_str());
CContextButtons choices;
AddVisibleItems(item, choices, menuItem);
if (choices.empty())
{
CLog::Log(LOGERROR, "CContextMenuManager: no items in group '%s'", menuItem.ToString().c_str());
return false;
}
int choice = CGUIDialogContextMenu::ShowAndGetChoice(choices);
if (choice == -1)
return false;
return OnClick(choice, item);
}
return menuItem.Execute(item);
}
示例2: ShowAndGetChoice
int CGUIDialogContextMenu::ShowAndGetChoice(const CContextButtons &choices)
{
if (choices.empty())
return -1;
CGUIDialogContextMenu *pMenu = g_windowManager.GetWindow<CGUIDialogContextMenu>(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
pMenu->m_buttons = choices;
pMenu->Initialize();
pMenu->SetInitialVisibility();
pMenu->SetupButtons();
pMenu->PositionAtCurrentFocus();
pMenu->Open();
int idx = pMenu->m_clickedButton;
if (idx != -1)
return choices[idx].first;
}
return -1;
}
示例3: ContextMenu
bool CGUIDialogPVRItemsViewBase::ContextMenu(int itemIdx)
{
auto InRange = [](size_t i, std::pair<size_t, size_t> range){ return i >= range.first && i < range.second; };
if (itemIdx < 0 || itemIdx >= m_vecItems->Size())
return false;
const CFileItemPtr item = m_vecItems->Get(itemIdx);
if (!item)
return false;
CContextButtons buttons;
// Add the global menu
const ContextMenuView globalMenu = CServiceBroker::GetContextMenuManager().GetItems(*item, CContextMenuManager::MAIN);
auto globalMenuRange = std::make_pair(buttons.size(), buttons.size() + globalMenu.size());
for (const auto& menu : globalMenu)
buttons.emplace_back(~buttons.size(), menu->GetLabel(*item));
// Add addon menus
const ContextMenuView addonMenu = CServiceBroker::GetContextMenuManager().GetAddonItems(*item, CContextMenuManager::MAIN);
auto addonMenuRange = std::make_pair(buttons.size(), buttons.size() + addonMenu.size());
for (const auto& menu : addonMenu)
buttons.emplace_back(~buttons.size(), menu->GetLabel(*item));
if (buttons.empty())
return true;
int idx = CGUIDialogContextMenu::Show(buttons);
if (idx < 0 || idx >= static_cast<int>(buttons.size()))
return false;
Close();
if (InRange(idx, globalMenuRange))
return CONTEXTMENU::LoopFrom(*globalMenu[idx - globalMenuRange.first], item);
return CONTEXTMENU::LoopFrom(*addonMenu[idx - addonMenuRange.first], item);
}