Skip to content

Commit

Permalink
Fix two menu reset problems
Browse files Browse the repository at this point in the history
As reported in #268, the menu reset i put was too heavy handed.
Make it so it cant reset "Timbre and the like".

As reported in #261, if you are in auto-name mode and remove
your first mapping you shoudl change the name. Comment this since
the logic required more than 10 seconds thought.
  • Loading branch information
baconpaul committed Jan 12, 2019
1 parent 8dc86d3 commit f444773
Showing 1 changed file with 55 additions and 10 deletions.
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

0 comments on commit f444773

Please sign in to comment.