/* ============================================================================== 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.1.5 ------------------------------------------------------------------------------ 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... #include "PluginProcessor.h" #include "FrameSequenceParseErrors.h" //[/Headers] #include "CustomEnvelopeComponent.h" //[MiscUserDefs] You can add your own user definitions and misc code here... //[/MiscUserDefs] //============================================================================== CustomEnvelopeComponent::CustomEnvelopeComponent (Magical8bitPlug2AudioProcessor& p, String type, String displayName, String flagParameterName) : processor(p) { //[Constructor_pre] You can add your own custom stuff here.. //[/Constructor_pre] textEditor.reset (new juce::TextEditor ("text editor")); addAndMakeVisible (textEditor.get()); textEditor->setMultiLine (false); textEditor->setReturnKeyStartsNewLine (false); textEditor->setReadOnly (false); textEditor->setScrollbarsShown (false); textEditor->setCaretVisible (true); textEditor->setPopupMenuEnabled (true); textEditor->setText (juce::String()); toggleButton.reset (new juce::ToggleButton ("toggle button")); addAndMakeVisible (toggleButton.get()); toggleButton->setButtonText (TRANS("Enabled")); toggleButton->addListener (this); toggleButton->setBounds (8, 4, 104, 24); label.reset (new juce::Label ("new label", juce::String())); addAndMakeVisible (label.get()); label->setFont (juce::Font (12.00f, juce::Font::plain).withTypefaceStyle ("Regular")); label->setJustificationType (juce::Justification::centredLeft); label->setEditable (false, false, false); label->setColour (juce::TextEditor::textColourId, juce::Colours::black); label->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); //[UserPreSize] //[/UserPreSize] setSize (540, 56); //[Constructor] You can add your own custom stuff here.. paramType = type; attc.reset (new ButtonAttachment (p.parameters, flagParameterName, *toggleButton)); textEditor->addListener (this); textEditor->setText (p.settingRefs.getSequenceString (type)); toggleButton->setButtonText (displayName); //[/Constructor] } CustomEnvelopeComponent::~CustomEnvelopeComponent() { //[Destructor_pre]. You can add your own custom destruction code here.. //[/Destructor_pre] textEditor = nullptr; toggleButton = nullptr; label = nullptr; //[Destructor]. You can add your own custom destruction code here.. attc.reset(); //[/Destructor] } //============================================================================== void CustomEnvelopeComponent::paint (juce::Graphics& g) { //[UserPrePaint] Add your own custom painting code here.. //[/UserPrePaint] //[UserPaint] Add your own custom painting code here.. //[/UserPaint] } void CustomEnvelopeComponent::resized() { //[UserPreResize] Add your own custom resize code here.. //[/UserPreResize] textEditor->setBounds (112, 4, getWidth() - 124, 24); label->setBounds (112, 28, getWidth() - 124, 24); //[UserResized] Add your own custom resize handling here.. //[/UserResized] } void CustomEnvelopeComponent::buttonClicked (juce::Button* buttonThatWasClicked) { //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] if (buttonThatWasClicked == toggleButton.get()) { //[UserButtonCode_toggleButton] -- add your button handler code here.. //[/UserButtonCode_toggleButton] } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] } void CustomEnvelopeComponent::lookAndFeelChanged() { //[UserCode_lookAndFeelChanged] -- Add your code here... ColorScheme cs = ColorScheme (processor.settingRefs.colorSchemeType()); labelLookAndFeel.setColour (Label::textColourId, cs.warning); label->setLookAndFeel (&labelLookAndFeel); textEditor->applyColourToAllText (cs.mainThinLine, true); //[/UserCode_lookAndFeelChanged] } //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... void CustomEnvelopeComponent::textEditorTextChanged (TextEditor& editor) { printf ("*** text changed!\n"); String txt = editor.getText(); ParseError err = kParseErrorNone; processor.settingRefs.setSequenceWithString (paramType, txt, &err); ColorScheme cs = ColorScheme (processor.settingRefs.colorSchemeType()); Colour c = (err < kParseErrorLevelFatal) ? cs.main : cs.warning; label->setColour (juce::Label::textColourId, c); if (err == kParseErrorValueOutOfRange) { if (paramType == "volume") { label->setText (getParseErrorString (err, 0, 15), dontSendNotification); } else if (paramType == "pitch") { label->setText (getParseErrorString (err, -64, 63), dontSendNotification); } else if (paramType == "duty") { label->setText (getParseErrorString (err, 0, 2), dontSendNotification); } } else { label->setText (getParseErrorString (err), dontSendNotification); } } void CustomEnvelopeComponent::sequenceChanged (String& str) { textEditor->setText (str); } //[/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]