diff --git a/CMakeLists.txt b/CMakeLists.txt index 617f84c..1173190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.15) # `project()` command. `project()` sets up some helpful variables that describe source/binary # directories, and the current project version. This is a standard CMake command. -project(blocks VERSION 0.1.6) +project(blocks VERSION 0.1.7) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest") # If you've installed JUCE somehow (via a package manager, or directly using the CMake install diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 6463c4d..993912a 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -60,10 +60,6 @@ void MainComponent::updateDotPosition(const Point position) { repaint(); } -void MainComponent::modulatorIsAdjusting(ModulatorComponent* component, std::string parameter_name, float value) { - delegate->editorAdjustedModulator(parameter_name, component->row, value); -} - void MainComponent::paint(juce::Graphics& g) { g.fillAll(ThemeManager::shared()->getCurrent().background); } @@ -1102,12 +1098,6 @@ void MainComponent::columnControlEndedAdjusting(ColumnControlsContainer::Control } } -void MainComponent::modulatorGestureChanged(ModulatorComponent* modulatorComponent, std::string parameter_name, bool started) { - is_modulator_adjusting_ = started; - auto modulator = delegate->getModulator2(modulatorComponent->row); - delegate->editorParameterGestureChanged(modulator->name, parameter_name, started); -} - void MainComponent::copy() { copied_blocks_.clear(); auto items = block_grid_.getItems(); diff --git a/Source/MainComponent.h b/Source/MainComponent.h index 07bd779..a551476 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -168,8 +168,6 @@ class MainComponent final: public Component, void modulatorEndedDrag(ModulatorComponent* modulatorComponent, const MouseEvent& event) override; void modulatorIsDragging(ModulatorComponent* modulatorComponent, const MouseEvent& event) override; void modulatorStartedDrag(ModulatorComponent* component, const MouseEvent& event) override; - void modulatorIsAdjusting(ModulatorComponent* component, std::string parameter_name, float value) override; - void modulatorGestureChanged(ModulatorComponent* modulatorComponent, std::string parameter_name, bool started) override; void presentModulationOptionsMenu(int modulatorIndex, Index& indexUnderMouse, BlockComponent* block); void updateDotPosition(const Point position); diff --git a/Source/blocks_plugin_processor.cpp b/Source/blocks_plugin_processor.cpp index d3db8e9..26c51f0 100644 --- a/Source/blocks_plugin_processor.cpp +++ b/Source/blocks_plugin_processor.cpp @@ -799,8 +799,5 @@ void PluginProcessor::editorStartedAdjustingParameter(ID& id, std::string& param } void PluginProcessor::editorAdjustedParameter(ID& id, std::string& parameter_name, float value) { - auto m = synth_->getModuleManager().getModule(id); - auto pname = m->getParameterName(parameter_name); - auto parameter = m->parameter_map_[pname]; - parameter->value_processor->set(value); + synth_->getModuleManager().getModule(id)->getParameter(parameter_name)->set(value); } \ No newline at end of file diff --git a/Source/filter_module_new.h b/Source/filter_module_new.h index f755d51..94ef43c 100644 --- a/Source/filter_module_new.h +++ b/Source/filter_module_new.h @@ -6,7 +6,7 @@ namespace model { class FilterModule: public Block { public: FilterModule(int number): Block("filter", number) { - add({ .name = "model", .max = 7.0, .value_scale = ValueScale::kIndexed , .string_lookup = strings::kFilterModelNames }); + add({ .name = "model", .max = 7.0, .value_scale = ValueScale::kIndexed , .string_lookup = strings::kFilterModelNames, .modulatable = false }); add({ .name = "style", .max = 4.0, .value_scale = ValueScale::kIndexed , .string_lookup = strings::kFilterStyleNames, .modulatable = false }); add({ .name = "cutoff", .min = 8.0, .max = 136.0, .default_value = 30.0, .post_offset = -60.0 }); add({ .name = "resonance", .max = 1.0, .default_value = 0.5, .display_multiply = 100.0, .display_units = "%", .display_name = "Q" }); diff --git a/Source/gui/ModulatorComponent.cpp b/Source/gui/ModulatorComponent.cpp index f53eca5..7f5dde2 100644 --- a/Source/gui/ModulatorComponent.cpp +++ b/Source/gui/ModulatorComponent.cpp @@ -10,10 +10,6 @@ #include "gui/ModulatorComponent.h" -void ModulatorComponent::sliderDragEnded(Slider* slider) { - delegate_->modulatorGestureChanged(this, slider_parameter_name_map_[slider], false); -} - ModulatorComponent::~ModulatorComponent() { sliders.clear(true); ThemeManager::shared()->removeListener(this); @@ -51,7 +47,6 @@ void ModulatorComponent::setupSliders() { auto slider = new LabeledSlider(blocks_slider_listener); sliders.add(slider); slidersContainer.addAndMakeVisible(slider); - slider->box_slider_.juce_slider_.addListener(this); } } @@ -75,7 +70,6 @@ void ModulatorComponent::drawBottomLine(Graphics& g) const { void ModulatorComponent::resized() { bounds = getLocalBounds(); - std::cout << "modulator bounds " << bounds.toString() << std::endl; resizeDragIndicator(); resizeSliderContainer(); @@ -193,22 +187,6 @@ void ModulatorComponent::setColour(Colour colour) { slider_container_.setSlidersColour(colour); } -void ModulatorComponent::sliderDragStarted(Slider* slider) { - for (int i = 0; i < sliders.size(); i++) - if (&sliders[i]->box_slider_.juce_slider_ == slider) { - currentSliderIndex = i; - break; - } - delegate_->modulatorGestureChanged(this, slider_parameter_name_map_[slider], true); -} - -void ModulatorComponent::sliderValueChanged(Slider* slider) { - float value = static_cast(slider->getValue()); - // if (onSliderValueChange) onSliderValueChange(currentSliderIndex, value); - auto name = slider_parameter_name_map_[slider]; - delegate_->modulatorIsAdjusting(this, name, value); -} - void ModulatorComponent::themeChanged(Theme theme) { title.setColour(Label::ColourIds::textColourId, theme.two); repaint(); diff --git a/Source/gui/ModulatorComponent.h b/Source/gui/ModulatorComponent.h index 40908d2..86501c7 100644 --- a/Source/gui/ModulatorComponent.h +++ b/Source/gui/ModulatorComponent.h @@ -17,7 +17,7 @@ #include "gui/ThemeManager.h" #include "gui/slider_container.h" -class ModulatorComponent: public Component, Slider::Listener, ThemeListener { +class ModulatorComponent: public Component, ThemeListener { private: ExitButton exitButton; DragIndicatorComponent drag_indicator_; @@ -36,10 +36,6 @@ class ModulatorComponent: public Component, Slider::Listener, ThemeListener { Colour colour; BlocksSlider::Listener* blocks_slider_listener; - void sliderValueChanged(Slider* slider) override; - void sliderDragStarted(Slider* slider) override; - void sliderDragEnded(Slider* slider) override; - int currentSliderIndex = -1; public: gui::SliderContainer slider_container_; @@ -88,6 +84,4 @@ struct ModulatorComponent::Listener { virtual void modulatorIsDragging(ModulatorComponent* modulatorComponent, const MouseEvent& event) = 0; virtual void modulatorStartedDrag(ModulatorComponent* modulatorComponent, const MouseEvent& event) = 0; virtual void modulatorRemoved(ModulatorComponent* modulatorComponent) = 0; - virtual void modulatorIsAdjusting(ModulatorComponent* modulatorComponent, std::string parameter_name, float value) = 0; - virtual void modulatorGestureChanged(ModulatorComponent* modulatorComponent, std::string paramter_name, bool started) = 0; }; diff --git a/Source/gui/UILayer.cpp b/Source/gui/UILayer.cpp index b8916ff..b447b0e 100644 --- a/Source/gui/UILayer.cpp +++ b/Source/gui/UILayer.cpp @@ -15,6 +15,7 @@ #include "module_new.h" #include "version_config.h" #include "gui/ThemeManager.h" +#include "settings/UserSettings.h" UILayer::UILayer(juce::MidiKeyboardState& keyboard_state, BlocksSlider::Listener* listener): ComponentMovementWatcher(this), @@ -33,7 +34,19 @@ UILayer::UILayer(juce::MidiKeyboardState& keyboard_state, BlocksSlider::Listener setupSideMenus(); - matrixButton.on_click_ = [this]() { connections_.setVisible(true); }; + matrixButton.on_click_ = [this]() { + UserSettings::shared()->set("connections_menu_visible", juce::String("true")); + connections_.setVisible(true); + }; + + connections_.exit_button_.on_click_ = [this]() { + UserSettings::shared()->set("connections_menu_visible", juce::String("false")); + connections_.setVisible(false); + }; + + auto empty_string = juce::String(""); + if (UserSettings::shared()->getString("connections_menu_visible", empty_string) == "true" ) connections_.setVisible(true); + if (UserSettings::shared()->getString("modulators_menu_visible", empty_string) == "true") modulators_.setVisible(true); setupKeyboard(); connections_list_box_model_.slider_listener_ = listener; @@ -67,8 +80,15 @@ void UILayer::addSVGButton(SVGButton& button, const char* rawData, size_t size) void UILayer::addModulatorsButton() { modulatorsButton.reset(new ModulatorsButton()); addAndMakeVisible(*modulatorsButton); + modulatorsButton->on_click_ = [this]() { + UserSettings::shared()->set("modulators_menu_visible", juce::String("true")); + modulators_.setVisible(true); + }; - modulatorsButton->on_click_ = [this]() { modulators_.setVisible(true); }; + modulators_.exit_button_.on_click_ = [this]() { + UserSettings::shared()->set("modulators_menu_visible", juce::String("false")); + modulators_.setVisible(false); + }; } void UILayer::setupSettingsButton() { @@ -151,15 +171,9 @@ void UILayer::setupSideMenus() { modulators_.isOnLeft = false; } -void UILayer::showModulatorsSideMenu() { - modulators_.listBox.updateContent(); - modulators_.setVisible(false); -} - void UILayer::setConnections(std::vector> modulationConnections) { connections_list_box_model_.setConnections(modulationConnections); if (connections_.listBox.isVisible()) { - std::cout << "very very" << std::endl; connections_.listBox.updateContent(); } } diff --git a/Source/gui/UILayer.h b/Source/gui/UILayer.h index e8b4b73..af4a981 100644 --- a/Source/gui/UILayer.h +++ b/Source/gui/UILayer.h @@ -61,7 +61,6 @@ class UILayer: public juce::Component, ComponentMovementWatcher, ThemeListener void setupSettingsButton(); void addModulatorsButton(); void resizeModulatorsButton(); - void showModulatorsSideMenu(); void resizeSettingsButton(); void resizeSaveAndNewButtons(); void themeChanged(Theme theme) override; diff --git a/Source/gui/controls/blocks_slider.cpp b/Source/gui/controls/blocks_slider.cpp index 0e31d3f..9c4f3d8 100644 --- a/Source/gui/controls/blocks_slider.cpp +++ b/Source/gui/controls/blocks_slider.cpp @@ -175,7 +175,9 @@ void BlocksSlider::startModulationSelectionAnimation() { } void BlocksSlider::stopModulationSelectionAnimation() { - value_label_.setColour(Label::ColourIds::textColourId, ThemeManager::shared()->getCurrent().two.brighter(0.4f)); + auto theme = ThemeManager::shared()->getCurrent(); + Colour value_label_colour = theme.dark ? theme.two.brighter(0.7f) : theme.background.brighter(0.4); + value_label_.setColour(Label::ColourIds::textColourId, value_label_colour); modulation_selection_highlight_.setVisible(false); modulation_indication_highlight_.setVisible(true); juce_slider_.setAlpha(1.0f); diff --git a/Source/settings/UserSettings.h b/Source/settings/UserSettings.h index 0fe93ee..ade57d5 100644 --- a/Source/settings/UserSettings.h +++ b/Source/settings/UserSettings.h @@ -5,11 +5,9 @@ using namespace juce; class UserSettings { public: static UserSettings* shared(); - void set(StringRef k, const var& v); int getInt(StringRef keyName, int defaultValue); String getString(StringRef keyName, String& defaultValue); - private: UserSettings(); std::unique_ptr file;