Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two menu reset problems #277

Merged
merged 1 commit into from
Jan 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 55 additions & 10 deletions src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,9 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b
}
long tag = control->getTag();

int firstEIDForFirstClear = -1;
std::vector< std::string > clearControlTargetNames;

if (button & kDoubleClick)
button |= kControl;

Expand Down Expand Up @@ -1475,8 +1478,11 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b
synth->storage.getPatch().param_ptr[md]->get_full_name(),
synth->getModDepth(md, modsource));
clear_md[md] = eid;
contextMenu->addEntry(tmptxt, eid++);
if (firstEIDForFirstClear < 0)
firstEIDForFirstClear = eid;
clearControlTargetNames.push_back(synth->storage.getPatch().param_ptr[md]->get_name());

contextMenu->addEntry(tmptxt, eid++);
n_md++;
}
}
Expand Down Expand Up @@ -1584,15 +1590,17 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b
refresh_mod();

// Also blank out the name and rebuild the UI
synth->storage.getPatch().CustomControllerLabel[ccid][0] = '-';
synth->storage.getPatch().CustomControllerLabel[ccid][1] = 0;
((CModulationSourceButton*)control)
->setlabel(synth->storage.getPatch().CustomControllerLabel[ccid]);

control->setDirty();
control->invalid();

synth->updateDisplay();
if (within_range(ms_ctrl1, modsource, ms_ctrl1 + n_customcontrollers - 1))
{
synth->storage.getPatch().CustomControllerLabel[ccid][0] = '-';
synth->storage.getPatch().CustomControllerLabel[ccid][1] = 0;
((CModulationSourceButton*)control)
->setlabel(synth->storage.getPatch().CustomControllerLabel[ccid]);
control->setDirty();
control->invalid();

synth->updateDisplay();
}
}
else if (command == id_learnctrl)
{
Expand Down Expand Up @@ -1644,10 +1652,47 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b
}
for (int md = 0; md < n_total_md; md++)
{
/* In the case where you have modulations like "Attack", "Pitch" and "Release" the default name
of the modulation will be "Attack". So if you clear "Attack" you and you haven't renamed
you want to change the name to "Pitch". But you have to do quite a bit of work to recreate what
the next parameter short name is and comapre it in the same way it is done. So that's
what this splat of code does.
*/
if (clear_md[md] == command)
{
bool resetName = false; // Should I reset the name?
std::string newName = ""; // And to what?

if (clear_md[md]==firstEIDForFirstClear)
{
if (strncmp(synth->storage.getPatch().CustomControllerLabel[ccid],
clearControlTargetNames[0].c_str(),
15) == 0 )
{
// So my modulator is named after my short name. I haven't been renamed. So I want to
// reset at least to "-" unless someone is after me
resetName = true;
newName = "-";
if (clearControlTargetNames.size() > 1)
newName = clearControlTargetNames[1];
}
}

synth->clearModulation(md, modsource);
refresh_mod();

if (resetName)
{
// And this is where we apply the name refresh, of course.
strncpy(synth->storage.getPatch().CustomControllerLabel[ccid], newName.c_str(), 15);
synth->storage.getPatch().CustomControllerLabel[ccid][ 15 ] = 0;
((CModulationSourceButton*)control)
->setlabel(synth->storage.getPatch().CustomControllerLabel[ccid]);
control->setDirty();
control->invalid();
synth->updateDisplay();
}

}
}
}
Expand Down