From eace8023c9c26a44082a72d2587a24847ffedade Mon Sep 17 00:00:00 2001 From: yoshih Date: Sat, 4 Jan 2025 06:27:51 +0800 Subject: [PATCH 01/13] first pass, compiles --- src/surge-fx/CMakeLists.txt | 1 + src/surge-fx/SurgeFXDefaultEditor.cpp | 227 ++++++++++++++++++++++++++ src/surge-fx/SurgeFXDefaultEditor.h | 53 ++++++ src/surge-fx/SurgeFXEditor.cpp | 223 ++----------------------- src/surge-fx/SurgeFXEditor.h | 12 +- src/surge-fx/SurgeLookAndFeel.h | 3 +- 6 files changed, 303 insertions(+), 216 deletions(-) create mode 100644 src/surge-fx/SurgeFXDefaultEditor.cpp create mode 100644 src/surge-fx/SurgeFXDefaultEditor.h diff --git a/src/surge-fx/CMakeLists.txt b/src/surge-fx/CMakeLists.txt index 105fdb6dda9..3104204dbf7 100644 --- a/src/surge-fx/CMakeLists.txt +++ b/src/surge-fx/CMakeLists.txt @@ -58,6 +58,7 @@ target_sources(${PROJECT_NAME} PRIVATE SurgeFXEditor.cpp SurgeFXEditor.h SurgeFXProcessor.cpp + SurgeFXDefaultEditor.cpp SurgeFXProcessor.h SurgeLookAndFeel.h FXOpenSoundControl.cpp diff --git a/src/surge-fx/SurgeFXDefaultEditor.cpp b/src/surge-fx/SurgeFXDefaultEditor.cpp new file mode 100644 index 00000000000..bfce354bdd4 --- /dev/null +++ b/src/surge-fx/SurgeFXDefaultEditor.cpp @@ -0,0 +1,227 @@ +#include "SurgeFXDefaultEditor.h" + +SurgeFXDefaultEditor::SurgeFXDefaultEditor(SurgefxAudioProcessor &p) : processor(p) +{ + + for (int i = 0; i < n_fx_params; ++i) + { + auto knob = std::make_unique(); + auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); + + // knob->setStyle(styleSheet); + knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); + + auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); + knobSource->setValueFromGUI(processor.getFXStorageValue01(i)); + knobSource->setLabel(paramName + " Knob"); + + knob->setSource(knobSource.get()); + + addAndMakeVisible(knob.get()); + knobs.push_back(std::move(knob)); + sources.push_back(std::move(knobSource)); + + fxTempoSync[i].setOnOffImage(BinaryData::TS_Act_svg, BinaryData::TS_Act_svgSize, + BinaryData::TS_Deact_svg, BinaryData::TS_Deact_svgSize); + fxTempoSync[i].setEnabled(processor.canTempoSync(i)); + fxTempoSync[i].setToggleState(processor.getFXStorageTempoSync(i), + juce::NotificationType::dontSendNotification); + fxTempoSync[i].onClick = [i, this]() { + this->processor.setUserEditingParamFeature(i, true); + this->processor.setFXParamTempoSync(i, this->fxTempoSync[i].getToggleState()); + this->processor.setFXStorageTempoSync(i, this->fxTempoSync[i].getToggleState()); + fxParamDisplay[i].setDisplay( + processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); + this->processor.setUserEditingParamFeature(i, false); + }; + + fxTempoSync[i].setTitle("Parameter " + std::to_string(i) + " TempoSync"); + addAndMakeVisible(&(fxTempoSync[i])); + + fxDeactivated[i].setOnOffImage(BinaryData::DE_Act_svg, BinaryData::DE_Act_svgSize, + BinaryData::DE_Deact_svg, BinaryData::DE_Deact_svgSize); + fxDeactivated[i].setEnabled(processor.canDeactitvate(i)); + fxDeactivated[i].setToggleState(processor.getFXStorageDeactivated(i), + juce::NotificationType::dontSendNotification); + fxDeactivated[i].onClick = [i, this]() { + this->processor.setUserEditingParamFeature(i, true); + this->processor.setFXParamDeactivated(i, this->fxDeactivated[i].getToggleState()); + this->processor.setFXStorageDeactivated(i, this->fxDeactivated[i].getToggleState()); + // Special case - coupled dectivation + this->reset(); + this->processor.setUserEditingParamFeature(i, false); + }; + fxDeactivated[i].setTitle("Parameter " + std::to_string(i) + " Deactivate"); + addAndMakeVisible(&(fxDeactivated[i])); + + fxExtended[i].setOnOffImage(BinaryData::EX_Act_svg, BinaryData::EX_Act_svgSize, + BinaryData::EX_Deact_svg, BinaryData::EX_Deact_svgSize); + fxExtended[i].setEnabled(processor.canExtend(i)); + fxExtended[i].setToggleState(processor.getFXStorageExtended(i), + juce::NotificationType::dontSendNotification); + fxExtended[i].onClick = [i, this]() { + this->processor.setUserEditingParamFeature(i, true); + this->processor.setFXParamExtended(i, this->fxExtended[i].getToggleState()); + this->processor.setFXStorageExtended(i, this->fxExtended[i].getToggleState()); + fxParamDisplay[i].setDisplay( + processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); + this->processor.setUserEditingParamFeature(i, false); + }; + fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); + addAndMakeVisible(&(fxExtended[i])); + + fxAbsoluted[i].setOnOffImage(BinaryData::AB_Act_svg, BinaryData::AB_Act_svgSize, + BinaryData::AB_Deact_svg, BinaryData::AB_Deact_svgSize); + fxAbsoluted[i].setEnabled(processor.canAbsolute(i)); + fxAbsoluted[i].setToggleState(processor.getFXParamAbsolute(i), + juce::NotificationType::dontSendNotification); + fxAbsoluted[i].onClick = [i, this]() { + this->processor.setUserEditingParamFeature(i, true); + this->processor.setFXParamAbsolute(i, this->fxAbsoluted[i].getToggleState()); + this->processor.setFXStorageAbsolute(i, this->fxAbsoluted[i].getToggleState()); + + fxParamDisplay[i].setDisplay( + processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); + this->processor.setUserEditingParamFeature(i, false); + }; + + fxAbsoluted[i].setTitle("Parameter " + std::to_string(i) + " Absoluted"); + addAndMakeVisible(&(fxAbsoluted[i])); + + processor.prepareParametersAbsentAudio(); + fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); + fxParamDisplay[i].setName(processor.getParamName(i).c_str()); + fxParamDisplay[i].setDisplay(processor.getParamValue(i)); + fxParamDisplay[i].setEnabled(processor.getParamEnabled(i)); + fxParamDisplay[i].onOverlayEntered = [i, this](const std::string &s) { + processor.setParameterByString(i, s); + }; + + addAndMakeVisible(&(fxParamDisplay[i])); + } +} + +SurgeFXDefaultEditor::~SurgeFXDefaultEditor() {} + +void SurgeFXDefaultEditor::paint(juce::Graphics &g) { g.fillAll(juce::Colours::darkgrey); } + +void SurgeFXDefaultEditor::reset() +{ + knobs.clear(); + sources.clear(); + + auto st = [](auto &thing, const std::string &title) { + thing.setTitle(title); + if (auto *handler = thing.getAccessibilityHandler()) + { + handler->notifyAccessibilityEvent(juce::AccessibilityEvent::titleChanged); + handler->notifyAccessibilityEvent(juce::AccessibilityEvent::valueChanged); + } + }; + + for (int i = 0; i < n_fx_params; ++i) + { + auto knob = std::make_unique(); + auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); + + // knob->setStyle(styleSheet); + knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); + + auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); + knobSource->setValueFromGUI(processor.getFXStorageValue01(i)); + auto name = paramName + " Knob"; + knobSource->setLabel(name); + + knob->setSource(knobSource.get()); + knob->setEnabled(processor.getParamEnabled(i)); + + addAndMakeVisible(*knob); + knobs.push_back(std::move(knob)); + sources.push_back(std::move(knobSource)); + + fxParamDisplay[i].setDisplay(processor.getParamValue(i).c_str()); + fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); + fxParamDisplay[i].setName(processor.getParamName(i).c_str()); + fxParamDisplay[i].allowsTypein = processor.canSetParameterByString(i); + + fxParamDisplay[i].setEnabled(processor.getParamEnabled(i)); + fxParamDisplay[i].setAppearsDeactivated(processor.getFXStorageAppearsDeactivated(i)); + + fxTempoSync[i].setEnabled(processor.canTempoSync(i)); + fxTempoSync[i].setAccessible(processor.canTempoSync(i)); + fxTempoSync[i].setToggleState(processor.getFXStorageTempoSync(i), + juce::NotificationType::dontSendNotification); + st(fxTempoSync[i], name + " Tempo Synced"); + fxDeactivated[i].setEnabled(false); + + fxExtended[i].setEnabled(processor.canExtend(i)); + fxExtended[i].setToggleState(processor.getFXStorageExtended(i), + juce::NotificationType::dontSendNotification); + fxExtended[i].setAccessible(processor.canExtend(i)); + st(fxExtended[i], name + " Extended"); + fxAbsoluted[i].setEnabled(processor.canAbsolute(i)); + fxAbsoluted[i].setToggleState(processor.getFXStorageAbsolute(i), + juce::NotificationType::dontSendNotification); + fxAbsoluted[i].setAccessible(processor.canAbsolute(i)); + st(fxAbsoluted[i], name + " Absolute"); + fxDeactivated[i].setEnabled(processor.canDeactitvate(i)); + fxDeactivated[i].setToggleState(processor.getFXStorageDeactivated(i), + juce::NotificationType::dontSendNotification); + fxDeactivated[i].setAccessible(processor.canDeactitvate(i)); + st(fxDeactivated[i], name + " Deactivated"); + } +} +void SurgeFXDefaultEditor::resized() +{ + int ypos0 = topSection - 5; + int rowHeight = (getHeight() - topSection - 40 - 10) / 6.0; + int byoff = 7; + + int sliderOff = 5; + if (getWidth() < baseWidth) + sliderOff = 2; + + for (int i = 0; i < n_fx_params; ++i) + { + juce::Rectangle position{(i / 6) * getWidth() / 2 + sliderOff, + (i % 6) * rowHeight + ypos0, rowHeight - sliderOff, + rowHeight - sliderOff}; + + position = position.reduced(position.getWidth() * 0.10, position.getHeight() * 0.10); + + knobs.at(i).get()->setBounds(position); + + int buttonSize = 19; + if (getWidth() < baseWidth) + buttonSize = 17; + int buttonMargin = 1; + juce::Rectangle tsPos{(i / 6) * getWidth() / 2 + 2 + rowHeight - 5, + (i % 6) * rowHeight + ypos0 + byoff + buttonMargin, buttonSize, + buttonSize}; + fxTempoSync[i].setBounds(tsPos); + + juce::Rectangle daPos{(i / 6) * getWidth() / 2 + 2 + rowHeight - 5, + (i % 6) * rowHeight + ypos0 + byoff + 2 * buttonMargin + + buttonSize, + buttonSize, buttonSize}; + fxDeactivated[i].setBounds(daPos); + + juce::Rectangle exPos{ + (i / 6) * getWidth() / 2 + 2 + rowHeight - 5 + buttonMargin + buttonSize, + (i % 6) * rowHeight + ypos0 + byoff + 1 * buttonMargin + 0 * buttonSize, buttonSize, + buttonSize}; + fxExtended[i].setBounds(exPos); + + juce::Rectangle abPos{ + (i / 6) * getWidth() / 2 + 2 + rowHeight - 5 + buttonMargin + buttonSize, + (i % 6) * rowHeight + ypos0 + byoff + 2 * buttonMargin + 1 * buttonSize, buttonSize, + buttonSize}; + fxAbsoluted[i].setBounds(abPos); + + juce::Rectangle dispPos{ + (i / 6) * getWidth() / 2 + 4 + rowHeight - 5 + 2 * buttonMargin + 2 * buttonSize, + (i % 6) * rowHeight + ypos0, + getWidth() / 2 - rowHeight - 8 - 2 * buttonMargin - 2 * buttonSize, rowHeight - 5}; + fxParamDisplay[i].setBounds(dispPos); + } +} \ No newline at end of file diff --git a/src/surge-fx/SurgeFXDefaultEditor.h b/src/surge-fx/SurgeFXDefaultEditor.h new file mode 100644 index 00000000000..2aba93d907a --- /dev/null +++ b/src/surge-fx/SurgeFXDefaultEditor.h @@ -0,0 +1,53 @@ +#pragma once + +#include // Include memory header for std::unique_ptr + +#include "SurgeFXProcessor.h" +#include "SurgeLookAndFeel.h" +#include "KnobSource.h" + +#include "juce_gui_basics/juce_gui_basics.h" + +#include +#include + +#include "SurgeStorage.h" +#include "Effect.h" +#include "FXOpenSoundControl.h" +#include +#include "sst/filters/HalfRateFilter.h" + +#include "juce_audio_processors/juce_audio_processors.h" + +class SurgeFXDefaultEditor : public juce::Component +{ + public: + SurgeFXDefaultEditor(SurgefxAudioProcessor &); + + ~SurgeFXDefaultEditor() override; + + void paint(juce::Graphics &) override; + void resized() override; + void setProjectFont(juce::Font font) { projectFont = font; } + void reset(); + + SurgeFXParamDisplay fxParamDisplay[n_fx_params]; + std::vector> sources; + + private: + static constexpr int topSection = 80; + static constexpr int baseWidth = 600; + + SurgefxAudioProcessor &processor; + + SurgeTempoSyncSwitch fxTempoSync[n_fx_params]; + SurgeTempoSyncSwitch fxDeactivated[n_fx_params]; + SurgeTempoSyncSwitch fxExtended[n_fx_params]; + SurgeTempoSyncSwitch fxAbsoluted[n_fx_params]; + + std::vector> knobs; + + juce::Font projectFont; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SurgeFXDefaultEditor); +}; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index ffac9682e77..09335ef751b 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -138,6 +138,9 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & picker = std::make_unique(this); addAndMakeVisibleRecordOrder(picker.get()); + defaultKnobLayout = std::make_unique(p); + addAndMakeVisibleRecordOrder(defaultKnobLayout.get()); + auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); auto surgeOrange = findColour(SurgeLookAndFeel::SurgeColourIds::orange); @@ -147,103 +150,6 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & styleSheet->setColour(knobStyle::styleClass, knobStyle::value, surgeOrange); styleSheet->setColour(knobStyle::styleClass, knobStyle::value_hover, surgeOrange); - for (int i = 0; i < n_fx_params; ++i) - { - auto knob = std::make_unique(); - auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); - - knob->setStyle(styleSheet); - knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); - - auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); - knobSource->setValueFromGUI(processor.getFXStorageValue01(i)); - knobSource->setLabel(paramName + " Knob"); - - knob->setSource(knobSource.get()); - - addAndMakeVisible(knob.get()); - knobs.push_back(std::move(knob)); - sources.push_back(std::move(knobSource)); - - fxTempoSync[i].setOnOffImage(BinaryData::TS_Act_svg, BinaryData::TS_Act_svgSize, - BinaryData::TS_Deact_svg, BinaryData::TS_Deact_svgSize); - fxTempoSync[i].setEnabled(processor.canTempoSync(i)); - fxTempoSync[i].setToggleState(processor.getFXStorageTempoSync(i), - juce::NotificationType::dontSendNotification); - fxTempoSync[i].onClick = [i, this]() { - this->processor.setUserEditingParamFeature(i, true); - this->processor.setFXParamTempoSync(i, this->fxTempoSync[i].getToggleState()); - this->processor.setFXStorageTempoSync(i, this->fxTempoSync[i].getToggleState()); - fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); - this->processor.setUserEditingParamFeature(i, false); - }; - - fxTempoSync[i].setTitle("Parameter " + std::to_string(i) + " TempoSync"); - addAndMakeVisibleRecordOrder(&(fxTempoSync[i])); - - fxDeactivated[i].setOnOffImage(BinaryData::DE_Act_svg, BinaryData::DE_Act_svgSize, - BinaryData::DE_Deact_svg, BinaryData::DE_Deact_svgSize); - fxDeactivated[i].setEnabled(processor.canDeactitvate(i)); - fxDeactivated[i].setToggleState(processor.getFXStorageDeactivated(i), - juce::NotificationType::dontSendNotification); - fxDeactivated[i].onClick = [i, this]() { - this->processor.setUserEditingParamFeature(i, true); - this->processor.setFXParamDeactivated(i, this->fxDeactivated[i].getToggleState()); - this->processor.setFXStorageDeactivated(i, this->fxDeactivated[i].getToggleState()); - // Special case - coupled dectivation - this->resetLabels(); - this->processor.setUserEditingParamFeature(i, false); - }; - fxDeactivated[i].setTitle("Parameter " + std::to_string(i) + " Deactivate"); - addAndMakeVisibleRecordOrder(&(fxDeactivated[i])); - - fxExtended[i].setOnOffImage(BinaryData::EX_Act_svg, BinaryData::EX_Act_svgSize, - BinaryData::EX_Deact_svg, BinaryData::EX_Deact_svgSize); - fxExtended[i].setEnabled(processor.canExtend(i)); - fxExtended[i].setToggleState(processor.getFXStorageExtended(i), - juce::NotificationType::dontSendNotification); - fxExtended[i].onClick = [i, this]() { - this->processor.setUserEditingParamFeature(i, true); - this->processor.setFXParamExtended(i, this->fxExtended[i].getToggleState()); - this->processor.setFXStorageExtended(i, this->fxExtended[i].getToggleState()); - fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); - this->processor.setUserEditingParamFeature(i, false); - }; - fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); - addAndMakeVisibleRecordOrder(&(fxExtended[i])); - - fxAbsoluted[i].setOnOffImage(BinaryData::AB_Act_svg, BinaryData::AB_Act_svgSize, - BinaryData::AB_Deact_svg, BinaryData::AB_Deact_svgSize); - fxAbsoluted[i].setEnabled(processor.canAbsolute(i)); - fxAbsoluted[i].setToggleState(processor.getFXParamAbsolute(i), - juce::NotificationType::dontSendNotification); - fxAbsoluted[i].onClick = [i, this]() { - this->processor.setUserEditingParamFeature(i, true); - this->processor.setFXParamAbsolute(i, this->fxAbsoluted[i].getToggleState()); - this->processor.setFXStorageAbsolute(i, this->fxAbsoluted[i].getToggleState()); - - fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); - this->processor.setUserEditingParamFeature(i, false); - }; - - fxAbsoluted[i].setTitle("Parameter " + std::to_string(i) + " Absoluted"); - addAndMakeVisibleRecordOrder(&(fxAbsoluted[i])); - - processor.prepareParametersAbsentAudio(); - fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); - fxParamDisplay[i].setName(processor.getParamName(i).c_str()); - fxParamDisplay[i].setDisplay(processor.getParamValue(i)); - fxParamDisplay[i].setEnabled(processor.getParamEnabled(i)); - fxParamDisplay[i].onOverlayEntered = [i, this](const std::string &s) { - processor.setParameterByString(i, s); - }; - - addAndMakeVisibleRecordOrder(&(fxParamDisplay[i])); - } - fxNameLabel = std::make_unique("fxlabel", "Surge XT Effects"); fxNameLabel->setFont(juce::FontOptions(28)); fxNameLabel->setColour(juce::Label::textColourId, juce::Colours::black); @@ -292,61 +198,7 @@ void SurgefxAudioProcessorEditor::resetLabels() } }; - knobs.clear(); - sources.clear(); - - for (int i = 0; i < n_fx_params; ++i) - { - auto knob = std::make_unique(); - auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); - - knob->setStyle(styleSheet); - knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); - - auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); - knobSource->setValueFromGUI(processor.getFXStorageValue01(i)); - auto name = paramName + " Knob"; - knobSource->setLabel(name); - - knob->setSource(knobSource.get()); - knob->setEnabled(processor.getParamEnabled(i)); - - addAndMakeVisible(*knob); - knobs.push_back(std::move(knob)); - sources.push_back(std::move(knobSource)); - - fxParamDisplay[i].setDisplay(processor.getParamValue(i).c_str()); - fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); - fxParamDisplay[i].setName(processor.getParamName(i).c_str()); - fxParamDisplay[i].allowsTypein = processor.canSetParameterByString(i); - - fxParamDisplay[i].setEnabled(processor.getParamEnabled(i)); - fxParamDisplay[i].setAppearsDeactivated(processor.getFXStorageAppearsDeactivated(i)); - - fxTempoSync[i].setEnabled(processor.canTempoSync(i)); - fxTempoSync[i].setAccessible(processor.canTempoSync(i)); - fxTempoSync[i].setToggleState(processor.getFXStorageTempoSync(i), - juce::NotificationType::dontSendNotification); - st(fxTempoSync[i], name + " Tempo Synced"); - fxDeactivated[i].setEnabled(false); - - fxExtended[i].setEnabled(processor.canExtend(i)); - fxExtended[i].setToggleState(processor.getFXStorageExtended(i), - juce::NotificationType::dontSendNotification); - fxExtended[i].setAccessible(processor.canExtend(i)); - st(fxExtended[i], name + " Extended"); - fxAbsoluted[i].setEnabled(processor.canAbsolute(i)); - fxAbsoluted[i].setToggleState(processor.getFXStorageAbsolute(i), - juce::NotificationType::dontSendNotification); - fxAbsoluted[i].setAccessible(processor.canAbsolute(i)); - st(fxAbsoluted[i], name + " Absolute"); - fxDeactivated[i].setEnabled(processor.canDeactitvate(i)); - fxDeactivated[i].setToggleState(processor.getFXStorageDeactivated(i), - juce::NotificationType::dontSendNotification); - fxDeactivated[i].setAccessible(processor.canDeactitvate(i)); - st(fxDeactivated[i], name + " Deactivated"); - } - + defaultKnobLayout->reset(); picker->repaint(); int row = 0, col = 0; @@ -378,8 +230,9 @@ void SurgefxAudioProcessorEditor::paramsChangedCallback() { if (i < n_fx_params) { - sources.at(i)->setValueFromModel(fv[i]); - fxParamDisplay[i].setDisplay(processor.getParamValueFor(i, fv[i])); + defaultKnobLayout->sources.at(i)->setValueFromModel(fv[i]); + defaultKnobLayout->fxParamDisplay[i].setDisplay( + processor.getParamValueFor(i, fv[i])); } else { @@ -400,61 +253,21 @@ void SurgefxAudioProcessorEditor::paint(juce::Graphics &g) void SurgefxAudioProcessorEditor::resized() { - picker->setBounds(100, 10, getWidth() - 200, topSection - 30); + auto bounds = getLocalBounds(); + int topAreaHeight = + static_cast((static_cast(topSection) / baseHeight) * getHeight()); + std::cout << topAreaHeight << std::endl; + int bottomAreaHeight = static_cast((static_cast(40) / baseHeight) * getHeight()); - int ypos0 = topSection - 5; - int rowHeight = (getHeight() - topSection - 40 - 10) / 6.0; - int byoff = 7; + auto topArea = bounds.removeFromTop(topAreaHeight); + auto bottomArea = bounds.removeFromBottom(bottomAreaHeight); - int sliderOff = 5; - if (getWidth() < baseWidth) - sliderOff = 2; - for (int i = 0; i < n_fx_params; ++i) - { - juce::Rectangle position{(i / 6) * getWidth() / 2 + sliderOff, - (i % 6) * rowHeight + ypos0, rowHeight - sliderOff, - rowHeight - sliderOff}; - - position = position.reduced(position.getWidth() * 0.10, position.getHeight() * 0.10); - - knobs.at(i).get()->setBounds(position); - - int buttonSize = 19; - if (getWidth() < baseWidth) - buttonSize = 17; - int buttonMargin = 1; - juce::Rectangle tsPos{(i / 6) * getWidth() / 2 + 2 + rowHeight - 5, - (i % 6) * rowHeight + ypos0 + byoff + buttonMargin, buttonSize, - buttonSize}; - fxTempoSync[i].setBounds(tsPos); - - juce::Rectangle daPos{(i / 6) * getWidth() / 2 + 2 + rowHeight - 5, - (i % 6) * rowHeight + ypos0 + byoff + 2 * buttonMargin + - buttonSize, - buttonSize, buttonSize}; - fxDeactivated[i].setBounds(daPos); - - juce::Rectangle exPos{ - (i / 6) * getWidth() / 2 + 2 + rowHeight - 5 + buttonMargin + buttonSize, - (i % 6) * rowHeight + ypos0 + byoff + 1 * buttonMargin + 0 * buttonSize, buttonSize, - buttonSize}; - fxExtended[i].setBounds(exPos); - - juce::Rectangle abPos{ - (i / 6) * getWidth() / 2 + 2 + rowHeight - 5 + buttonMargin + buttonSize, - (i % 6) * rowHeight + ypos0 + byoff + 2 * buttonMargin + 1 * buttonSize, buttonSize, - buttonSize}; - fxAbsoluted[i].setBounds(abPos); - - juce::Rectangle dispPos{ - (i / 6) * getWidth() / 2 + 4 + rowHeight - 5 + 2 * buttonMargin + 2 * buttonSize, - (i % 6) * rowHeight + ypos0, - getWidth() / 2 - rowHeight - 8 - 2 * buttonMargin - 2 * buttonSize, rowHeight - 5}; - fxParamDisplay[i].setBounds(dispPos); - } + picker->setBounds(topArea); fxNameLabel->setFont(juce::FontOptions(28)); - fxNameLabel->setBounds(40, getHeight() - 40, 350, 38); + fxNameLabel->setBounds(bottomArea); + + defaultKnobLayout->setBounds(bounds); } int SurgefxAudioProcessorEditor::findLargestFittingZoomBetween( diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 86a02969198..0021797528d 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -24,6 +24,7 @@ #define SURGE_SRC_SURGE_FX_SURGEFXEDITOR_H #include "SurgeFXProcessor.h" +#include "SurgeFXDefaultEditor.h" #include "SurgeLookAndFeel.h" #include "KnobSource.h" @@ -57,7 +58,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, }; std::vector menu; std::unique_ptr picker; - + std::unique_ptr defaultKnobLayout; static constexpr int topSection = 80; void makeMenu(); @@ -110,16 +111,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, static constexpr int baseWidth = 600, baseHeight = 55 * 6 + 80 + topSection; - std::vector> knobs; - std::vector> sources; - private: - SurgeFXParamDisplay fxParamDisplay[n_fx_params]; - SurgeTempoSyncSwitch fxTempoSync[n_fx_params]; - SurgeTempoSyncSwitch fxDeactivated[n_fx_params]; - SurgeTempoSyncSwitch fxExtended[n_fx_params]; - SurgeTempoSyncSwitch fxAbsoluted[n_fx_params]; - void blastToggleState(int i); void resetLabels(); diff --git a/src/surge-fx/SurgeLookAndFeel.h b/src/surge-fx/SurgeLookAndFeel.h index 591983b78e4..6b2d692b8f7 100644 --- a/src/surge-fx/SurgeLookAndFeel.h +++ b/src/surge-fx/SurgeLookAndFeel.h @@ -1,3 +1,4 @@ +#pragma once /* * Surge XT - a free and open source hybrid synthesizer, * built by Surge Synth Team @@ -224,7 +225,7 @@ class SurgeLookAndFeel : public juce::LookAndFeel_V4 shouldDrawButtonAsDown); } - void drawCornerResizer(juce::Graphics &g, int w, int h, bool, bool) override{}; + void drawCornerResizer(juce::Graphics &g, int w, int h, bool, bool) override {}; void paintComponentBackground(juce::Graphics &g, int w, int h) { From 6dffd8ab0a8602307f3cb4d2d7a03bb1e0d09a20 Mon Sep 17 00:00:00 2001 From: yoshih Date: Sat, 4 Jan 2025 10:30:03 +0800 Subject: [PATCH 02/13] rename to ParameterPanel --- src/surge-fx/CMakeLists.txt | 2 +- .../{SurgeFXDefaultEditor.cpp => ParameterPanel.cpp} | 12 ++++++------ .../{SurgeFXDefaultEditor.h => ParameterPanel.h} | 8 ++++---- src/surge-fx/SurgeFXEditor.cpp | 12 ++++++------ src/surge-fx/SurgeFXEditor.h | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) rename src/surge-fx/{SurgeFXDefaultEditor.cpp => ParameterPanel.cpp} (96%) rename src/surge-fx/{SurgeFXDefaultEditor.h => ParameterPanel.h} (85%) diff --git a/src/surge-fx/CMakeLists.txt b/src/surge-fx/CMakeLists.txt index 3104204dbf7..547c773f3a7 100644 --- a/src/surge-fx/CMakeLists.txt +++ b/src/surge-fx/CMakeLists.txt @@ -58,7 +58,7 @@ target_sources(${PROJECT_NAME} PRIVATE SurgeFXEditor.cpp SurgeFXEditor.h SurgeFXProcessor.cpp - SurgeFXDefaultEditor.cpp + ParameterPanel.cpp SurgeFXProcessor.h SurgeLookAndFeel.h FXOpenSoundControl.cpp diff --git a/src/surge-fx/SurgeFXDefaultEditor.cpp b/src/surge-fx/ParameterPanel.cpp similarity index 96% rename from src/surge-fx/SurgeFXDefaultEditor.cpp rename to src/surge-fx/ParameterPanel.cpp index bfce354bdd4..4949358929a 100644 --- a/src/surge-fx/SurgeFXDefaultEditor.cpp +++ b/src/surge-fx/ParameterPanel.cpp @@ -1,6 +1,6 @@ -#include "SurgeFXDefaultEditor.h" +#include "ParameterPanel.h" -SurgeFXDefaultEditor::SurgeFXDefaultEditor(SurgefxAudioProcessor &p) : processor(p) +ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) : processor(p) { for (int i = 0; i < n_fx_params; ++i) @@ -101,11 +101,11 @@ SurgeFXDefaultEditor::SurgeFXDefaultEditor(SurgefxAudioProcessor &p) : processor } } -SurgeFXDefaultEditor::~SurgeFXDefaultEditor() {} +ParameterPanel::~ParameterPanel() {} -void SurgeFXDefaultEditor::paint(juce::Graphics &g) { g.fillAll(juce::Colours::darkgrey); } +void ParameterPanel::paint(juce::Graphics &g) { g.fillAll(juce::Colours::darkgrey); } -void SurgeFXDefaultEditor::reset() +void ParameterPanel::reset() { knobs.clear(); sources.clear(); @@ -171,7 +171,7 @@ void SurgeFXDefaultEditor::reset() st(fxDeactivated[i], name + " Deactivated"); } } -void SurgeFXDefaultEditor::resized() +void ParameterPanel::resized() { int ypos0 = topSection - 5; int rowHeight = (getHeight() - topSection - 40 - 10) / 6.0; diff --git a/src/surge-fx/SurgeFXDefaultEditor.h b/src/surge-fx/ParameterPanel.h similarity index 85% rename from src/surge-fx/SurgeFXDefaultEditor.h rename to src/surge-fx/ParameterPanel.h index 2aba93d907a..29ae75029d1 100644 --- a/src/surge-fx/SurgeFXDefaultEditor.h +++ b/src/surge-fx/ParameterPanel.h @@ -19,12 +19,12 @@ #include "juce_audio_processors/juce_audio_processors.h" -class SurgeFXDefaultEditor : public juce::Component +class ParameterPanel : public juce::Component { public: - SurgeFXDefaultEditor(SurgefxAudioProcessor &); + ParameterPanel(SurgefxAudioProcessor &); - ~SurgeFXDefaultEditor() override; + ~ParameterPanel() override; void paint(juce::Graphics &) override; void resized() override; @@ -49,5 +49,5 @@ class SurgeFXDefaultEditor : public juce::Component juce::Font projectFont; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SurgeFXDefaultEditor); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParameterPanel); }; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 09335ef751b..aacea7d68d2 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -138,8 +138,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & picker = std::make_unique(this); addAndMakeVisibleRecordOrder(picker.get()); - defaultKnobLayout = std::make_unique(p); - addAndMakeVisibleRecordOrder(defaultKnobLayout.get()); + deafultParameterPanel = std::make_unique(p); + addAndMakeVisibleRecordOrder(deafultParameterPanel.get()); auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); auto surgeOrange = findColour(SurgeLookAndFeel::SurgeColourIds::orange); @@ -198,7 +198,7 @@ void SurgefxAudioProcessorEditor::resetLabels() } }; - defaultKnobLayout->reset(); + deafultParameterPanel->reset(); picker->repaint(); int row = 0, col = 0; @@ -230,8 +230,8 @@ void SurgefxAudioProcessorEditor::paramsChangedCallback() { if (i < n_fx_params) { - defaultKnobLayout->sources.at(i)->setValueFromModel(fv[i]); - defaultKnobLayout->fxParamDisplay[i].setDisplay( + deafultParameterPanel->sources.at(i)->setValueFromModel(fv[i]); + deafultParameterPanel->fxParamDisplay[i].setDisplay( processor.getParamValueFor(i, fv[i])); } else @@ -267,7 +267,7 @@ void SurgefxAudioProcessorEditor::resized() fxNameLabel->setFont(juce::FontOptions(28)); fxNameLabel->setBounds(bottomArea); - defaultKnobLayout->setBounds(bounds); + deafultParameterPanel->setBounds(bounds); } int SurgefxAudioProcessorEditor::findLargestFittingZoomBetween( diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 0021797528d..328055997bd 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -24,7 +24,7 @@ #define SURGE_SRC_SURGE_FX_SURGEFXEDITOR_H #include "SurgeFXProcessor.h" -#include "SurgeFXDefaultEditor.h" +#include "ParameterPanel.h" #include "SurgeLookAndFeel.h" #include "KnobSource.h" @@ -58,7 +58,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, }; std::vector menu; std::unique_ptr picker; - std::unique_ptr defaultKnobLayout; + std::unique_ptr deafultParameterPanel; static constexpr int topSection = 80; void makeMenu(); From 669ccee79a668c9a7409331d93ba9d5eabb3f3be Mon Sep 17 00:00:00 2001 From: yoshih Date: Sat, 4 Jan 2025 10:39:49 +0800 Subject: [PATCH 03/13] compiles but segfauts on setStyle --- src/surge-fx/ParameterPanel.cpp | 8 +++++++- src/surge-fx/ParameterPanel.h | 5 +++-- src/surge-fx/SurgeFXEditor.cpp | 3 +-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/surge-fx/ParameterPanel.cpp b/src/surge-fx/ParameterPanel.cpp index 4949358929a..57afb92700f 100644 --- a/src/surge-fx/ParameterPanel.cpp +++ b/src/surge-fx/ParameterPanel.cpp @@ -1,8 +1,14 @@ #include "ParameterPanel.h" -ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) : processor(p) +ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p, + std::shared_ptr styleSheet) + : processor(p), + sst::jucegui::style::StyleConsumer(sst::jucegui::components::Knob::Styles::styleClass) + { + setStyle(styleSheet); + for (int i = 0; i < n_fx_params; ++i) { auto knob = std::make_unique(); diff --git a/src/surge-fx/ParameterPanel.h b/src/surge-fx/ParameterPanel.h index 29ae75029d1..3dc8df00cdf 100644 --- a/src/surge-fx/ParameterPanel.h +++ b/src/surge-fx/ParameterPanel.h @@ -19,10 +19,11 @@ #include "juce_audio_processors/juce_audio_processors.h" -class ParameterPanel : public juce::Component +class ParameterPanel : public juce::Component, sst::jucegui::style::StyleConsumer { public: - ParameterPanel(SurgefxAudioProcessor &); + ParameterPanel(SurgefxAudioProcessor &, + std::shared_ptr styleSheet); ~ParameterPanel() override; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index aacea7d68d2..22064cee035 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -138,7 +138,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & picker = std::make_unique(this); addAndMakeVisibleRecordOrder(picker.get()); - deafultParameterPanel = std::make_unique(p); + deafultParameterPanel = std::make_unique(p, styleSheet); addAndMakeVisibleRecordOrder(deafultParameterPanel.get()); auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); @@ -256,7 +256,6 @@ void SurgefxAudioProcessorEditor::resized() auto bounds = getLocalBounds(); int topAreaHeight = static_cast((static_cast(topSection) / baseHeight) * getHeight()); - std::cout << topAreaHeight << std::endl; int bottomAreaHeight = static_cast((static_cast(40) / baseHeight) * getHeight()); auto topArea = bounds.removeFromTop(topAreaHeight); From 76669de2f8e35e4a10b30dac77d405f0b0a97166 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 13:27:29 +0800 Subject: [PATCH 04/13] i regret making this commit this big but this removes StyleConsumer (not needed) and reverts resized to the original format --- src/surge-fx/ParameterPanel.cpp | 22 +++++++++++++++------- src/surge-fx/ParameterPanel.h | 6 +++--- src/surge-fx/SurgeFXEditor.cpp | 33 ++++++++++++++------------------- src/surge-fx/SurgeFXEditor.h | 4 +--- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/surge-fx/ParameterPanel.cpp b/src/surge-fx/ParameterPanel.cpp index 57afb92700f..ba29afb39f2 100644 --- a/src/surge-fx/ParameterPanel.cpp +++ b/src/surge-fx/ParameterPanel.cpp @@ -1,20 +1,27 @@ #include "ParameterPanel.h" -ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p, - std::shared_ptr styleSheet) - : processor(p), - sst::jucegui::style::StyleConsumer(sst::jucegui::components::Knob::Styles::styleClass) +ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) + : processor(p), styleSheet(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + sst::jucegui::style::StyleSheet::DARK)) { + sst::jucegui::style::StyleSheet::initializeStyleSheets([]() {}); - setStyle(styleSheet); + using knobStyle = sst::jucegui::components::Knob::Styles; + // auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); + // auto surgeOrange = findColour(SurgeLookAndFeel::SurgeColourIds::orange); + + // // styleSheet->setColour(knobStyle::styleClass, knobStyle::handle, backgroundColour); + // // styleSheet->setColour(knobStyle::styleClass, knobStyle::knobbase, backgroundColour); + // // styleSheet->setColour(knobStyle::styleClass, knobStyle::value, surgeOrange); + // // styleSheet->setColour(knobStyle::styleClass, knobStyle::value_hover, surgeOrange); for (int i = 0; i < n_fx_params; ++i) { auto knob = std::make_unique(); auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); - // knob->setStyle(styleSheet); + knob->setStyle(styleSheet); knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); @@ -130,7 +137,7 @@ void ParameterPanel::reset() auto knob = std::make_unique(); auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); - // knob->setStyle(styleSheet); + knob->setStyle(styleSheet); knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); @@ -176,6 +183,7 @@ void ParameterPanel::reset() fxDeactivated[i].setAccessible(processor.canDeactitvate(i)); st(fxDeactivated[i], name + " Deactivated"); } + resized(); } void ParameterPanel::resized() { diff --git a/src/surge-fx/ParameterPanel.h b/src/surge-fx/ParameterPanel.h index 3dc8df00cdf..16e820ad4a0 100644 --- a/src/surge-fx/ParameterPanel.h +++ b/src/surge-fx/ParameterPanel.h @@ -19,11 +19,10 @@ #include "juce_audio_processors/juce_audio_processors.h" -class ParameterPanel : public juce::Component, sst::jucegui::style::StyleConsumer +class ParameterPanel : public juce::Component { public: - ParameterPanel(SurgefxAudioProcessor &, - std::shared_ptr styleSheet); + ParameterPanel(SurgefxAudioProcessor &); ~ParameterPanel() override; @@ -34,6 +33,7 @@ class ParameterPanel : public juce::Component, sst::jucegui::style::StyleConsume SurgeFXParamDisplay fxParamDisplay[n_fx_params]; std::vector> sources; + std::shared_ptr styleSheet; private: static constexpr int topSection = 80; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 22064cee035..9e1e7fb1edc 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -119,13 +119,8 @@ struct Picker : public juce::Component //============================================================================== SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor &p) - : AudioProcessorEditor(&p), - sst::jucegui::style::StyleConsumer(sst::jucegui::components::Knob::Styles::styleClass), - styleSheet(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - sst::jucegui::style::StyleSheet::DARK)), - processor(p) + : AudioProcessorEditor(&p), processor(p) { - sst::jucegui::style::StyleSheet::initializeStyleSheets([]() {}); processor.storage->addErrorListener(this); setAccessible(true); @@ -138,18 +133,9 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & picker = std::make_unique(this); addAndMakeVisibleRecordOrder(picker.get()); - deafultParameterPanel = std::make_unique(p, styleSheet); + deafultParameterPanel = std::make_unique(p); addAndMakeVisibleRecordOrder(deafultParameterPanel.get()); - auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); - auto surgeOrange = findColour(SurgeLookAndFeel::SurgeColourIds::orange); - - using knobStyle = sst::jucegui::components::Knob::Styles; - styleSheet->setColour(knobStyle::styleClass, knobStyle::handle, backgroundColour); - styleSheet->setColour(knobStyle::styleClass, knobStyle::knobbase, backgroundColour); - styleSheet->setColour(knobStyle::styleClass, knobStyle::value, surgeOrange); - styleSheet->setColour(knobStyle::styleClass, knobStyle::value_hover, surgeOrange); - fxNameLabel = std::make_unique("fxlabel", "Surge XT Effects"); fxNameLabel->setFont(juce::FontOptions(28)); fxNameLabel->setColour(juce::Label::textColourId, juce::Colours::black); @@ -175,7 +161,6 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & idleTimer = std::make_unique(this); idleTimer->startTimer(1000 / 5); - resized(); } SurgefxAudioProcessorEditor::~SurgefxAudioProcessorEditor() @@ -253,6 +238,16 @@ void SurgefxAudioProcessorEditor::paint(juce::Graphics &g) void SurgefxAudioProcessorEditor::resized() { + // old + picker->setBounds(100, 10, getWidth() - 200, topSection - 30); + int ypos0 = topSection - 5; + int rowHeight = (getHeight() - topSection - 40 - 10) / 6.0; + int byoff = 7; + + int sliderOff = 5; + if (getWidth() < baseWidth) + sliderOff = 2; + auto bounds = getLocalBounds(); int topAreaHeight = static_cast((static_cast(topSection) / baseHeight) * getHeight()); @@ -261,10 +256,10 @@ void SurgefxAudioProcessorEditor::resized() auto topArea = bounds.removeFromTop(topAreaHeight); auto bottomArea = bounds.removeFromBottom(bottomAreaHeight); - picker->setBounds(topArea); + // picker->setBounds(topArea); fxNameLabel->setFont(juce::FontOptions(28)); - fxNameLabel->setBounds(bottomArea); + fxNameLabel->setBounds(40, getHeight() - 40, 350, 38); deafultParameterPanel->setBounds(bounds); } diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 328055997bd..79f3a6cad85 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -38,8 +38,7 @@ */ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, juce::AsyncUpdater, - SurgeStorage::ErrorListener, - sst::jucegui::style::StyleConsumer + SurgeStorage::ErrorListener { public: SurgefxAudioProcessorEditor(SurgefxAudioProcessor &); @@ -142,7 +141,6 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, public: std::vector accessibleOrderWeakRefs; - std::shared_ptr styleSheet; public: std::unique_ptr createFocusTraverser() override; From 663e697ad8f890ea07b55dea63d58200aeb0c7c3 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 13:55:31 +0800 Subject: [PATCH 05/13] match the UI to the original --- src/surge-fx/ParameterPanel.cpp | 20 +++++++++----------- src/surge-fx/ParameterPanel.h | 3 +++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/surge-fx/ParameterPanel.cpp b/src/surge-fx/ParameterPanel.cpp index ba29afb39f2..3c487af0bef 100644 --- a/src/surge-fx/ParameterPanel.cpp +++ b/src/surge-fx/ParameterPanel.cpp @@ -2,19 +2,17 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) : processor(p), styleSheet(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - sst::jucegui::style::StyleSheet::DARK)) + sst::jucegui::style::StyleSheet ::DARK)) { - sst::jucegui::style::StyleSheet::initializeStyleSheets([]() {}); + sst::jucegui::style ::StyleSheet::initializeStyleSheets([]() {}); using knobStyle = sst::jucegui::components::Knob::Styles; - // auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); - // auto surgeOrange = findColour(SurgeLookAndFeel::SurgeColourIds::orange); - // // styleSheet->setColour(knobStyle::styleClass, knobStyle::handle, backgroundColour); - // // styleSheet->setColour(knobStyle::styleClass, knobStyle::knobbase, backgroundColour); - // // styleSheet->setColour(knobStyle::styleClass, knobStyle::value, surgeOrange); - // // styleSheet->setColour(knobStyle::styleClass, knobStyle::value_hover, surgeOrange); + styleSheet->setColour(knobStyle::styleClass, knobStyle::handle, backgroundColour); + styleSheet->setColour(knobStyle::styleClass, knobStyle::knobbase, backgroundColour); + styleSheet->setColour(knobStyle::styleClass, knobStyle::value, surgeOrange); + styleSheet->setColour(knobStyle::styleClass, knobStyle::value_hover, surgeOrange); for (int i = 0; i < n_fx_params; ++i) { @@ -116,7 +114,7 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) ParameterPanel::~ParameterPanel() {} -void ParameterPanel::paint(juce::Graphics &g) { g.fillAll(juce::Colours::darkgrey); } +void ParameterPanel::paint(juce::Graphics &g) { g.fillAll(backgroundColour); } void ParameterPanel::reset() { @@ -187,8 +185,8 @@ void ParameterPanel::reset() } void ParameterPanel::resized() { - int ypos0 = topSection - 5; - int rowHeight = (getHeight() - topSection - 40 - 10) / 6.0; + int ypos0 = 5; + int rowHeight = getHeight() / 6.0; int byoff = 7; int sliderOff = 5; diff --git a/src/surge-fx/ParameterPanel.h b/src/surge-fx/ParameterPanel.h index 16e820ad4a0..4bf6fd69f23 100644 --- a/src/surge-fx/ParameterPanel.h +++ b/src/surge-fx/ParameterPanel.h @@ -48,6 +48,9 @@ class ParameterPanel : public juce::Component std::vector> knobs; + juce::Colour backgroundColour = juce::Colour(205, 206, 212); + juce::Colour surgeOrange = juce::Colour(255, 144, 0); + juce::Font projectFont; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParameterPanel); From fd33c7ee5e0d0e5e2dc296195b493061fd4bfba2 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 14:02:34 +0800 Subject: [PATCH 06/13] new line to fix clang --- src/surge-fx/ParameterPanel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/surge-fx/ParameterPanel.cpp b/src/surge-fx/ParameterPanel.cpp index 3c487af0bef..ba61007d931 100644 --- a/src/surge-fx/ParameterPanel.cpp +++ b/src/surge-fx/ParameterPanel.cpp @@ -236,4 +236,4 @@ void ParameterPanel::resized() getWidth() / 2 - rowHeight - 8 - 2 * buttonMargin - 2 * buttonSize, rowHeight - 5}; fxParamDisplay[i].setBounds(dispPos); } -} \ No newline at end of file +} From 4fdda4ed53f78785b9f0cee8d5ee45ddc3241929 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 14:11:40 +0800 Subject: [PATCH 07/13] add back accessibility order feature --- src/surge-fx/ParameterPanel.cpp | 21 +++++++++++---------- src/surge-fx/ParameterPanel.h | 9 ++++++++- src/surge-fx/SurgeFXEditor.cpp | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/surge-fx/ParameterPanel.cpp b/src/surge-fx/ParameterPanel.cpp index ba61007d931..814c3e6d3a3 100644 --- a/src/surge-fx/ParameterPanel.cpp +++ b/src/surge-fx/ParameterPanel.cpp @@ -1,9 +1,10 @@ #include "ParameterPanel.h" -ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) +ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p, + std::vector &accessibleOrder) : processor(p), styleSheet(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - sst::jucegui::style::StyleSheet ::DARK)) - + sst::jucegui::style::StyleSheet::DARK)), + accessibleOrderWeakRefs(accessibleOrder) { sst::jucegui::style ::StyleSheet::initializeStyleSheets([]() {}); @@ -28,7 +29,7 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) knob->setSource(knobSource.get()); - addAndMakeVisible(knob.get()); + addAndMakeVisibleRecordOrder(knob.get()); knobs.push_back(std::move(knob)); sources.push_back(std::move(knobSource)); @@ -47,7 +48,7 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) }; fxTempoSync[i].setTitle("Parameter " + std::to_string(i) + " TempoSync"); - addAndMakeVisible(&(fxTempoSync[i])); + addAndMakeVisibleRecordOrder(&(fxTempoSync[i])); fxDeactivated[i].setOnOffImage(BinaryData::DE_Act_svg, BinaryData::DE_Act_svgSize, BinaryData::DE_Deact_svg, BinaryData::DE_Deact_svgSize); @@ -63,7 +64,7 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) this->processor.setUserEditingParamFeature(i, false); }; fxDeactivated[i].setTitle("Parameter " + std::to_string(i) + " Deactivate"); - addAndMakeVisible(&(fxDeactivated[i])); + addAndMakeVisibleRecordOrder(&(fxDeactivated[i])); fxExtended[i].setOnOffImage(BinaryData::EX_Act_svg, BinaryData::EX_Act_svgSize, BinaryData::EX_Deact_svg, BinaryData::EX_Deact_svgSize); @@ -79,7 +80,7 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) this->processor.setUserEditingParamFeature(i, false); }; fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); - addAndMakeVisible(&(fxExtended[i])); + addAndMakeVisibleRecordOrder(&(fxExtended[i])); fxAbsoluted[i].setOnOffImage(BinaryData::AB_Act_svg, BinaryData::AB_Act_svgSize, BinaryData::AB_Deact_svg, BinaryData::AB_Deact_svgSize); @@ -97,7 +98,7 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) }; fxAbsoluted[i].setTitle("Parameter " + std::to_string(i) + " Absoluted"); - addAndMakeVisible(&(fxAbsoluted[i])); + addAndMakeVisibleRecordOrder(&(fxAbsoluted[i])); processor.prepareParametersAbsentAudio(); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); @@ -108,7 +109,7 @@ ParameterPanel::ParameterPanel(SurgefxAudioProcessor &p) processor.setParameterByString(i, s); }; - addAndMakeVisible(&(fxParamDisplay[i])); + addAndMakeVisibleRecordOrder(&(fxParamDisplay[i])); } } @@ -146,7 +147,7 @@ void ParameterPanel::reset() knob->setSource(knobSource.get()); knob->setEnabled(processor.getParamEnabled(i)); - addAndMakeVisible(*knob); + addAndMakeVisibleRecordOrder(knob.get()); knobs.push_back(std::move(knob)); sources.push_back(std::move(knobSource)); diff --git a/src/surge-fx/ParameterPanel.h b/src/surge-fx/ParameterPanel.h index 4bf6fd69f23..15a6305c7a8 100644 --- a/src/surge-fx/ParameterPanel.h +++ b/src/surge-fx/ParameterPanel.h @@ -22,7 +22,7 @@ class ParameterPanel : public juce::Component { public: - ParameterPanel(SurgefxAudioProcessor &); + ParameterPanel(SurgefxAudioProcessor &, std::vector &accessibleOrder); ~ParameterPanel() override; @@ -50,8 +50,15 @@ class ParameterPanel : public juce::Component juce::Colour backgroundColour = juce::Colour(205, 206, 212); juce::Colour surgeOrange = juce::Colour(255, 144, 0); + std::vector &accessibleOrderWeakRefs; // Reference to the vector juce::Font projectFont; + void addAndMakeVisibleRecordOrder(juce::Component *c) + { + accessibleOrderWeakRefs.push_back(c); + addAndMakeVisible(c); + } + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParameterPanel); }; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 9e1e7fb1edc..452c188c207 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -133,7 +133,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & picker = std::make_unique(this); addAndMakeVisibleRecordOrder(picker.get()); - deafultParameterPanel = std::make_unique(p); + deafultParameterPanel = std::make_unique(p, accessibleOrderWeakRefs); addAndMakeVisibleRecordOrder(deafultParameterPanel.get()); fxNameLabel = std::make_unique("fxlabel", "Surge XT Effects"); From 700e9164e043922501789b8b6f44c6bbecf31f08 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 14:30:34 +0800 Subject: [PATCH 08/13] clean up headers --- src/surge-fx/ParameterPanel.h | 17 ++++------------- src/surge-fx/SurgeLookAndFeel.h | 4 +++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/surge-fx/ParameterPanel.h b/src/surge-fx/ParameterPanel.h index 15a6305c7a8..06f9e353dae 100644 --- a/src/surge-fx/ParameterPanel.h +++ b/src/surge-fx/ParameterPanel.h @@ -1,24 +1,13 @@ -#pragma once - -#include // Include memory header for std::unique_ptr +#ifndef SURGE_SRC_SURGE_FX_PARAMETERPANEL_H +#define SURGE_SRC_SURGE_FX_PARAMETERPANEL_H #include "SurgeFXProcessor.h" #include "SurgeLookAndFeel.h" #include "KnobSource.h" -#include "juce_gui_basics/juce_gui_basics.h" - #include #include -#include "SurgeStorage.h" -#include "Effect.h" -#include "FXOpenSoundControl.h" -#include -#include "sst/filters/HalfRateFilter.h" - -#include "juce_audio_processors/juce_audio_processors.h" - class ParameterPanel : public juce::Component { public: @@ -62,3 +51,5 @@ class ParameterPanel : public juce::Component JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParameterPanel); }; + +#endif // SURGE_SRC_SURGE_FX_PARAMETERPANEL_H diff --git a/src/surge-fx/SurgeLookAndFeel.h b/src/surge-fx/SurgeLookAndFeel.h index 6b2d692b8f7..3ae505dc93f 100644 --- a/src/surge-fx/SurgeLookAndFeel.h +++ b/src/surge-fx/SurgeLookAndFeel.h @@ -1,4 +1,3 @@ -#pragma once /* * Surge XT - a free and open source hybrid synthesizer, * built by Surge Synth Team @@ -21,6 +20,8 @@ * https://github.com/surge-synthesizer/surge */ +#ifndef SURGE_SRC_SURGE_FX_SURGELOOKANDFEEL_H +#define SURGE_SRC_SURGE_FX_SURGELOOKANDFEEL_H #include "version.h" #include "juce_gui_basics/juce_gui_basics.h" @@ -505,3 +506,4 @@ class SurgeTempoSyncSwitch : public juce::ToggleButton g.fillRoundedRectangle(kbounds, controlRadius); } }; +#endif // SURGE_SRC_SURGE_FX_SURGELOOKANDFEEL_H From a0ef9157c529df3d61f81bd04a90f12aa8eb4637 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 14:37:44 +0800 Subject: [PATCH 09/13] why is there as semicolon here --- src/surge-fx/SurgeLookAndFeel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/surge-fx/SurgeLookAndFeel.h b/src/surge-fx/SurgeLookAndFeel.h index 3ae505dc93f..14dc6ca5d0d 100644 --- a/src/surge-fx/SurgeLookAndFeel.h +++ b/src/surge-fx/SurgeLookAndFeel.h @@ -226,7 +226,7 @@ class SurgeLookAndFeel : public juce::LookAndFeel_V4 shouldDrawButtonAsDown); } - void drawCornerResizer(juce::Graphics &g, int w, int h, bool, bool) override {}; + void drawCornerResizer(juce::Graphics &g, int w, int h, bool, bool) override {} void paintComponentBackground(juce::Graphics &g, int w, int h) { From dbbb1150edb17a7c6dd71e1015d3feac7dd69e74 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 14:46:41 +0800 Subject: [PATCH 10/13] self review + why are there headers in the cmake sources --- src/surge-fx/CMakeLists.txt | 8 ++++---- src/surge-fx/SurgeFXEditor.cpp | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/surge-fx/CMakeLists.txt b/src/surge-fx/CMakeLists.txt index 547c773f3a7..8cea7b6e84b 100644 --- a/src/surge-fx/CMakeLists.txt +++ b/src/surge-fx/CMakeLists.txt @@ -56,13 +56,13 @@ juce_add_plugin(${PROJECT_NAME} target_sources(${PROJECT_NAME} PRIVATE SurgeFXEditor.cpp - SurgeFXEditor.h + # SurgeFXEditor.h SurgeFXProcessor.cpp ParameterPanel.cpp - SurgeFXProcessor.h - SurgeLookAndFeel.h + # SurgeFXProcessor.h + # SurgeLookAndFeel.h FXOpenSoundControl.cpp - FXOpenSoundControl.h + # FXOpenSoundControl.h ) target_link_libraries(${PROJECT_NAME} PRIVATE diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 452c188c207..d2d1670d57c 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -238,7 +238,6 @@ void SurgefxAudioProcessorEditor::paint(juce::Graphics &g) void SurgefxAudioProcessorEditor::resized() { - // old picker->setBounds(100, 10, getWidth() - 200, topSection - 30); int ypos0 = topSection - 5; int rowHeight = (getHeight() - topSection - 40 - 10) / 6.0; @@ -253,10 +252,8 @@ void SurgefxAudioProcessorEditor::resized() static_cast((static_cast(topSection) / baseHeight) * getHeight()); int bottomAreaHeight = static_cast((static_cast(40) / baseHeight) * getHeight()); - auto topArea = bounds.removeFromTop(topAreaHeight); - auto bottomArea = bounds.removeFromBottom(bottomAreaHeight); - - // picker->setBounds(topArea); + bounds.removeFromTop(topAreaHeight); + bounds.removeFromBottom(bottomAreaHeight); fxNameLabel->setFont(juce::FontOptions(28)); fxNameLabel->setBounds(40, getHeight() - 40, 350, 38); From b06ad43306c0daf017445dbab279aa33db5bde67 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 10 Jan 2025 14:47:13 +0800 Subject: [PATCH 11/13] yeah it builds fine without the headers in source --- src/surge-fx/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/surge-fx/CMakeLists.txt b/src/surge-fx/CMakeLists.txt index 8cea7b6e84b..01735367077 100644 --- a/src/surge-fx/CMakeLists.txt +++ b/src/surge-fx/CMakeLists.txt @@ -56,13 +56,9 @@ juce_add_plugin(${PROJECT_NAME} target_sources(${PROJECT_NAME} PRIVATE SurgeFXEditor.cpp - # SurgeFXEditor.h SurgeFXProcessor.cpp ParameterPanel.cpp - # SurgeFXProcessor.h - # SurgeLookAndFeel.h FXOpenSoundControl.cpp - # FXOpenSoundControl.h ) target_link_libraries(${PROJECT_NAME} PRIVATE From 4a639bef1516f904092bbc1911fc82494bdee3af Mon Sep 17 00:00:00 2001 From: yoshih Date: Mon, 20 Jan 2025 22:16:25 +0800 Subject: [PATCH 12/13] fix ubuntu build --- src/surge-fx/ParameterPanel.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/surge-fx/ParameterPanel.h b/src/surge-fx/ParameterPanel.h index 06f9e353dae..af1d875bb9d 100644 --- a/src/surge-fx/ParameterPanel.h +++ b/src/surge-fx/ParameterPanel.h @@ -41,8 +41,6 @@ class ParameterPanel : public juce::Component juce::Colour surgeOrange = juce::Colour(255, 144, 0); std::vector &accessibleOrderWeakRefs; // Reference to the vector - juce::Font projectFont; - void addAndMakeVisibleRecordOrder(juce::Component *c) { accessibleOrderWeakRefs.push_back(c); From c1c272664ccf083915817067e488a6f28fed920c Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 21 Jan 2025 00:36:36 +0800 Subject: [PATCH 13/13] fix ubuntu build 2 --- src/surge-fx/ParameterPanel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/surge-fx/ParameterPanel.h b/src/surge-fx/ParameterPanel.h index af1d875bb9d..228e2ae0bca 100644 --- a/src/surge-fx/ParameterPanel.h +++ b/src/surge-fx/ParameterPanel.h @@ -17,7 +17,6 @@ class ParameterPanel : public juce::Component void paint(juce::Graphics &) override; void resized() override; - void setProjectFont(juce::Font font) { projectFont = font; } void reset(); SurgeFXParamDisplay fxParamDisplay[n_fx_params];