sliders in groups

This commit is contained in:
Alex Birch 2019-06-30 10:59:07 +01:00
parent 542994d672
commit a7d375a2bb
No known key found for this signature in database
GPG Key ID: 305EB1F98D44ACBA
5 changed files with 186 additions and 4 deletions

View File

@ -107,6 +107,7 @@
358E45F122BEE5CE0087ED8D /* libgthread-2.0.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 358E45BB22BEE53A0087ED8D /* libgthread-2.0.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 358E45F122BEE5CE0087ED8D /* libgthread-2.0.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 358E45BB22BEE53A0087ED8D /* libgthread-2.0.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
358E45F222BEE5CE0087ED8D /* libFLAC.8.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 358E45BC22BEE53A0087ED8D /* libFLAC.8.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 358E45F222BEE5CE0087ED8D /* libFLAC.8.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 358E45BC22BEE53A0087ED8D /* libFLAC.8.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
358E45F322BEE5CE0087ED8D /* libogg.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 358E45BD22BEE53A0087ED8D /* libogg.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 358E45F322BEE5CE0087ED8D /* libogg.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 358E45BD22BEE53A0087ED8D /* libogg.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
358E45FB22C80DCA0087ED8D /* SlidersComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 358E45F922C80DCA0087ED8D /* SlidersComponent.cpp */; };
3793A7D5AC25576FAC8583E6 /* include_juce_graphics.mm in Sources */ = {isa = PBXBuildFile; fileRef = A6BC2528C1717DDC2B66215E /* include_juce_graphics.mm */; }; 3793A7D5AC25576FAC8583E6 /* include_juce_graphics.mm in Sources */ = {isa = PBXBuildFile; fileRef = A6BC2528C1717DDC2B66215E /* include_juce_graphics.mm */; };
42542EDC02B3DE845BCC21FE /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1616112041466F7324D7E19 /* Accelerate.framework */; }; 42542EDC02B3DE845BCC21FE /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1616112041466F7324D7E19 /* Accelerate.framework */; };
458D25AB7460484F90B37A2F /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1910B48593DA5FACC7E122 /* IOKit.framework */; }; 458D25AB7460484F90B37A2F /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1910B48593DA5FACC7E122 /* IOKit.framework */; };
@ -295,6 +296,8 @@
358E45BC22BEE53A0087ED8D /* libFLAC.8.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libFLAC.8.dylib; sourceTree = "<group>"; }; 358E45BC22BEE53A0087ED8D /* libFLAC.8.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libFLAC.8.dylib; sourceTree = "<group>"; };
358E45BD22BEE53A0087ED8D /* libogg.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libogg.0.dylib; sourceTree = "<group>"; }; 358E45BD22BEE53A0087ED8D /* libogg.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libogg.0.dylib; sourceTree = "<group>"; };
358E45F422BFC00C0087ED8D /* MidiConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MidiConstants.h; path = ../../Source/MidiConstants.h; sourceTree = "<group>"; }; 358E45F422BFC00C0087ED8D /* MidiConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MidiConstants.h; path = ../../Source/MidiConstants.h; sourceTree = "<group>"; };
358E45F922C80DCA0087ED8D /* SlidersComponent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SlidersComponent.cpp; path = ../../Source/SlidersComponent.cpp; sourceTree = "<group>"; };
358E45FA22C80DCA0087ED8D /* SlidersComponent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SlidersComponent.h; path = ../../Source/SlidersComponent.h; sourceTree = "<group>"; };
35D551D55292C9D0508A408A /* PluginEditor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = PluginEditor.cpp; path = ../../Source/PluginEditor.cpp; sourceTree = SOURCE_ROOT; }; 35D551D55292C9D0508A408A /* PluginEditor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = PluginEditor.cpp; path = ../../Source/PluginEditor.cpp; sourceTree = SOURCE_ROOT; };
373EF982A53046CE00BECE68 /* include_juce_events.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = include_juce_events.mm; path = ../../JuceLibraryCode/include_juce_events.mm; sourceTree = SOURCE_ROOT; }; 373EF982A53046CE00BECE68 /* include_juce_events.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = include_juce_events.mm; path = ../../JuceLibraryCode/include_juce_events.mm; sourceTree = SOURCE_ROOT; };
3909EE4609ED2DCCC6B6B290 /* juce_data_structures */ = {isa = PBXFileReference; lastKnownFileType = folder; name = juce_data_structures; path = /Applications/JUCE/modules/juce_data_structures; sourceTree = "<absolute>"; }; 3909EE4609ED2DCCC6B6B290 /* juce_data_structures */ = {isa = PBXFileReference; lastKnownFileType = folder; name = juce_data_structures; path = /Applications/JUCE/modules/juce_data_structures; sourceTree = "<absolute>"; };
@ -547,6 +550,8 @@
35D551D55292C9D0508A408A /* PluginEditor.cpp */, 35D551D55292C9D0508A408A /* PluginEditor.cpp */,
8990F3EAFFBBD6A42247C663 /* PluginEditor.h */, 8990F3EAFFBBD6A42247C663 /* PluginEditor.h */,
358E45F422BFC00C0087ED8D /* MidiConstants.h */, 358E45F422BFC00C0087ED8D /* MidiConstants.h */,
358E45F922C80DCA0087ED8D /* SlidersComponent.cpp */,
358E45FA22C80DCA0087ED8D /* SlidersComponent.h */,
); );
name = Source; name = Source;
sourceTree = "<group>"; sourceTree = "<group>";
@ -945,6 +950,7 @@
E08B3A2AF85F9FCF991F1CA2 /* include_juce_audio_basics.mm in Sources */, E08B3A2AF85F9FCF991F1CA2 /* include_juce_audio_basics.mm in Sources */,
C4D76C968347E2ACBAB5B6E7 /* include_juce_audio_devices.mm in Sources */, C4D76C968347E2ACBAB5B6E7 /* include_juce_audio_devices.mm in Sources */,
51C9DBCA840E334DB1804133 /* include_juce_audio_formats.mm in Sources */, 51C9DBCA840E334DB1804133 /* include_juce_audio_formats.mm in Sources */,
358E45FB22C80DCA0087ED8D /* SlidersComponent.cpp in Sources */,
5E5B833BBDD65F0D4271CA52 /* include_juce_audio_plugin_client_utils.cpp in Sources */, 5E5B833BBDD65F0D4271CA52 /* include_juce_audio_plugin_client_utils.cpp in Sources */,
C59AF9E198C59F67039F12BB /* include_juce_audio_plugin_client_VST_utils.mm in Sources */, C59AF9E198C59F67039F12BB /* include_juce_audio_plugin_client_VST_utils.mm in Sources */,
5BEE82A710A5F9566FCF4FDA /* include_juce_audio_processors.mm in Sources */, 5BEE82A710A5F9566FCF4FDA /* include_juce_audio_processors.mm in Sources */,

View File

@ -20,7 +20,7 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor (JuicySFAudioProcessor&
filePicker(p.getFluidSynthModel()) filePicker(p.getFluidSynthModel())
{ {
// set resize limits for this plug-in // set resize limits for this plug-in
setResizeLimits (400, 300, 800, 600); setResizeLimits (400, 300, 1900, 1000);
setSize (p.lastUIWidth, p.lastUIHeight); setSize (p.lastUIWidth, p.lastUIHeight);
@ -34,8 +34,10 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor (JuicySFAudioProcessor&
setWantsKeyboardFocus(true); setWantsKeyboardFocus(true);
addAndMakeVisible (midiKeyboard); addAndMakeVisible (midiKeyboard);
addAndMakeVisible(slidersComponent);
addAndMakeVisible(tablesComponent); addAndMakeVisible(tablesComponent);
addAndMakeVisible(filePicker); addAndMakeVisible(filePicker);
} }
JuicySFAudioProcessorEditor::~JuicySFAudioProcessorEditor() JuicySFAudioProcessorEditor::~JuicySFAudioProcessorEditor()
@ -77,11 +79,17 @@ void JuicySFAudioProcessorEditor::paint (Graphics& g)
void JuicySFAudioProcessorEditor::resized() void JuicySFAudioProcessorEditor::resized()
{ {
const int padding = 8; const int padding{8};
const int pianoHeight = 70; const int pianoHeight{70};
const int filePickerHeight = 25; const int filePickerHeight{25};
const int slidersHeight{150};
Rectangle<int> r (getLocalBounds()); Rectangle<int> r (getLocalBounds());
filePicker.setBounds(r.removeFromTop(filePickerHeight + padding).reduced(padding, 0).withTrimmedTop(padding)); filePicker.setBounds(r.removeFromTop(filePickerHeight + padding).reduced(padding, 0).withTrimmedTop(padding));
slidersComponent.setBounds(r.removeFromTop(slidersHeight + padding).reduced(padding, 0).withTrimmedTop(padding));
// Rectangle<int> r2 (getLocalBounds());
// slidersComponent.setBounds(r2.removeFromLeft(filePickerWidth + padding).reduced(padding, 0).withTrimmedLeft(padding));
midiKeyboard.setBounds (r.removeFromBottom (pianoHeight).reduced(padding, 0)); midiKeyboard.setBounds (r.removeFromBottom (pianoHeight).reduced(padding, 0));
tablesComponent.setBounds(r.reduced(0, padding)); tablesComponent.setBounds(r.reduced(0, padding));

View File

@ -18,6 +18,7 @@
#include "ExposesComponents.h" #include "ExposesComponents.h"
#include "FilePicker.h" #include "FilePicker.h"
#include "StateChangeSubscriber.h" #include "StateChangeSubscriber.h"
#include "SlidersComponent.h"
//============================================================================== //==============================================================================
/** /**
@ -50,6 +51,7 @@ private:
SurjectiveMidiKeyboardComponent midiKeyboard; SurjectiveMidiKeyboardComponent midiKeyboard;
TablesComponent tablesComponent; TablesComponent tablesComponent;
FilePicker filePicker; FilePicker filePicker;
SlidersComponent slidersComponent;
bool focusInitialized; bool focusInitialized;

125
Source/SlidersComponent.cpp Normal file
View File

@ -0,0 +1,125 @@
//
// SlidersComponent.cpp
// juicysfplugin - Shared Code
//
// Created by Alex Birch on 29/06/2019.
// Copyright © 2019 Birchlabs. All rights reserved.
//
#include "SlidersComponent.h"
std::function<void()> SlidersComponent::makeSliderListener(Slider& slider) {
return [&slider]{
slider.setValue(slider.getValue(), NotificationType::dontSendNotification);
};
}
SlidersComponent::~SlidersComponent()
{
}
void SlidersComponent::resized() {
const int envelopeSliders{4};
const int filterSliders{2};
const int groupXMargin{8};
const int groupXPadding{8};
const int groupYPadding{9};
const int sliderXMargin{3};
const int labelHeight{25};
const int sliderWidth{30};
Rectangle<int> r{getLocalBounds()};
Rectangle<int> rEnvelope{r.removeFromLeft(envelopeSliders * sliderWidth + (envelopeSliders-1) * sliderXMargin + 2 * groupXPadding)};
Rectangle<int> rFilter{r.removeFromLeft(filterSliders * sliderWidth + (filterSliders-1) * sliderXMargin + 2 * groupXPadding + groupXMargin).withTrimmedLeft(groupXMargin)};
envelopeGroup.setBounds(rEnvelope);
filterGroup.setBounds(rFilter);
rEnvelope.reduce(groupXPadding, groupYPadding);
rFilter.reduce(groupXPadding, groupYPadding);
attackSlider.setBounds(rEnvelope.removeFromLeft(sliderWidth).withTrimmedTop(labelHeight));
decaySlider.setBounds(rEnvelope.removeFromLeft(sliderWidth + sliderXMargin).withTrimmedTop(labelHeight).withTrimmedLeft(sliderXMargin));
sustainSlider.setBounds(rEnvelope.removeFromLeft(sliderWidth + sliderXMargin).withTrimmedTop(labelHeight).withTrimmedLeft(sliderXMargin));
releaseSlider.setBounds(rEnvelope.removeFromLeft(sliderWidth + sliderXMargin).withTrimmedTop(labelHeight).withTrimmedLeft(sliderXMargin));
filterCutOffSlider.setBounds(rFilter.removeFromLeft(sliderWidth).withTrimmedTop(labelHeight));
filterResonanceSlider.setBounds(rFilter.removeFromLeft(sliderWidth + sliderXMargin).withTrimmedTop(labelHeight).withTrimmedLeft(sliderXMargin));
}
SlidersComponent::SlidersComponent() :
envelopeGroup{"envelopeGroup", "Envelope"},
filterGroup{"filterGroup", "Filter"}
{
const Slider::SliderStyle style{Slider::SliderStyle::LinearVertical};
const double rangeMin(0);
const double rangeMax(127);
const double rangeStep(1);
attackSlider.setSliderStyle(style);
attackSlider.setRange(rangeMin, rangeMax, rangeStep);
// attackSlider.onValueChange = makeSliderListener(attackSlider);
attackSlider.setTextBoxStyle(Slider::TextBoxBelow, true, attackSlider.getTextBoxWidth(), attackSlider.getTextBoxHeight());
decaySlider.setSliderStyle(style);
decaySlider.setRange(rangeMin, rangeMax, rangeStep);
// decaySlider.onValueChange = makeSliderListener(decaySlider);
decaySlider.setTextBoxStyle(Slider::TextBoxBelow, true, decaySlider.getTextBoxWidth(), decaySlider.getTextBoxHeight());
sustainSlider.setSliderStyle(style);
sustainSlider.setRange(rangeMin, rangeMax, rangeStep);
// sustainSlider.onValueChange = makeSliderListener(sustainSlider);
sustainSlider.setTextBoxStyle(Slider::TextBoxBelow, true, sustainSlider.getTextBoxWidth(), sustainSlider.getTextBoxHeight());
releaseSlider.setSliderStyle(style);
releaseSlider.setRange(rangeMin, rangeMax, rangeStep);
// releaseSlider.onValueChange = makeSliderListener(releaseSlider);
releaseSlider.setTextBoxStyle(Slider::TextBoxBelow, true, releaseSlider.getTextBoxWidth(), releaseSlider.getTextBoxHeight());
filterCutOffSlider.setSliderStyle(style);
filterCutOffSlider.setRange(rangeMin, rangeMax, rangeStep);
// filterCutOffSlider.onValueChange = makeSliderListener(filterCutOffSlider);
filterCutOffSlider.setTextBoxStyle(Slider::TextBoxBelow, true, filterCutOffSlider.getTextBoxWidth(), filterCutOffSlider.getTextBoxHeight());
filterResonanceSlider.setSliderStyle(style);
filterResonanceSlider.setRange(rangeMin, rangeMax, rangeStep);
// filterResonanceSlider.onValueChange = makeSliderListener(filterResonanceSlider);
filterResonanceSlider.setTextBoxStyle(Slider::TextBoxBelow, true, filterResonanceSlider.getTextBoxWidth(), filterResonanceSlider.getTextBoxHeight());
addAndMakeVisible(attackSlider);
addAndMakeVisible(decaySlider);
addAndMakeVisible(sustainSlider);
addAndMakeVisible(releaseSlider);
addAndMakeVisible(filterCutOffSlider);
addAndMakeVisible(filterResonanceSlider);
attackLabel.setText("A", NotificationType::dontSendNotification);
attackLabel.setJustificationType(Justification::centredBottom);
attackLabel.attachToComponent(&attackSlider, false);
decayLabel.setText("D", NotificationType::dontSendNotification);
decayLabel.setJustificationType(Justification::centredBottom);
decayLabel.attachToComponent(&decaySlider, false);
sustainLabel.setText("S", NotificationType::dontSendNotification);
sustainLabel.setJustificationType(Justification::centredBottom);
sustainLabel.attachToComponent(&sustainSlider, false);
releaseLabel.setText("R", NotificationType::dontSendNotification);
releaseLabel.setJustificationType(Justification::centredBottom);
releaseLabel.attachToComponent(&releaseSlider, false);
filterCutOffLabel.setText("Cut", NotificationType::dontSendNotification);
filterCutOffLabel.setJustificationType(Justification::centredBottom);
filterCutOffLabel.attachToComponent(&filterCutOffSlider, false);
filterResonanceLabel.setText("Res", NotificationType::dontSendNotification);
filterResonanceLabel.setJustificationType(Justification::centredBottom);
filterResonanceLabel.attachToComponent(&filterResonanceSlider, false);
addAndMakeVisible(attackLabel);
addAndMakeVisible(decayLabel);
addAndMakeVisible(sustainLabel);
addAndMakeVisible(releaseLabel);
addAndMakeVisible(filterCutOffLabel);
addAndMakeVisible(filterResonanceLabel);
addAndMakeVisible(envelopeGroup);
addAndMakeVisible(filterGroup);
}

41
Source/SlidersComponent.h Normal file
View File

@ -0,0 +1,41 @@
# pragma once
#include "../JuceLibraryCode/JuceHeader.h"
using namespace std;
class SlidersComponent : public Component
{
public:
SlidersComponent();
~SlidersComponent();
void resized() override;
private:
std::function<void()> makeSliderListener(Slider& slider);
GroupComponent envelopeGroup;
Slider attackSlider;
Label attackLabel;
Slider decaySlider;
Label decayLabel;
Slider sustainSlider;
Label sustainLabel;
Slider releaseSlider;
Label releaseLabel;
GroupComponent filterGroup;
Slider filterCutOffSlider;
Label filterCutOffLabel;
Slider filterResonanceSlider;
Label filterResonanceLabel;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SlidersComponent)
};