From c77f380fda67c35b6bd34ec9a98b390e86afdecd Mon Sep 17 00:00:00 2001 From: Takeshi Yokemura Date: Mon, 17 May 2021 07:11:32 +0900 Subject: [PATCH] (1)Added MonoComponent file (2)Size Adjustment --- Magical8bitPlug2.jucer | 4 ++ Source/BasicParamsComponent.cpp | 6 +- Source/MonophonicComponent.cpp | 107 ++++++++++++++++++++++++++++++++ Source/MonophonicComponent.h | 65 +++++++++++++++++++ Source/PluginEditor.cpp | 36 ++++++----- Source/Settings.h | 1 + 6 files changed, 202 insertions(+), 17 deletions(-) create mode 100644 Source/MonophonicComponent.cpp create mode 100644 Source/MonophonicComponent.h diff --git a/Magical8bitPlug2.jucer b/Magical8bitPlug2.jucer index a4db363..912c68f 100644 --- a/Magical8bitPlug2.jucer +++ b/Magical8bitPlug2.jucer @@ -46,6 +46,10 @@ file="Source/EnvelopeParamsComponent.cpp"/> + + setValue(1); //[UserButtonCode_monoButton] -- add your button handler code here.. + polyNumberInput.get()->setValue(1); + return; //[/UserButtonCode_monoButton] } @@ -196,8 +197,7 @@ void BasicParamsComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged) BEGIN_JUCER_METADATA diff --git a/Source/MonophonicComponent.cpp b/Source/MonophonicComponent.cpp new file mode 100644 index 0000000..ed91e88 --- /dev/null +++ b/Source/MonophonicComponent.cpp @@ -0,0 +1,107 @@ +/* + ============================================================================== + + This is an automatically generated GUI class created by the Projucer! + + Be careful when adding custom code to these files, as only the code within + the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded + and re-saved. + + Created with Projucer version: 6.0.8 + + ------------------------------------------------------------------------------ + + The Projucer is part of the JUCE library. + Copyright (c) 2020 - Raw Material Software Limited. + + ============================================================================== +*/ + +//[Headers] You can add your own extra header files here... +//[/Headers] + +#include "MonophonicComponent.h" + + +//[MiscUserDefs] You can add your own user definitions and misc code here... +//[/MiscUserDefs] + +//============================================================================== +MonophonicComponent::MonophonicComponent () +{ + //[Constructor_pre] You can add your own custom stuff here.. + //[/Constructor_pre] + + + //[UserPreSize] + //[/UserPreSize] + + setSize (640, 400); + + + //[Constructor] You can add your own custom stuff here.. + //[/Constructor] +} + +MonophonicComponent::~MonophonicComponent() +{ + //[Destructor_pre]. You can add your own custom destruction code here.. + //[/Destructor_pre] + + + + //[Destructor]. You can add your own custom destruction code here.. + //[/Destructor] +} + +//============================================================================== +void MonophonicComponent::paint (juce::Graphics& g) +{ + //[UserPrePaint] Add your own custom painting code here.. + //[/UserPrePaint] + + g.fillAll (juce::Colour (0xff323e44)); + + //[UserPaint] Add your own custom painting code here.. + //[/UserPaint] +} + +void MonophonicComponent::resized() +{ + //[UserPreResize] Add your own custom resize code here.. + //[/UserPreResize] + + //[UserResized] Add your own custom resize handling here.. + //[/UserResized] +} + + + +//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... +//[/MiscUserCode] + + +//============================================================================== +#if 0 +/* -- Projucer information section -- + + This is where the Projucer stores the metadata that describe this GUI layout, so + make changes in here at your peril! + +BEGIN_JUCER_METADATA + + + + + +END_JUCER_METADATA +*/ +#endif + + +//[EndFile] You can add extra defines here... +//[/EndFile] + diff --git a/Source/MonophonicComponent.h b/Source/MonophonicComponent.h new file mode 100644 index 0000000..f6a8c96 --- /dev/null +++ b/Source/MonophonicComponent.h @@ -0,0 +1,65 @@ +/* + ============================================================================== + + This is an automatically generated GUI class created by the Projucer! + + Be careful when adding custom code to these files, as only the code within + the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded + and re-saved. + + Created with Projucer version: 6.0.8 + + ------------------------------------------------------------------------------ + + The Projucer is part of the JUCE library. + Copyright (c) 2020 - Raw Material Software Limited. + + ============================================================================== +*/ + +#pragma once + +//[Headers] -- You can add your own extra header files here -- +#include +//[/Headers] + + + +//============================================================================== +/** + //[Comments] + An auto-generated component, created by the Projucer. + + Describe your class and how it works here! + //[/Comments] +*/ +class MonophonicComponent : public juce::Component +{ +public: + //============================================================================== + MonophonicComponent (); + ~MonophonicComponent() override; + + //============================================================================== + //[UserMethods] -- You can add your own custom methods in this section. + //[/UserMethods] + + void paint (juce::Graphics& g) override; + void resized() override; + + + +private: + //[UserVariables] -- You can add your own custom variables in this section. + //[/UserVariables] + + //============================================================================== + + + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MonophonicComponent) +}; + +//[EndFile] You can add extra defines here... +//[/EndFile] + diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 3488141..d3c12c1 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -169,8 +169,7 @@ struct } if (isMono) { - retHeight += sectionSeparatorHeight - + monoCompoHeight; + retHeight += monoCompoHeight; } return retHeight; } @@ -205,27 +204,37 @@ void Magical8bitPlug2AudioProcessorEditor::resized() int y = sizes.topMargin; int w = sizes.halfComponentWidth; basicCompo->setBounds (x, y, sizes.fullComponentWidth, sizes.basCompoHeight); + + y += sizes.basCompoHeight + sizes.sectionSeparatorHeight; + + // + // Monophonic + // + if (processor.settingRefs.isMonophonic()) { + y += sizes.monoCompoHeight; + } + + int y1 = y; + int y2 = y; // // Main part - Left // - y = sizes.topMargin + sizes.basCompoHeight + sizes.sectionSeparatorHeight; - pulCompo->setBounds (x, y, w, sizes.toneSpecificControlHeight); - noiCompo->setBounds (x, y, w, sizes.toneSpecificControlHeight); - y += sizes.toneSpecificControlHeight; + pulCompo->setBounds (x, y1, w, sizes.toneSpecificControlHeight); + noiCompo->setBounds (x, y1, w, sizes.toneSpecificControlHeight); + y1 += sizes.toneSpecificControlHeight; - envCompo->setBounds (x, y, w, sizes.envCompoHeight); - y += sizes.envCompoHeight; + envCompo->setBounds (x, y1, w, sizes.envCompoHeight); + y1 += sizes.envCompoHeight; - bendCompo->setBounds (x, y, w, sizes.bendCompoHeight); - y += sizes.bendCompoHeight; + bendCompo->setBounds (x, y1, w, sizes.bendCompoHeight); + y1 += sizes.bendCompoHeight; // // Main part - Right // x = sizes.leftMargin + sizes.halfComponentWidth + sizes.verticalSeparatorWidth; - int y2 = sizes.topMargin + sizes.basCompoHeight + sizes.sectionSeparatorHeight; sweepCompo->setBounds (x, y2, w, sizes.sweepCompoHeight); y2 += sizes.sweepCompoHeight; @@ -237,7 +246,7 @@ void Magical8bitPlug2AudioProcessorEditor::resized() // Advanced part // x = sizes.leftMargin; - int y3 = y > y2 ? y : y2; + int y3 = y1 > y2 ? y1 : y2; y3 += sizes.sectionSeparatorHeight; advCompo->setBounds (x, y3, sizes.fullComponentWidth, sizes.advCompoHeight); @@ -276,8 +285,7 @@ void Magical8bitPlug2AudioProcessorEditor::resizeWholePanel() if (!isComponentsReady) { return; } - bool isMono = (int)(*processor.settingRefs.maxPoly) == 1; - setSize (sizes.totalWidth, sizes.totalHeight (processor.settingRefs.isAdvancedPanelOpen(), isMono)); + setSize (sizes.totalWidth, sizes.totalHeight (processor.settingRefs.isAdvancedPanelOpen(), processor.settingRefs.isMonophonic())); } void Magical8bitPlug2AudioProcessorEditor::parameterValueChanged (int parameterIndex, float newValue) diff --git a/Source/Settings.h b/Source/Settings.h index 738aa72..8b29dad 100644 --- a/Source/Settings.h +++ b/Source/Settings.h @@ -139,6 +139,7 @@ struct SettingRefs // accessors // int oscillatorType() { return (int) (*osc); } + bool isMonophonic() { return (int)(*maxPoly) == 1; } bool isAdvancedPanelOpen() { return *isAdvancedPanelOpen_raw > 0.5; } ColorSchemeType colorSchemeType() { return (ColorSchemeType) ((int) (*colorScheme)); }