Skip to content

Commit

Permalink
Fix incorrect mod index name in slider RMB menu (#4972)
Browse files Browse the repository at this point in the history
Also don't show "Switch to..." options if modlist size is 1
  • Loading branch information
mkruselj authored Sep 2, 2021
1 parent e34fa82 commit da8e7f4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 36 deletions.
46 changes: 26 additions & 20 deletions src/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,6 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c

cms->buildHamburgerMenu(contextMenu, true);

contextMenu.addSeparator();

int n_total_md = synth->storage.getPatch().param_ptr.size();
const int max_md = 4096;

Expand Down Expand Up @@ -390,24 +388,25 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
if (((md < n_global_params) || ((parameter->scene - 1) == activeScene)) &&
synth->isAnyActiveModulation(md, thisms, use_scene))
{
char modtxt[TXT_SIZE];
auto pmd = synth->storage.getPatch().param_ptr[md];

auto indices = synth->getModulationIndicesBetween(md, thisms, use_scene);
auto hasIdx = synth->supportsIndexedModulator(use_scene, thisms);
char modtxt[TXT_SIZE];

for (auto modidx : indices)
{
pmd->get_display_of_modulation_depth(
parameter->get_display_of_modulation_depth(
modtxt, synth->getModDepth(md, thisms, use_scene, modidx),
synth->isBipolarModulation(thisms), Parameter::Menu);
char tmptxt[1024]; // leave room for that ubuntu 20.0 error

if (pmd->ctrlgroup == cg_LFO)
if (parameter->ctrlgroup == cg_LFO)
{
char pname[TXT_SIZE];
pmd->create_fullname(
pmd->get_name(), pname, pmd->ctrlgroup, pmd->ctrlgroup_entry,
modulatorName(pmd->ctrlgroup_entry, true).c_str());
parameter->create_fullname(
parameter->get_name(), pname, parameter->ctrlgroup,
parameter->ctrlgroup_entry,
modulatorName(parameter->ctrlgroup_entry, true).c_str());
snprintf(tmptxt, TXT_SIZE, "Edit %s%s -> %s: %s",
(char *)modulatorName(thisms, true).c_str(),
modulatorIndexExtension(use_scene, thisms, modidx).c_str(),
Expand All @@ -418,7 +417,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
snprintf(tmptxt, TXT_SIZE, "Edit %s%s -> %s: %s",
(char *)modulatorName(thisms, true).c_str(),
modulatorIndexExtension(use_scene, thisms, modidx).c_str(),
pmd->get_full_name(), modtxt);
parameter->get_full_name(), modtxt);
}

auto clearOp = [this, parameter, use_scene, bvf, thisms, modidx]() {
Expand Down Expand Up @@ -450,11 +449,12 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
if (((md < n_global_params) || ((parameter->scene - 1) == activeScene)) &&
synth->isAnyActiveModulation(md, thisms, use_scene))
{
auto pmd = synth->storage.getPatch().param_ptr[md];
auto indices = synth->getModulationIndicesBetween(md, thisms, use_scene);
auto hasIdx = synth->supportsIndexedModulator(use_scene, thisms);

for (auto modidx : indices)
{
char tmptxt[1024];
char tmptxt[TXT_SIZE * 2];

if (parameter->ctrlgroup == cg_LFO)
{
Expand Down Expand Up @@ -1889,31 +1889,36 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
modsources ms = (modsources)k;
int startScene = current_scene, endScene = current_scene + 1;
bool showScene = false;

if (p->scene == 0)
{
startScene = 0;
endScene = n_scenes;
showScene = true;
}

for (int sc = startScene; sc < endScene; ++sc)
{
auto indices = synth->getModulationIndicesBetween(ptag, ms, sc);

for (auto modidx : indices)
{
if (synth->isActiveModulation(ptag, ms, sc, modidx))
{
char modtxt[256];

p->get_display_of_modulation_depth(
modtxt, synth->getModDepth(ptag, ms, sc, modidx),
synth->isBipolarModulation(ms), Parameter::Menu);

char tmptxt[512];
sprintf(tmptxt, "Edit %s%s -> %s: %s",
(char *)modulatorName(ms, true, showScene ? sc : -1)
.c_str(),
modulatorIndexExtension(current_scene, ms, sc, modidx)
.c_str(),
p->get_full_name(), modtxt);

sprintf(
tmptxt, "Edit %s%s -> %s: %s",
(char *)modulatorName(ms, true, showScene ? sc : -1)
.c_str(),
modulatorIndexExtension(current_scene, ms, modidx).c_str(),
p->get_full_name(), modtxt);

contextMenu.addItem(tmptxt, [this, p, sc, bvf, ms, modidx]() {
this->promptForUserValueEntry(p, bvf, ms, sc, modidx);
Expand Down Expand Up @@ -1943,9 +1948,10 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
{
if (synth->isActiveModulation(ptag, ms, sc, modidx))
{
char tmptxt[256];
char tmptxt[TXT_SIZE];

snprintf(
tmptxt, 256, "Clear %s%s -> %s",
tmptxt, TXT_SIZE, "Clear %s%s -> %s",
(char *)modulatorName(ms, true, showScene ? sc : -1)
.c_str(),
modulatorIndexExtension(current_scene, ms, modidx).c_str(),
Expand Down
33 changes: 17 additions & 16 deletions src/gui/widgets/ModulationSourceButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,25 +285,26 @@ void ModulationSourceButton::buildHamburgerMenu(juce::PopupMenu &menu,

menu.addSeparator();
}

for (auto e : modlist)
else
{
auto modName = std::get<3>(e);

if (addedToModbuttonContextMenu)
if (modlist.size() > 1)
{
modName = "Switch to " + modName;
for (auto e : modlist)
{
auto modName = std::get<3>(e);
modName = "Switch to " + modName;

menu.addItem(modName, [this, idx]() {
this->modlistIndex = idx;
mouseMode = HAMBURGER;
notifyValueChanged();
mouseMode = NONE;
repaint();
});

idx++;
}
}

menu.addItem(modName, [this, idx]() {
this->modlistIndex = idx;
mouseMode = HAMBURGER;
notifyValueChanged();
mouseMode = NONE;
repaint();
});

idx++;
}
}

Expand Down

0 comments on commit da8e7f4

Please sign in to comment.