本文整理汇总了C++中CContextButtons::size方法的典型用法代码示例。如果您正苦于以下问题:C++ CContextButtons::size方法的具体用法?C++ CContextButtons::size怎么用?C++ CContextButtons::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContextButtons
的用法示例。
在下文中一共展示了CContextButtons::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPopupMenu
bool CGUIMediaWindow::OnPopupMenu(int iItem)
{
// popup the context menu
// grab our context menu
CContextButtons buttons;
GetContextButtons(iItem, buttons);
if (buttons.size())
{
// mark the item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(true);
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (!pMenu) return false;
// load our menu
pMenu->Initialize();
// add the buttons and execute it
for (CContextButtons::iterator it = buttons.begin(); it != buttons.end(); it++)
pMenu->AddButton((*it).second);
// position it correctly
float posX = 200;
float posY = 100;
const CGUIControl *pList = GetControl(CONTROL_VIEW_START);
if (pList)
{
posX = pList->GetXPosition() + pList->GetWidth() / 2;
posY = pList->GetYPosition() + pList->GetHeight() / 2;
}
pMenu->SetPosition(posX - pMenu->GetWidth() / 2, posY - pMenu->GetHeight() / 2);
pMenu->DoModal();
// translate our button press
CONTEXT_BUTTON btn = CONTEXT_BUTTON_CANCELLED;
if (pMenu->GetButton() > 0 && pMenu->GetButton() <= (int)buttons.size())
btn = buttons[pMenu->GetButton() - 1].first;
// deselect our item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(false);
if (btn != CONTEXT_BUTTON_CANCELLED)
return OnContextButton(iItem, btn);
}
return false;
}
示例2: SourcesMenu
bool CGUIDialogContextMenu::SourcesMenu(const CStdString &strType, const CFileItemPtr item, float posX, float posY)
{
// TODO: This should be callable even if we don't have any valid items
if (!item)
return false;
// popup the context menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
// load our menu
pMenu->Initialize();
// grab our context menu
CContextButtons buttons;
GetContextButtons(strType, item, buttons);
// add the buttons and execute it
for (CContextButtons::iterator it = buttons.begin(); it != buttons.end(); it++)
pMenu->AddButton((*it).second);
// position it correctly
pMenu->OffsetPosition(posX, posY);
pMenu->DoModal();
// translate our button press
CONTEXT_BUTTON btn = CONTEXT_BUTTON_CANCELLED;
if (pMenu->GetButton() > 0 && pMenu->GetButton() <= (int)buttons.size())
btn = buttons[pMenu->GetButton() - 1].first;
if (btn != CONTEXT_BUTTON_CANCELLED)
return OnContextButton(strType, item, btn);
}
return false;
}
示例3: OnPopupMenu
bool CGUIMediaWindow::OnPopupMenu(int iItem)
{
// popup the context menu
// grab our context menu
CContextButtons buttons;
GetContextButtons(iItem, buttons);
if (buttons.size())
{
// mark the item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(true);
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (!pMenu) return false;
// load our menu
pMenu->Initialize();
// add the buttons and execute it
for (CContextButtons::iterator it = buttons.begin(); it != buttons.end(); it++)
pMenu->AddButton((*it).second);
// position it correctly
CPoint pos = GetContextPosition();
pMenu->OffsetPosition(pos.x, pos.y);
pMenu->DoModal();
// translate our button press
CONTEXT_BUTTON btn = CONTEXT_BUTTON_CANCELLED;
if (pMenu->GetButton() > 0 && pMenu->GetButton() <= (int)buttons.size())
btn = buttons[pMenu->GetButton() - 1].first;
// deselect our item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(false);
if (btn != CONTEXT_BUTTON_CANCELLED)
return OnContextButton(iItem, btn);
}
return false;
}
示例4: 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);
}
示例5: ShowAndGetChoice
int CGUIDialogContextMenu::ShowAndGetChoice(const CContextButtons &choices)
{
if (choices.size() == 0)
return -1;
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
pMenu->m_buttons = choices;
pMenu->Initialize();
pMenu->PositionAtCurrentFocus();
pMenu->DoModal();
return pMenu->m_clickedButton;
}
return -1;
}
示例6: AddVisibleItems
void CContextMenuManager::AddVisibleItems(
const CFileItemPtr& item, CContextButtons& list, const CContextMenuItem& root /* = CContextMenuItem::MAIN */)
{
if (!item)
return;
const int initialSize = list.size();
for (const auto& kv : m_items)
if (IsVisible(kv.second, root, item))
list.push_back(std::make_pair(kv.first, kv.second.GetLabel()));
if (root == MAIN || root == MANAGE)
{
std::stable_sort(list.begin() + initialSize, list.end(),
[](const std::pair<int, std::string>& lhs, const std::pair<int, std::string>& rhs)
{
return lhs.second < rhs.second;
}
);
}
}
示例7: OnPopupMenu
bool CGUIMediaWindow::OnPopupMenu(int iItem)
{
// popup the context menu
// grab our context menu
CContextButtons buttons;
GetContextButtons(iItem, buttons);
if (buttons.size())
{
// mark the item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(true);
int choice = CGUIDialogContextMenu::ShowAndGetChoice(buttons);
// deselect our item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(false);
if (choice >= 0)
return OnContextButton(iItem, (CONTEXT_BUTTON)choice);
}
return false;
}