Skip to content

Commit

Permalink
Don't show "By Source/Target" if there are no sources/targets to show (
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruselj authored Nov 26, 2021
1 parent e5d4b4c commit e1d0145
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions src/surge-xt/gui/overlays/ModulationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,38 +804,55 @@ void ModulationSideControls::valueChanged(GUI::IComponentTagValue *c)
*/
auto men = juce::PopupMenu();
std::set<std::string> sources, targets;

for (const auto &r : editor->modContents->dataRows)
{
sources.insert(r.sname);
targets.insert(r.pname);
}

// FIXME add help component

auto tcomp =
std::make_unique<Surge::Widgets::MenuTitleHelpComponent>("Filter Modulation List", "");

tcomp->setSkin(skin, associatedBitmapStore);

men.addCustomItem(-1, std::move(tcomp));
men.addSeparator();
men.addItem(Surge::GUI::toOSCaseForMenu("Clear Filter"), [this]() {
editor->modContents->clearFilters();
filterL->setText("Filter By", juce::NotificationType::dontSendNotification);
filterW->setLabels({"-"});
});
men.addSeparator();
men.addSectionHeader("BY SOURCE");
for (auto s : sources)
men.addItem(s, [this, s]() {
editor->modContents->filterBySource(s);
filterL->setText("Filter By Source", juce::NotificationType::dontSendNotification);
filterW->setLabels({s});
});
men.addSectionHeader("BY TARGET");
for (auto t : targets)
men.addItem(t, [this, t]() {
editor->modContents->filterByTarget(t);
filterL->setText("Filter By Target", juce::NotificationType::dontSendNotification);
filterW->setLabels({t});

if (!sources.empty() && !targets.empty())
{
men.addSeparator();

men.addItem(Surge::GUI::toOSCaseForMenu("Clear Filter"), [this]() {
editor->modContents->clearFilters();
filterL->setText("Filter By", juce::NotificationType::dontSendNotification);
filterW->setLabels({"-"});
});

men.addSeparator();

men.addSectionHeader("BY SOURCE");

for (auto s : sources)
men.addItem(s, [this, s]() {
editor->modContents->filterBySource(s);
filterL->setText("Filter By Source",
juce::NotificationType::dontSendNotification);
filterW->setLabels({s});
});

men.addSectionHeader("BY TARGET");

for (auto t : targets)
men.addItem(t, [this, t]() {
editor->modContents->filterByTarget(t);
filterL->setText("Filter By Target",
juce::NotificationType::dontSendNotification);
filterW->setLabels({t});
});
}

men.showMenuAsync(juce::PopupMenu::Options(), GUI::makeEndHoverCallback(filterW.get()));
}
break;
Expand Down

0 comments on commit e1d0145

Please sign in to comment.