Skip to content

Commit

Permalink
Add alternates/index modulators to modbutton RMB context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruselj committed Aug 30, 2021
1 parent 7d73879 commit 133dcfd
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 23 deletions.
23 changes: 13 additions & 10 deletions src/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,15 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
{
#endif
}
else if (hu != "")
{
auto lurl = fullyResolvedHelpURL(hu);
std::string hs = std::string("[?] ") + modulatorName(modsource, false);
contextMenu.addItem(hs, [lurl]() { juce::URL(lurl).launchInDefaultBrowser(); });
}
else
{
if (hu != "")
{
auto lurl = fullyResolvedHelpURL(hu);
std::string hs = std::string("[?] ") + modulatorName(modsource, false);
contextMenu.addItem(hs, [lurl]() { juce::URL(lurl).launchInDefaultBrowser(); });
}
else
{
contextMenu.addItem(modulatorName(modsource, false), []() {});
}
contextMenu.addItem(modulatorName(modsource, false), []() {});
}

contextMenu.addSeparator();
Expand All @@ -355,6 +352,12 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
showModulationEditorDialog();
});

contextMenu.addSeparator();

cms->buildHamburgerMenu(contextMenu, true);

contextMenu.addSeparator();

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

Expand Down
78 changes: 65 additions & 13 deletions src/gui/widgets/ModulationSourceButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,69 @@ void ModulationSourceButton::paint(juce::Graphics &g)
}
}

void ModulationSourceButton::buildHamburgerMenu(juce::PopupMenu &menu,
const bool addedToModbuttonContextMenu)
{
int idx{0};
std::string hu;
auto modsource = getCurrentModSource();
auto sge = firstListenerOfType<SurgeGUIEditor>();

if (modsource >= ms_ctrl1 && modsource <= ms_ctrl8)
{
hu = sge->helpURLForSpecial("macro-modbutton");
}
else if (modsource >= ms_lfo1 && modsource <= ms_slfo6)
{
hu = sge->helpURLForSpecial("lfo-modbutton");
}
else if ((modsource >= ms_ampeg && modsource <= ms_filtereg) ||
(modsource >= ms_random_bipolar && modsource <= ms_alternate_unipolar))
{
hu = sge->helpURLForSpecial("internalmod-modbutton");
}
else
{
hu = sge->helpURLForSpecial("other-modbutton");
}

if (!addedToModbuttonContextMenu)
{
if (hu != "")
{
auto lurl = sge->fullyResolvedHelpURL(hu);
std::string hs = std::string("[?] ") + sge->modulatorName(modsource, false);
menu.addItem(hs, [lurl]() { juce::URL(lurl).launchInDefaultBrowser(); });
}
else
{
menu.addItem(sge->modulatorName(modsource, false), []() {});
}

menu.addSeparator();
}

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

if (addedToModbuttonContextMenu)
{
modName = "Switch to " + modName;
}

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

idx++;
}
}

void ModulationSourceButton::mouseDown(const juce::MouseEvent &event)
{
mouseMode = CLICK;
Expand All @@ -252,22 +315,11 @@ void ModulationSourceButton::mouseDown(const juce::MouseEvent &event)
if (needsHamburger() && hamburgerHome.contains(event.position.toInt()))
{
auto menu = juce::PopupMenu();
int idx{0};

for (auto e : modlist)
{
menu.addItem(std::get<3>(e), [this, idx]() {
this->modlistIndex = idx;
mouseMode = HAMBURGER;
notifyValueChanged();
mouseMode = NONE;
repaint();
});

idx++;
}
buildHamburgerMenu(menu, false);

mouseMode = HAMBURGER;

menu.showMenuAsync(juce::PopupMenu::Options());

return;
Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/ModulationSourceButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ struct ModulationSourceButton : public juce::Component,
DRAG_COMPONENT_HAPPEN,
HAMBURGER
} mouseMode{NONE};

MouseState getMouseMode() const { return mouseMode; }

juce::ComponentDragger componentDragger;
juce::Rectangle<int> mouseDownBounds;
float valAtMouseDown{0};
Expand All @@ -162,6 +164,9 @@ struct ModulationSourceButton : public juce::Component,
void mouseDrag(const juce::MouseEvent &event) override;
void mouseWheelMove(const juce::MouseEvent &event,
const juce::MouseWheelDetails &wheel) override;

void buildHamburgerMenu(juce::PopupMenu &menu, const bool addedToModbuttonContextMenu);

Surge::GUI::WheelAccumulationHelper wheelAccumulationHelper;

void resized() override;
Expand Down

0 comments on commit 133dcfd

Please sign in to comment.