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

Add copy to clipboard to ModList #6773

Merged
merged 1 commit into from
Jan 8, 2023
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
30 changes: 29 additions & 1 deletion src/surge-xt/gui/overlays/ModulationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ struct ModulationSideControls : public juce::Component,
dispW->setValue(dwv / 3.0);
dispW->setDraggable(true);
valueChanged(dispW.get());

copyW = std::make_unique<Surge::Widgets::SelfDrawButton>("Copy to Clipboard");
copyW->setAccessible(true);
copyW->setStorage(&(editor->synth->storage));
copyW->setTitle("Copy to Clipboard");
copyW->setDescription("Copy to Clipboard");
copyW->setSkin(skin);
copyW->onClick = [this]() { doCopyToClipboard(); };
addAndMakeVisible(*copyW);
}

void resized() override
Expand Down Expand Up @@ -162,6 +171,9 @@ struct ModulationSideControls : public juce::Component,
dispL->setBounds(b);
b = b.translated(0, h);
dispW->setBounds(b.withHeight(h * 4));

b = b.translated(0, h * 4.5 + m);
copyW->setBounds(b);
}

void paint(juce::Graphics &g) override
Expand Down Expand Up @@ -241,9 +253,12 @@ struct ModulationSideControls : public juce::Component,
}
}

void doCopyToClipboard();

std::unique_ptr<juce::Label> sortL, filterL, addL, dispL;
std::unique_ptr<Surge::Widgets::MultiSwitchSelfDraw> sortW, filterW, addSourceW, addTargetW,
dispW;
std::unique_ptr<Surge::Widgets::SelfDrawButton> copyW;
SurgeGUIEditor *sge;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationSideControls);
Expand Down Expand Up @@ -515,7 +530,8 @@ struct ModulationListContents : public juce::Component, public Surge::GUI::SkinC
{
contents->editor->viewport->setViewPosition(0, 0);
}
surgeLikeSlider->grabKeyboardFocus();
if (surgeLikeSlider->isShowing())
surgeLikeSlider->grabKeyboardFocus();
}
bool firstInSort{false}, hasFollower{false};
bool isTop{false}, isAfterTop{false}, isLast{false};
Expand Down Expand Up @@ -1102,6 +1118,18 @@ struct ModulationListContents : public juce::Component, public Surge::GUI::SkinC
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationListContents);
};

void ModulationSideControls::doCopyToClipboard()
{
std::ostringstream oss;
oss << "Modulation List for " << editor->ed->getStorage()->getPatch().name << "\n";
for (const auto &r : editor->modContents->dataRows)
{
oss << " Source: " << r.sname << "; Target: " << r.pname << "; Depth: " << r.mss.valplus
<< " " << (r.isBipolar ? "(Bipolar)" : "(Unipolar)") << "\n";
}
juce::SystemClipboard::copyTextToClipboard(oss.str());
}

void ModulationSideControls::valueChanged(GUI::IComponentTagValue *c)
{
auto tag = c->getTag();
Expand Down