Skip to content

Commit

Permalink
Add context menu help entries for mod list and formula editor (#5984)
Browse files Browse the repository at this point in the history
Closes #5778
  • Loading branch information
mkruselj authored Mar 21, 2022
1 parent 738f7e8 commit 8163ec5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 6 deletions.
1 change: 1 addition & 0 deletions resources/surge-shared/paramdocumentation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<special id="wavetables" help_url="#wavetable"/>
<special id="mseg-editor" help_url="#multi-segment-envelope-generator-mseg"/>
<special id="formula-editor" help_url="#formula"/>
<special id="mod-list" help_url="#modulation-list"/>
<special id="macro-modbutton" help_url="#macros"/>
<special id="lfo-modbutton" help_url="#lfos"/>
<special id="internalmod-modbutton" help_url="#internal-modulators"/>
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/SurgeSynthProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void SurgeSynthProcessor::applyMidi(const juce::MidiMessageMetadata &it)
else if (m.isProgramChange())
{
// apparently this is not enough to actually execute SurgeSynthesizer::programChange
// for whatever reason!
// in VST3 case
surge->programChange(ch, m.getProgramChangeNumber());
}
else
Expand Down
44 changes: 41 additions & 3 deletions src/surge-xt/gui/overlays/LuaEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "WavetableScriptEvaluator.h"
#include "LuaSupport.h"
#include "widgets/MultiSwitch.h"
#include "widgets/MenuCustomComponents.h"

namespace Surge
{
Expand Down Expand Up @@ -130,11 +131,13 @@ void CodeEditorContainerWithApply::codeDocumentTextInserted(const juce::String &
applyButton->setEnabled(true);
setApplyEnabled(true);
}

void CodeEditorContainerWithApply::codeDocumentTextDeleted(int startIndex, int endIndex)
{
applyButton->setEnabled(true);
setApplyEnabled(true);
}

bool CodeEditorContainerWithApply::keyPressed(const juce::KeyPress &key, juce::Component *o)
{
if (key.getKeyCode() == juce::KeyPress::returnKey && key.getModifiers().isCommandDown())
Expand Down Expand Up @@ -249,6 +252,7 @@ struct ExpandingFormulaDebugger : public juce::Component, public Surge::GUI::Ski
else
g.fillAll(skin->getColor(Colors::FormulaEditor::Debugger::Row));
}

void paintCell(juce::Graphics &g, int rowNumber, int columnId, int w, int h,
bool rowIsSelected) override
{
Expand Down Expand Up @@ -295,6 +299,7 @@ struct ExpandingFormulaDebugger : public juce::Component, public Surge::GUI::Ski
std::unique_ptr<juce::Label> dPhaseLabel;

void paint(juce::Graphics &g) override { g.fillAll(skin->getColor(Colors::MSEGEditor::Panel)); }

void onSkinChanged() override { debugTableDataModel->setSkin(skin, associatedBitmapStore); }

void setOpen(bool b)
Expand Down Expand Up @@ -337,7 +342,9 @@ struct FormulaControlArea : public juce::Component,
};

FormulaModulatorEditor *overlay{nullptr};
FormulaControlArea(FormulaModulatorEditor *ol) : overlay(ol)
SurgeGUIEditor *editor{nullptr};

FormulaControlArea(FormulaModulatorEditor *ol, SurgeGUIEditor *ed) : overlay(ol), editor(ed)
{
setAccessible(true);
setTitle("Controls");
Expand Down Expand Up @@ -467,9 +474,40 @@ struct FormulaControlArea : public juce::Component,
return res;
}

int32_t controlModifierClicked(GUI::IComponentTagValue *c, const juce::ModifierKeys &mods,
bool isDoubleClickEvent) override
{
auto tag = (tags)(c->getTag());

switch (tag)
{
case tag_select_tab:
case tag_code_apply:
case tag_debugger_show:
case tag_debugger_init:
case tag_debugger_step:
{
juce::PopupMenu contextMenu;

auto msurl = editor->helpURLForSpecial("formula-editor");
auto hurl = editor->fullyResolvedHelpURL(msurl);

editor->addHelpHeaderTo("Formula Editor", hurl, contextMenu);

contextMenu.showMenuAsync(editor->popupMenuOptions(this, false));
}
break;
default:
break;
}

return 0;
}

void valueChanged(GUI::IComponentTagValue *c) override
{
auto tag = (tags)(c->getTag());

switch (tag)
{
case tag_select_tab:
Expand Down Expand Up @@ -544,7 +582,7 @@ FormulaModulatorEditor::FormulaModulatorEditor(SurgeGUIEditor *ed, SurgeStorage
FormulaModulatorStorage *fs, int lid, int scene,
Surge::GUI::Skin::ptr_t skin)
: CodeEditorContainerWithApply(ed, s, skin, false), lfos(ls), scene(scene), formulastorage(fs),
lfo_id(lid)
lfo_id(lid), editor(ed)
{
mainEditor->setScrollbarThickness(8);
mainEditor->setTitle("LUA Modulator Code");
Expand All @@ -563,7 +601,7 @@ FormulaModulatorEditor::FormulaModulatorEditor(SurgeGUIEditor *ed, SurgeStorage
preludeDisplay->setDescription("LUA Prelude Code");
EditorColors::setColorsFromSkin(preludeDisplay.get(), skin);

controlArea = std::make_unique<FormulaControlArea>(this);
controlArea = std::make_unique<FormulaControlArea>(this, editor);
addAndMakeVisible(*controlArea);
addAndMakeVisible(*mainEditor);
addChildComponent(*preludeDisplay);
Expand Down
1 change: 1 addition & 0 deletions src/surge-xt/gui/overlays/LuaEditors.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct FormulaModulatorEditor : public CodeEditorContainerWithApply

LFOStorage *lfos{nullptr};
FormulaModulatorStorage *formulastorage{nullptr};
SurgeGUIEditor *editor{nullptr};
int lfo_id, scene;

void onSkinChanged() override;
Expand Down
24 changes: 22 additions & 2 deletions src/surge-xt/gui/widgets/ModulationSourceButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "SurgeGUIUtils.h"
#include "SurgeJUCEHelpers.h"
#include "AccessibleHelpers.h"
#include "widgets/MenuCustomComponents.h"

namespace Surge
{
Expand Down Expand Up @@ -410,7 +411,7 @@ void ModulationSourceButton::mouseDoubleClick(const juce::MouseEvent &event)
auto ccid = (int)getCurrentModSource() - ms_ctrl1;
auto sge = firstListenerOfType<SurgeGUIEditor>();

// See #5774 for wy this is commented out
// See #5774 for why this is commented out
// sge->openMacroRenameDialog(ccid, topRect.getTopLeft(), this);

return;
Expand Down Expand Up @@ -445,7 +446,7 @@ void ModulationSourceButton::mouseDoubleClick(const juce::MouseEvent &event)
int lfo_id = getCurrentModSource() - ms_lfo1;
auto sge = firstListenerOfType<SurgeGUIEditor>();

// See #5774 for wy this is commented out
// See #5774 for why this is commented out
// sge->openLFORenameDialog(lfo_id, rect.getTopLeft(), this);

return;
Expand Down Expand Up @@ -736,6 +737,25 @@ void ModulationOverviewLaunchButton::buttonClicked(Button *button)
repaint();
}

void ModulationOverviewLaunchButton::mouseDown(const juce::MouseEvent &event)
{
if (event.mods.isPopupMenu())
{
juce::PopupMenu contextMenu;

auto msurl = editor->helpURLForSpecial("mod-list");
auto hurl = editor->fullyResolvedHelpURL(msurl);

editor->addHelpHeaderTo("Modulation List", hurl, contextMenu);

contextMenu.showMenuAsync(editor->popupMenuOptions(this, false));
}
else
{
juce::Button::mouseDown(event);
}
}

void ModulationOverviewLaunchButton::paintButton(juce::Graphics &g,
bool shouldDrawButtonAsHighlighted,
bool shouldDrawButtonAsDown)
Expand Down
3 changes: 3 additions & 0 deletions src/surge-xt/gui/widgets/ModulationSourceButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ struct ModulationSourceButton : public juce::Component,
struct ModulationOverviewLaunchButton : public juce::Button,
juce::Button::Listener,
Surge::GUI::SkinConsumingComponent

{
ModulationOverviewLaunchButton(SurgeGUIEditor *ed)
: juce::Button("Open Modulation Overview"), editor(ed)
Expand All @@ -240,6 +241,8 @@ struct ModulationOverviewLaunchButton : public juce::Button,

void buttonClicked(Button *button) override;

void mouseDown(const juce::MouseEvent &event) override;

SurgeGUIEditor *editor;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationOverviewLaunchButton);
};
Expand Down

0 comments on commit 8163ec5

Please sign in to comment.