Skip to content

Commit

Permalink
zprime fixes (#35)
Browse files Browse the repository at this point in the history
* work

* work

* zprime fixes

* cleanup
  • Loading branch information
dan-german committed May 4, 2024
1 parent 54c5bd7 commit 53d30a6
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 59 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ void MainComponent::updateDotPosition(const Point<int> 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);
}
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions Source/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> position);
Expand Down
5 changes: 1 addition & 4 deletions Source/blocks_plugin_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion Source/filter_module_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand Down
22 changes: 0 additions & 22 deletions Source/gui/ModulatorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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();
Expand Down Expand Up @@ -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<float>(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();
Expand Down
8 changes: 1 addition & 7 deletions Source/gui/ModulatorComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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_;
Expand Down Expand Up @@ -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;
};
30 changes: 22 additions & 8 deletions Source/gui/UILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -151,15 +171,9 @@ void UILayer::setupSideMenus() {
modulators_.isOnLeft = false;
}

void UILayer::showModulatorsSideMenu() {
modulators_.listBox.updateContent();
modulators_.setVisible(false);
}

void UILayer::setConnections(std::vector<std::shared_ptr<model::Connection>> modulationConnections) {
connections_list_box_model_.setConnections(modulationConnections);
if (connections_.listBox.isVisible()) {
std::cout << "very very" << std::endl;
connections_.listBox.updateContent();
}
}
Expand Down
1 change: 0 additions & 1 deletion Source/gui/UILayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion Source/gui/controls/blocks_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions Source/settings/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertiesFile> file;
Expand Down

0 comments on commit 53d30a6

Please sign in to comment.