/*
==============================================================================
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: 5.4.4
------------------------------------------------------------------------------
The Projucer is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
==============================================================================
*/
//[Headers] You can add your own extra header files here...
#include "GuiLFO.h"
#include "GuiADSR.h"
#include "AudioParameters.h"
//[/Headers]
#include "GuiPitch.h"
//[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs]
//==============================================================================
GuiPitch::GuiPitch ( const String& name, const String & text)
: GroupComponent (name, text)
{
//[Constructor_pre] You can add your own custom stuff here..
molossLNF = std::make_unique< MolossLookNFeel>(MolossLookNFeel::CYAN_LNF);
setLookAndFeel(molossLNF.get());
//[/Constructor_pre]
setName ("GuiPitch");
labelCoarse.reset (new Label ("labelCoarse",
TRANS("Coarse")));
addAndMakeVisible (labelCoarse.get());
labelCoarse->setFont (Font (15.00f, Font::plain).withTypefaceStyle ("Regular"));
labelCoarse->setJustificationType (Justification::centred);
labelCoarse->setEditable (false, false, false);
labelCoarse->setColour (TextEditor::textColourId, Colours::black);
labelCoarse->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
coarseSlider.reset (new Slider ("coarseSlider"));
addAndMakeVisible (coarseSlider.get());
coarseSlider->setTooltip (TRANS("Coarse pitch in semi-tones. 0 means A4 key is 400 Hz."));
coarseSlider->setRange (-24, 24, 1);
coarseSlider->setSliderStyle (Slider::RotaryVerticalDrag);
coarseSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 40, 20);
labelFine.reset (new Label ("labelFine",
TRANS("Fine")));
addAndMakeVisible (labelFine.get());
labelFine->setFont (Font (15.00f, Font::plain).withTypefaceStyle ("Regular"));
labelFine->setJustificationType (Justification::centred);
labelFine->setEditable (false, false, false);
labelFine->setColour (TextEditor::textColourId, Colours::black);
labelFine->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
fineSlider.reset (new Slider ("fineSlider"));
addAndMakeVisible (fineSlider.get());
fineSlider->setTooltip (TRANS("Fine pitch in cents of semi-tones."));
fineSlider->setRange (-50, 50, 1);
fineSlider->setSliderStyle (Slider::RotaryVerticalDrag);
fineSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 40, 20);
groupLFO.reset (new GuiLFO ("groupLFO",
TRANS("LFO")));
addAndMakeVisible (groupLFO.get());
groupLFO->setBounds (16, 504, 238, 190);
groupADSR.reset (new GuiADSR ("groupADSR",
TRANS("ADSR")));
addAndMakeVisible (groupADSR.get());
groupADSR->setBounds (8, 292, 253, 220);
keyFollow.reset (new Label ("keyFollow",
TRANS("KF")));
addAndMakeVisible (keyFollow.get());
keyFollow->setFont (Font (15.00f, Font::plain).withTypefaceStyle ("Regular"));
keyFollow->setJustificationType (Justification::centred);
keyFollow->setEditable (false, false, false);
keyFollow->setColour (TextEditor::textColourId, Colours::black);
keyFollow->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
kfSlider.reset (new Slider ("kfSlider"));
addAndMakeVisible (kfSlider.get());
kfSlider->setTooltip (TRANS("Pitch KeyFollow in cents of semitone per note. 100 is one semi-tone per note (normal pitch)."));
kfSlider->setRange (-200, 200, 1);
kfSlider->setSliderStyle (Slider::RotaryVerticalDrag);
kfSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 40, 20);
copyButton.reset (new TextButton ("copyButton"));
addAndMakeVisible (copyButton.get());
copyButton->setTooltip (TRANS("Copy Pitch Parameters"));
copyButton->setButtonText (TRANS("C"));
copyButton->addListener (this);
copyButton->setBounds (223, 37, 24, 24);
pasteButton.reset (new TextButton ("pasteButton"));
addAndMakeVisible (pasteButton.get());
pasteButton->setTooltip (TRANS("Paste Pitch Parameters"));
pasteButton->setButtonText (TRANS("P"));
pasteButton->addListener (this);
pasteButton->setBounds (223, 69, 24, 24);
//[UserPreSize]
//[/UserPreSize]
setSize (600, 400);
//[Constructor] You can add your own custom stuff here..
//[/Constructor]
}
GuiPitch::~GuiPitch()
{
//[Destructor_pre]. You can add your own custom destruction code here..
mAttachment = nullptr;
setLookAndFeel(nullptr);
//[/Destructor_pre]
labelCoarse = nullptr;
coarseSlider = nullptr;
labelFine = nullptr;
fineSlider = nullptr;
groupLFO = nullptr;
groupADSR = nullptr;
keyFollow = nullptr;
kfSlider = nullptr;
copyButton = nullptr;
pasteButton = nullptr;
//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]
}
//==============================================================================
void GuiPitch::paint (Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here..
GroupComponent::paint(g);
//[/UserPrePaint]
//[UserPaint] Add your own custom painting code here..
//[/UserPaint]
}
void GuiPitch::resized()
{
//[UserPreResize] Add your own custom resize code here..
//[/UserPreResize]
labelCoarse->setBounds (50 - (47 / 2), 27 - (24 / 2), 47, 24);
coarseSlider->setBounds (50 - (56 / 2), (27 - (24 / 2)) + 16, 56, 72);
labelFine->setBounds (116 - (47 / 2), (27 - (24 / 2)) + 24 / 2 - (24 / 2), 47, 24);
fineSlider->setBounds (116 - (56 / 2), ((27 - (24 / 2)) + 16) + 0, 56, 72);
keyFollow->setBounds (182 - (47 / 2), (27 - (24 / 2)) + 24 / 2 - (24 / 2), 47, 24);
kfSlider->setBounds (182 - (56 / 2), ((27 - (24 / 2)) + 16) + 0, 56, 72);
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}
void GuiPitch::buttonClicked (Button* buttonThatWasClicked)
{
//[UserbuttonClicked_Pre]
//[/UserbuttonClicked_Pre]
if (buttonThatWasClicked == copyButton.get())
{
//[UserButtonCode_copyButton] -- add your button handler code here..
copy();
//[/UserButtonCode_copyButton]
}
else if (buttonThatWasClicked == pasteButton.get())
{
//[UserButtonCode_pasteButton] -- add your button handler code here..
paste();
//[/UserButtonCode_pasteButton]
}
//[UserbuttonClicked_Post]
//[/UserbuttonClicked_Post]
}
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
void GuiPitch::setParameters(PitchParameters * pitchParam) {
mPitchParameters = pitchParam;
groupADSR->setParameters(pitchParam);
groupLFO->setParameters(pitchParam);
mAttachment = std::make_unique<GuiAttachment>(mPitchParameters->getProcessor());
updateFromParameters();
}
void GuiPitch::updateFromParameters()
{
mAttachment->attachSlider(mPitchParameters->mCoarse, *coarseSlider);
mAttachment->attachSlider(mPitchParameters->mFine, *fineSlider);
mAttachment->attachSlider(mPitchParameters->mKeyFollow, *kfSlider);
}
void GuiPitch::paste(String prefix) {
mPitchParameters->pasteParameters(prefix);
}
void GuiPitch::copy(String prefix) {
mPitchParameters->copyParameters(prefix);
}
//[/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
<JUCER_COMPONENT documentType="Component" className="GuiPitch" componentName="GuiPitch"
parentClasses="public GroupComponent" constructorParams=" const String& name, const String & text"
variableInitialisers="GroupComponent (name, text)" snapPixels="8"
snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="0"
initialWidth="600" initialHeight="400">
<BACKGROUND backgroundColour="323e44"/>
<LABEL name="labelCoarse" id="ddf178a525ed6f14" memberName="labelCoarse"
virtualName="" explicitFocusOrder="0" pos="49.5c 27c 47 24" edTextCol="ff000000"
edBkgCol="0" labelText="Coarse" editableSingleClick="0" editableDoubleClick="0"
focusDiscardsChanges="0" fontname="Default font" fontsize="15.0"
kerning="0.0" bold="0" italic="0" justification="36"/>
<SLIDER name="coarseSlider" id="586690c5050f6d69" memberName="coarseSlider"
virtualName="" explicitFocusOrder="0" pos="50c 16 56 72" posRelativeY="ddf178a525ed6f14"
tooltip="Coarse pitch in semi-tones. 0 means A4 key is 400 Hz."
min="-24.0" max="24.0" int="1.0" style="RotaryVerticalDrag" textBoxPos="TextBoxBelow"
textBoxEditable="1" textBoxWidth="40" textBoxHeight="20" skewFactor="1.0"
needsCallback="0"/>
<LABEL name="labelFine" id="3c93d39de5afafb4" memberName="labelFine"
virtualName="" explicitFocusOrder="0" pos="115.5c 0Cc 47 24"
posRelativeY="ddf178a525ed6f14" edTextCol="ff000000" edBkgCol="0"
labelText="Fine" editableSingleClick="0" editableDoubleClick="0"
focusDiscardsChanges="0" fontname="Default font" fontsize="15.0"
kerning="0.0" bold="0" italic="0" justification="36"/>
<SLIDER name="fineSlider" id="c64ccea4e8040931" memberName="fineSlider"
virtualName="" explicitFocusOrder="0" pos="116c 0 56 72" posRelativeY="586690c5050f6d69"
tooltip="Fine pitch in cents of semi-tones." min="-50.0" max="50.0"
int="1.0" style="RotaryVerticalDrag" textBoxPos="TextBoxBelow"
textBoxEditable="1" textBoxWidth="40" textBoxHeight="20" skewFactor="1.0"
needsCallback="0"/>
<GROUPCOMPONENT name="groupLFO" id="e688a7661f1c7439" memberName="groupLFO" virtualName="GuiLFO"
explicitFocusOrder="0" pos="16 504 238 190" title="LFO"/>
<GROUPCOMPONENT name="groupADSR" id="2631439cf016426b" memberName="groupADSR"
virtualName="GuiADSR" explicitFocusOrder="0" pos="8 292 253 220"
title="ADSR"/>
<LABEL name="keyFollow" id="1fcf2f01a92aba57" memberName="keyFollow"
virtualName="" explicitFocusOrder="0" pos="181.5c 0Cc 47 24"
posRelativeY="ddf178a525ed6f14" edTextCol="ff000000" edBkgCol="0"
labelText="KF" editableSingleClick="0" editableDoubleClick="0"
focusDiscardsChanges="0" fontname="Default font" fontsize="15.0"
kerning="0.0" bold="0" italic="0" justification="36"/>
<SLIDER name="kfSlider" id="326bb555d48d4078" memberName="kfSlider" virtualName=""
explicitFocusOrder="0" pos="182c 0 56 72" posRelativeY="586690c5050f6d69"
tooltip="Pitch KeyFollow in cents of semitone per note. 100 is one semi-tone per note (normal pitch)."
min="-200.0" max="200.0" int="1.0" style="RotaryVerticalDrag"
textBoxPos="TextBoxBelow" textBoxEditable="1" textBoxWidth="40"
textBoxHeight="20" skewFactor="1.0" needsCallback="0"/>
<TEXTBUTTON name="copyButton" id="36caa20fb07405f3" memberName="copyButton"
virtualName="" explicitFocusOrder="0" pos="223 37 24 24" tooltip="Copy Pitch Parameters"
buttonText="C" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
<TEXTBUTTON name="pasteButton" id="4af5e8f91f632b47" memberName="pasteButton"
virtualName="" explicitFocusOrder="0" pos="223 69 24 24" tooltip="Paste Pitch Parameters"
buttonText="P" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
</JUCER_COMPONENT>
END_JUCER_METADATA
*/
#endif
//[EndFile] You can add extra defines here...
//[/EndFile]