Change height by poly number

This commit is contained in:
Takeshi Yokemura 2021-05-16 21:11:51 +09:00
parent fffe531b59
commit 1245490e52
3 changed files with 80 additions and 55 deletions

View File

@ -7,12 +7,12 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 5.4.5
Created with Projucer version: 6.0.8
------------------------------------------------------------------------------
The Projucer is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
Copyright (c) 2020 - Raw Material Software Limited.
==============================================================================
*/
@ -34,14 +34,14 @@ BasicParamsComponent::BasicParamsComponent (Magical8bitPlug2AudioProcessor& p, M
//[Constructor_pre] You can add your own custom stuff here..
//[/Constructor_pre]
polyLabel.reset (new Label ("label",
TRANS("Poly")));
polyLabel.reset (new juce::Label ("label",
TRANS("Poly")));
addAndMakeVisible (polyLabel.get());
polyLabel->setFont (Font (15.00f, Font::plain).withTypefaceStyle ("Regular"));
polyLabel->setJustificationType (Justification::centredLeft);
polyLabel->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
polyLabel->setJustificationType (juce::Justification::centredLeft);
polyLabel->setEditable (false, false, false);
polyLabel->setColour (TextEditor::textColourId, Colours::black);
polyLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
polyLabel->setColour (juce::TextEditor::textColourId, juce::Colours::black);
polyLabel->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000));
polyLabel->setBounds (232, 8, 40, 15);
@ -49,7 +49,7 @@ BasicParamsComponent::BasicParamsComponent (Magical8bitPlug2AudioProcessor& p, M
addAndMakeVisible (gainSlider.get());
gainSlider->setName ("gain slider");
gainSlider->setBounds (0, 32, 360, 32);
gainSlider->setBounds (0, 32, 380, 32);
oscChoice.reset (new ChoiceComponent (p, "osc", "OSC Type"));
addAndMakeVisible (oscChoice.get());
@ -57,16 +57,16 @@ BasicParamsComponent::BasicParamsComponent (Magical8bitPlug2AudioProcessor& p, M
oscChoice->setBounds (0, 4, 224, 28);
polyNumberInput.reset (new Slider ("poly number input"));
polyNumberInput.reset (new juce::Slider ("poly number input"));
addAndMakeVisible (polyNumberInput.get());
polyNumberInput->setRange (0, 32, 1);
polyNumberInput->setSliderStyle (Slider::IncDecButtons);
polyNumberInput->setTextBoxStyle (Slider::TextBoxLeft, false, 30, 20);
polyNumberInput->setSliderStyle (juce::Slider::IncDecButtons);
polyNumberInput->setTextBoxStyle (juce::Slider::TextBoxLeft, false, 30, 20);
polyNumberInput->addListener (this);
polyNumberInput->setBounds (268, 4, 86, 24);
advancedSwitch.reset (new CheckBoxComponent (p, "isAdvancedPanelOpen_raw", "Show Advanced Options"));
advancedSwitch.reset (new CheckBoxComponent (p, "isAdvancedPanelOpen_raw", "Advanced Options"));
addAndMakeVisible (advancedSwitch.get());
advancedSwitch->setName ("advanced option switch");
@ -74,6 +74,13 @@ BasicParamsComponent::BasicParamsComponent (Magical8bitPlug2AudioProcessor& p, M
addAndMakeVisible (colorSchemeChoice.get());
colorSchemeChoice->setName ("color selector");
monoButton.reset (new juce::TextButton ("mono button"));
addAndMakeVisible (monoButton.get());
monoButton->setButtonText (TRANS("mono"));
monoButton->addListener (this);
monoButton->setBounds (360, 4, 54, 24);
//[UserPreSize]
//[/UserPreSize]
@ -104,6 +111,7 @@ BasicParamsComponent::~BasicParamsComponent()
polyNumberInput = nullptr;
advancedSwitch = nullptr;
colorSchemeChoice = nullptr;
monoButton = nullptr;
//[Destructor]. You can add your own custom destruction code here..
@ -111,7 +119,7 @@ BasicParamsComponent::~BasicParamsComponent()
}
//==============================================================================
void BasicParamsComponent::paint (Graphics& g)
void BasicParamsComponent::paint (juce::Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here..
//[/UserPrePaint]
@ -125,13 +133,13 @@ void BasicParamsComponent::resized()
//[UserPreResize] Add your own custom resize code here..
//[/UserPreResize]
advancedSwitch->setBounds (getWidth() - 240, 4, 240, 28);
advancedSwitch->setBounds (getWidth() - 180, 4, 180, 28);
colorSchemeChoice->setBounds (getWidth() - 4 - 185, 32, 185, 28);
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}
void BasicParamsComponent::sliderValueChanged (Slider* sliderThatWasMoved)
void BasicParamsComponent::sliderValueChanged (juce::Slider* sliderThatWasMoved)
{
//[UsersliderValueChanged_Pre]
//[/UsersliderValueChanged_Pre]
@ -140,6 +148,7 @@ void BasicParamsComponent::sliderValueChanged (Slider* sliderThatWasMoved)
{
//[UserSliderCode_polyNumberInput] -- add your slider handling code here..
processor.setupVoice();
editor.resizeWholePanel();
//[/UserSliderCode_polyNumberInput]
}
@ -147,6 +156,24 @@ void BasicParamsComponent::sliderValueChanged (Slider* sliderThatWasMoved)
//[/UsersliderValueChanged_Post]
}
void BasicParamsComponent::buttonClicked (juce::Button* buttonThatWasClicked)
{
//[UserbuttonClicked_Pre]
//[/UserbuttonClicked_Pre]
if (buttonThatWasClicked == monoButton.get())
{
polyNumberInput.get()->setValue(1);
//[UserButtonCode_monoButton] -- add your button handler code here..
//[/UserButtonCode_monoButton]
}
//[UserbuttonClicked_Post]
colorSchemeChoice->setVisible (buttonThatWasClicked->getToggleState());
editor.resizeWholePanel();
//[/UserbuttonClicked_Post]
}
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
@ -156,12 +183,6 @@ void BasicParamsComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
editor.resized();
printf ("setup voice!!\n");
}
void BasicParamsComponent::buttonClicked (Button* buttonThatWasClicked)
{
colorSchemeChoice->setVisible (buttonThatWasClicked->getToggleState());
editor.resizeWholePanel();
}
//[/MiscUserCode]
@ -187,7 +208,7 @@ BEGIN_JUCER_METADATA
focusDiscardsChanges="0" fontname="Default font" fontsize="15.0"
kerning="0.0" bold="0" italic="0" justification="33"/>
<GENERICCOMPONENT name="gain slider" id="4bb22b329fed19e9" memberName="gainSlider"
virtualName="" explicitFocusOrder="0" pos="0 32 360 32" class="SliderComponent"
virtualName="" explicitFocusOrder="0" pos="0 32 380 32" class="SliderComponent"
params="p, &quot;gain&quot;, &quot;Gain&quot;"/>
<GENERICCOMPONENT name="osc selector" id="fa2387d441a3005d" memberName="oscChoice"
virtualName="" explicitFocusOrder="0" pos="0 4 224 28" class="ChoiceComponent"
@ -198,11 +219,14 @@ BEGIN_JUCER_METADATA
textBoxEditable="1" textBoxWidth="30" textBoxHeight="20" skewFactor="1.0"
needsCallback="1"/>
<GENERICCOMPONENT name="advanced option switch" id="9d35239102eeb521" memberName="advancedSwitch"
virtualName="" explicitFocusOrder="0" pos="0Rr 4 240 28" class="CheckBoxComponent"
params="p, &quot;isAdvancedPanelOpen_raw&quot;, &quot;Show Advanced Options&quot;"/>
virtualName="" explicitFocusOrder="0" pos="0Rr 4 180 28" class="CheckBoxComponent"
params="p, &quot;isAdvancedPanelOpen_raw&quot;, &quot;Advanced Options&quot;"/>
<GENERICCOMPONENT name="color selector" id="21d73ddc37680dd7" memberName="colorSchemeChoice"
virtualName="" explicitFocusOrder="0" pos="4Rr 32 185 28" class="ChoiceComponent"
params="p, &quot;colorScheme&quot;, &quot;Color&quot;"/>
<TEXTBUTTON name="mono button" id="9265bb1a11f90786" memberName="monoButton"
virtualName="" explicitFocusOrder="0" pos="360 4 54 24" buttonText="mono"
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
</JUCER_COMPONENT>
END_JUCER_METADATA

View File

@ -7,12 +7,12 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 5.4.5
Created with Projucer version: 6.0.8
------------------------------------------------------------------------------
The Projucer is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
Copyright (c) 2020 - Raw Material Software Limited.
==============================================================================
*/
@ -39,24 +39,24 @@ class Magical8bitPlug2AudioProcessorEditor;
//[/Comments]
*/
class BasicParamsComponent : public Component,
public ComboBox::Listener,
public Button::Listener,
public Slider::Listener
public ComboBox::Listener,
public juce::Slider::Listener,
public juce::Button::Listener
{
public:
//==============================================================================
BasicParamsComponent (Magical8bitPlug2AudioProcessor& p, Magical8bitPlug2AudioProcessorEditor& e);
~BasicParamsComponent();
~BasicParamsComponent() override;
//==============================================================================
//[UserMethods] -- You can add your own custom methods in this section.
void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override;
void buttonClicked (Button* buttonThatWasClicked) override;
//[/UserMethods]
void paint (Graphics& g) override;
void paint (juce::Graphics& g) override;
void resized() override;
void sliderValueChanged (Slider* sliderThatWasMoved) override;
void sliderValueChanged (juce::Slider* sliderThatWasMoved) override;
void buttonClicked (juce::Button* buttonThatWasClicked) override;
@ -69,12 +69,13 @@ private:
//[/UserVariables]
//==============================================================================
std::unique_ptr<Label> polyLabel;
std::unique_ptr<juce::Label> polyLabel;
std::unique_ptr<SliderComponent> gainSlider;
std::unique_ptr<ChoiceComponent> oscChoice;
std::unique_ptr<Slider> polyNumberInput;
std::unique_ptr<juce::Slider> polyNumberInput;
std::unique_ptr<CheckBoxComponent> advancedSwitch;
std::unique_ptr<ChoiceComponent> colorSchemeChoice;
std::unique_ptr<juce::TextButton> monoButton;
//==============================================================================

View File

@ -130,6 +130,9 @@ struct
const int basCompoHeight = componentMargin * 2
+ genericControlHeight * 2;
const int monoCompoHeight = componentMargin * 2
+ indexHeight
+ customEnvelopeHeight;
const int toneSpecificControlHeight = componentMargin * 2
+ indexHeight
+ genericControlHeight;
@ -148,30 +151,26 @@ struct
const int advCompoHeight = componentMargin * 2
+ indexHeight
+ customEnvelopeHeight * 3;
const int totalHeight (bool isAdvOptOn)
const int totalHeight (bool isAdvOptOn, bool isMono)
{
int retHeight = topMargin
+ basCompoHeight
+ sectionSeparatorHeight
+ toneSpecificControlHeight
+ envCompoHeight
+ bendCompoHeight
+ bottomMargin;
if (isAdvOptOn)
{
return topMargin
+ basCompoHeight
+ sectionSeparatorHeight
+ toneSpecificControlHeight
+ envCompoHeight
+ bendCompoHeight
+ sectionSeparatorHeight
+ advCompoHeight
+ bottomMargin;
retHeight += sectionSeparatorHeight
+ advCompoHeight;
}
else
if (isMono)
{
return topMargin
+ basCompoHeight
+ sectionSeparatorHeight
+ toneSpecificControlHeight
+ envCompoHeight
+ bendCompoHeight
+ bottomMargin;
retHeight += sectionSeparatorHeight
+ monoCompoHeight;
}
return retHeight;
}
} sizes;
@ -272,7 +271,8 @@ void Magical8bitPlug2AudioProcessorEditor::resized()
void Magical8bitPlug2AudioProcessorEditor::resizeWholePanel()
{
setSize (sizes.totalWidth, sizes.totalHeight (processor.settingRefs.isAdvancedPanelOpen()));
bool isMono = (int)(*processor.settingRefs.maxPoly) == 1;
setSize (sizes.totalWidth, sizes.totalHeight (processor.settingRefs.isAdvancedPanelOpen(), isMono));
}
void Magical8bitPlug2AudioProcessorEditor::parameterValueChanged (int parameterIndex, float newValue)