mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
PopupMenu modernisation: Improved the PopupMenu::Item class to make it easy to build items by chaining calls together.
This commit is contained in:
parent
cce26202ab
commit
cd4aba9e43
10 changed files with 246 additions and 141 deletions
|
|
@ -552,26 +552,22 @@ void TabbedButtonBar::setTabBackgroundColour (int tabIndex, Colour newColour)
|
|||
}
|
||||
}
|
||||
|
||||
void TabbedButtonBar::extraItemsMenuCallback (int result, TabbedButtonBar* bar)
|
||||
{
|
||||
if (bar != nullptr && result > 0)
|
||||
bar->setCurrentTabIndex (result - 1);
|
||||
}
|
||||
|
||||
void TabbedButtonBar::showExtraItemsMenu()
|
||||
{
|
||||
PopupMenu m;
|
||||
Component::SafePointer<TabbedButtonBar> bar (this);
|
||||
|
||||
for (int i = 0; i < tabs.size(); ++i)
|
||||
{
|
||||
auto* tab = tabs.getUnchecked(i);
|
||||
|
||||
if (! tab->button->isVisible())
|
||||
m.addItem (i + 1, tab->name, true, i == currentTabIndex);
|
||||
m.addItem (PopupMenu::Item (tab->name)
|
||||
.setTicked (i == currentTabIndex)
|
||||
.setAction ([this, bar, i] { if (bar != nullptr) setCurrentTabIndex (i); }));
|
||||
}
|
||||
|
||||
m.showMenuAsync (PopupMenu::Options().withTargetComponent (extraTabsButton.get()),
|
||||
ModalCallbackFunction::forComponent (extraItemsMenuCallback, this));
|
||||
m.showMenuAsync (PopupMenu::Options().withTargetComponent (extraTabsButton.get()));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue