diff --git a/Source/GeneralOptionsDlg.cpp b/Source/GeneralOptionsDlg.cpp deleted file mode 100644 index 221391c..0000000 --- a/Source/GeneralOptionsDlg.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - ============================================================================== - - 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... -#include "LumatoneEditorLookAndFeel.h" - -#include "./lumatone_editor_library/device/lumatone_controller.h" - -#include "MainComponent.h" -//[/Headers] - -#include "GeneralOptionsDlg.h" - - -//[MiscUserDefs] You can add your own user definitions and misc code here... -//[/MiscUserDefs] - -//============================================================================== -GeneralOptionsDlg::GeneralOptionsDlg (const LumatoneEditorState& stateIn) - : LumatoneEditorState("GeneralOptionsDialog", stateIn) -{ - //[Constructor_pre] You can add your own custom stuff here.. - //[/Constructor_pre] - - labelGeneralSettingslTitle.reset (new juce::Label ("labelGeneralSettingslTitle", - TRANS("General Settings"))); - addAndMakeVisible (labelGeneralSettingslTitle.get()); - labelGeneralSettingslTitle->setFont (juce::Font (18.00f, juce::Font::plain).withTypefaceStyle ("Regular")); - labelGeneralSettingslTitle->setJustificationType (juce::Justification::centredLeft); - labelGeneralSettingslTitle->setEditable (false, false, false); - labelGeneralSettingslTitle->setColour (juce::Label::textColourId, juce::Colour (0xff61acc8)); - labelGeneralSettingslTitle->setColour (juce::TextEditor::textColourId, juce::Colours::black); - labelGeneralSettingslTitle->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); - - labelGeneralSettingslTitle->setBounds (8, 0, 104, 24); - - buttonAfterTouchActive.reset (new juce::ToggleButton ("buttonAfterTouchActive")); - addAndMakeVisible (buttonAfterTouchActive.get()); - buttonAfterTouchActive->setButtonText (TRANS("Polyphonic Aftertouch")); - buttonAfterTouchActive->addListener (this); - - buttonAfterTouchActive->setBounds (8, 32, 176, 24); - - buttonLightOnKeyStrokes.reset (new juce::ToggleButton ("buttonLightOnKeyStrokes")); - addAndMakeVisible (buttonLightOnKeyStrokes.get()); - buttonLightOnKeyStrokes->setButtonText (TRANS("Light on Keystrokes")); - buttonLightOnKeyStrokes->addListener (this); - - buttonLightOnKeyStrokes->setBounds (8, 64, 176, 24); - - - //[UserPreSize] - labelGeneralSettingslTitle->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); - - addEditorListener(this); - //[/UserPreSize] - - setSize (188, 96); - - - //[Constructor] You can add your own custom stuff here.. - //[/Constructor] -} - -GeneralOptionsDlg::~GeneralOptionsDlg() -{ - //[Destructor_pre]. You can add your own custom destruction code here.. - removeEditorListener(this); - //[/Destructor_pre] - - labelGeneralSettingslTitle = nullptr; - buttonAfterTouchActive = nullptr; - buttonLightOnKeyStrokes = nullptr; - - - //[Destructor]. You can add your own custom destruction code here.. - //[/Destructor] -} - -//============================================================================== -void GeneralOptionsDlg::paint (juce::Graphics& g) -{ - //[UserPrePaint] Add your own custom painting code here.. - - //[/UserPrePaint] - - //[UserPaint] Add your own custom painting code here.. - - g.setColour(Colour(0xff212626)); - g.fillRoundedRectangle(getLocalBounds().toFloat().withTop(proportionOfHeight(SETTINGSAREAMARGINHEIGHT)), roundedCornerSize); - //[/UserPaint] -} - -void GeneralOptionsDlg::resized() -{ - //[UserPreResize] Add your own custom resize code here.. - //[/UserPreResize] - - //[UserResized] Add your own custom resize handling here.. - - roundedCornerSize = roundToInt(getParentHeight() * ROUNDEDCORNERTOAPPHEIGHT); - - resizeLabelWithHeight(labelGeneralSettingslTitle.get(), roundToInt(getHeight() * SETTINGSLABELHEIGHT)); - labelGeneralSettingslTitle->setTopLeftPosition(roundToInt(getWidth() * SETTINGSLABELMARGINWIDTH), 0); - - int marginX = roundToInt(getParentWidth() * SETTINGSCONTROLMARGINTOAPPWIDTH); - - buttonAfterTouchActive->setBounds( - marginX, proportionOfHeight(0.3f), proportionOfWidth(1.0f), proportionOfHeight(SETTINGSTOGGLEHEIGHTSCALAR) - ); - - buttonLightOnKeyStrokes->setBounds( - marginX, proportionOfHeight(0.5f), proportionOfWidth(1.0f), proportionOfHeight(SETTINGSTOGGLEHEIGHTSCALAR) - ); - - //[/UserResized] -} - -void GeneralOptionsDlg::buttonClicked (juce::Button* buttonThatWasClicked) -{ - //[UserbuttonClicked_Pre] - //[/UserbuttonClicked_Pre] - - if (buttonThatWasClicked == buttonAfterTouchActive.get()) - { - //[UserButtonCode_buttonAfterTouchActive] -- add your button handler code here.. - // ((MainContentComponent*)getParentComponent())->getMappingInEdit().afterTouchActive = buttonAfterTouchActive->getToggleState(); - // TerpstraSysExApplication::getApp().setHasChangesToSave(true); - setAftertouchEnabled(buttonAfterTouchActive->getToggleState()); - //[/UserButtonCode_buttonAfterTouchActive] - } - else if (buttonThatWasClicked == buttonLightOnKeyStrokes.get()) - { - //[UserButtonCode_buttonLightOnKeyStrokes] -- add your button handler code here.. - // ((MainContentComponent*)getParentComponent())->getMappingInEdit().lightOnKeyStrokes = buttonLightOnKeyStrokes->getToggleState(); - // TerpstraSysExApplication::getApp().setHasChangesToSave(true); - setLightOnKeyStrokes(buttonLightOnKeyStrokes->getToggleState()); - //[/UserButtonCode_buttonLightOnKeyStrokes] - } - - //[UserbuttonClicked_Post] - //[/UserbuttonClicked_Post] -} - - - -//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... -void GeneralOptionsDlg::lookAndFeelChanged() -{ - labelGeneralSettingslTitle->setColour(Label::ColourIds::textColourId, getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::LabelBlue)); -} - -void GeneralOptionsDlg::loadFromMapping() -{ - // auto mappingInEdit = ((MainContentComponent*)getParentComponent())->getMappingInEdit(); - buttonAfterTouchActive->setToggleState(getAftertouchOn(), juce::NotificationType::dontSendNotification); - buttonLightOnKeyStrokes->setToggleState(getLightOnKeyStrokes(), juce::NotificationType::dontSendNotification); -} - -//void GeneralOptionsDlg::presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) -//{ -// buttonAfterTouchActive->setToggleState(presetFlags.polyphonicAftertouch, dontSendNotification); -// buttonLightOnKeyStrokes->setToggleState(presetFlags.lightsOnKeystroke, dontSendNotification); -//} - -void GeneralOptionsDlg::lightOnKeyStrokesChanged(bool lightOn) -{ - buttonLightOnKeyStrokes->setToggleState(getLightOnKeyStrokes(), dontSendNotification); - -} - -void GeneralOptionsDlg::aftertouchToggled(bool enabled) -{ - buttonAfterTouchActive->setToggleState(getAftertouchOn(), dontSendNotification); - -} - -//[/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/GeneralOptionsDlg.h b/Source/GeneralOptionsDlg.h deleted file mode 100644 index 6c2842c..0000000 --- a/Source/GeneralOptionsDlg.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - ============================================================================== - - 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 - -#include "./lumatone_editor_library/listeners/editor_listener.h" - -#include "LumatoneEditorState.h" -//[/Headers] - - - -//============================================================================== -/** - //[Comments] - An auto-generated component, created by the Projucer. - - Describe your class and how it works here! - //[/Comments] -*/ -class GeneralOptionsDlg : public juce::Component, - public LumatoneEditorState, - public LumatoneEditor::EditorListener, - public juce::Button::Listener -{ -public: - //============================================================================== - GeneralOptionsDlg(const LumatoneEditorState& stateIn); - ~GeneralOptionsDlg() override; - - //============================================================================== - //[UserMethods] -- You can add your own custom methods in this section. - - // New mapping is loaded. Display data. - void loadFromMapping(); - - void lookAndFeelChanged() override; - - // LumatoneEditor::FirmwareListener Implementation - //void presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) override; - - // LumatoneEditor::EditorListener Implementation - void lightOnKeyStrokesChanged(bool lightOn) override; - void aftertouchToggled(bool enabled) override; - - //[/UserMethods] - - void paint (juce::Graphics& g) override; - void resized() override; - void buttonClicked (juce::Button* buttonThatWasClicked) override; - - - -private: - //[UserVariables] -- You can add your own custom variables in this section. - int roundedCornerSize; - //[/UserVariables] - - //============================================================================== - std::unique_ptr labelGeneralSettingslTitle; - std::unique_ptr buttonAfterTouchActive; - std::unique_ptr buttonLightOnKeyStrokes; - - - //============================================================================== - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GeneralOptionsDlg) -}; - -//[EndFile] You can add extra defines here... -//[/EndFile] diff --git a/Source/Main.cpp b/Source/Main.cpp index c3ac7a2..595af05 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -23,7 +23,6 @@ #include "./lumatone_editor_library/graphics/view_constants.h" #include "./lumatone_editor_library/palettes/colour_palette_file.h" -#include "GeneralOptionsDlg.h" #include "VelocityCurveDlgBase.h" #include "NoteOnOffVelocityCurveDialog.h" #include "LumatoneMenu.h" diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index a805fc5..310beab 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -18,10 +18,9 @@ #include "NoteEditArea.h" #include "IsomorphicMassAssign.h" -#include "GeneralOptionsDlg.h" #include "CurvesArea.h" #include "GlobalSettingsArea.h" -#include "PedalSensitivityDlg.h" +#include "MappingSettingsComponent.h" #include "./ColourPaletteWindow.h" @@ -49,15 +48,10 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j // Edit function area noteEditArea.reset(new NoteEditArea(stateIn)); - addAndMakeVisible(noteEditArea.get()); noteEditArea->getOctaveBoardSelectorTab()->addChangeListener(this); noteEditArea->getColourViewComponent()->addListener(this); // Open up ColourPaletteWindow - generalOptionsArea.reset(new GeneralOptionsDlg(stateIn)); - addAndMakeVisible(generalOptionsArea.get()); - - pedalSensitivityDlg.reset(new PedalSensitivityDlg(stateIn)); - addAndMakeVisible(pedalSensitivityDlg.get()); + mappingSettingsComponent = std::make_unique(stateIn); curvesArea.reset(new CurvesArea(stateIn)); addAndMakeVisible(curvesArea.get()); @@ -66,7 +60,12 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j addAndMakeVisible(globalSettingsArea.get()); globalSettingsArea->listenToColourEditButtons(this); - // getLumatoneController()->addFirmwareListener(this + sectionTabs = std::make_unique(juce::TabbedButtonBar::TabsAtTop); + addAndMakeVisible(*sectionTabs); + sectionTabs->addTab("Key Editor", juce::Colour(), noteEditArea.get(), false); + sectionTabs->addTab("AutoGenerator", juce::Colour(), noteEditArea.get(), false); + sectionTabs->addTab("Advanced", juce::Colour(), noteEditArea.get(), false); + sectionTabs->addTab("Mapping Settings", juce::Colour(), mappingSettingsComponent.get(), false); btnLoadFile.reset(new juce::TextButton("btnLoadFile")); addAndMakeVisible(btnLoadFile.get()); @@ -127,14 +126,13 @@ MainContentComponent::~MainContentComponent() btnSaveFile = nullptr; btnImportFile = nullptr; - midiEditArea = nullptr; - allKeysOverview = nullptr; + globalSettingsArea = nullptr; + curvesArea = nullptr; + mappingSettingsComponent = nullptr; noteEditArea = nullptr; - generalOptionsArea = nullptr; - curvesArea = nullptr; - globalSettingsArea = nullptr; - pedalSensitivityDlg = nullptr; + midiEditArea = nullptr; + allKeysOverview = nullptr; lblAppName = nullptr; lblAppVersion = nullptr; @@ -486,11 +484,13 @@ void MainContentComponent::resized() btnImportFile->setBounds(allKeysOverview->getRight() - importWidth, importY, importWidth, btnHeight); // Edit function/single key field area - noteEditArea->setSize(proportionOfWidth(assignWidth), proportionOfHeight(assignHeight)); - noteEditArea->setControlsTopLeftPosition(proportionOfWidth(assignMarginX), controlsArea.getY()); + // noteEditArea->setSize(proportionOfWidth(assignWidth), proportionOfHeight(assignHeight)); + // noteEditArea->setControlsTopLeftPosition(proportionOfWidth(assignMarginX), controlsArea.getY()); + + sectionTabs->setBounds(proportionOfWidth(assignMarginX), controlsArea.getY(), proportionOfWidth(assignWidth), proportionOfHeight(assignHeight)); - generalOptionsArea->setBounds(getLocalBounds().toFloat().getProportion(generalSettingsBounds).toNearestInt()); - pedalSensitivityDlg->setBounds(getLocalBounds().toFloat().getProportion(pedalSettingsBounds).toNearestInt()); + // generalOptionsArea->setBounds(getLocalBounds().toFloat().getProportion(generalSettingsBounds).toNearestInt()); + // pedalSensitivityDlg->setBounds(getLocalBounds().toFloat().getProportion(pedalSettingsBounds).toNearestInt()); curvesArea->setBounds(getLocalBounds().toFloat().getProportion(curvesAreaBounds).toNearestInt()); diff --git a/Source/MainComponent.h b/Source/MainComponent.h index 4d83d54..82fa906 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -20,10 +20,10 @@ class LumatoneKeyboardComponent; class MidiEditArea; class NoteEditArea; -class GeneralOptionsDlg; +class MappingSettingsComponent; class CurvesArea; class GlobalSettingsArea; -class PedalSensitivityDlg; + //============================================================================== /* @@ -93,19 +93,21 @@ class MainContentComponent : public juce::Component std::unique_ptr allKeysOverview; // Edit fields for setting key and button parameters, and edits for single keys - std::unique_ptr noteEditArea; - std::unique_ptr generalOptionsArea; + std::unique_ptr noteEditArea; + std::unique_ptr mappingSettingsComponent; + std::unique_ptr curvesArea; - std::unique_ptr globalSettingsArea; - std::unique_ptr pedalSensitivityDlg; + std::unique_ptr globalSettingsArea; + + std::unique_ptr sectionTabs; std::unique_ptr btnLoadFile; std::unique_ptr btnSaveFile; std::unique_ptr btnImportFile; // Version signature in bottom left of window - std::unique_ptr lblAppName; - std::unique_ptr lblAppVersion; + std::unique_ptr lblAppName; + std::unique_ptr lblAppVersion; // Buffer for copy/paste of sub board data std::unique_ptr copiedSubBoardData; diff --git a/Source/MappingSettingsComponent.cpp b/Source/MappingSettingsComponent.cpp new file mode 100644 index 0000000..34ea4d5 --- /dev/null +++ b/Source/MappingSettingsComponent.cpp @@ -0,0 +1,236 @@ +/* +============================================================================== + + MappingSettingsComponent.h + Created: 15 Jan 2023 + Author: Vincenzo + +============================================================================== +*/ + +#include "MappingSettingsComponent.h" + +#include "LumatoneEditorLookAndFeel.h" + +#include "./lumatone_editor_library/graphics/view_constants.h" + +//============================================================================== +MappingSettingsComponent::MappingSettingsComponent (const LumatoneEditorState& stateIn) + : LumatoneEditorState("MappingSettingsComponent", stateIn) +{ + labelGeneralSettingslTitle.reset (new juce::Label ("labelGeneralSettingslTitle", juce::translate("General Settings"))); + labelGeneralSettingslTitle->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); + labelGeneralSettingslTitle->setJustificationType (juce::Justification::centredLeft); + labelGeneralSettingslTitle->setEditable (false, false, false); + labelGeneralSettingslTitle->setColour(Label::ColourIds::textColourId, getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::LabelBlue)); + labelGeneralSettingslTitle->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); + addAndMakeVisible (labelGeneralSettingslTitle.get()); + + buttonAfterTouchActive.reset (new juce::ToggleButton ("buttonAfterTouchActive")); + buttonAfterTouchActive->setButtonText (juce::translate("Polyphonic Aftertouch")); + buttonAfterTouchActive->onClick = [&]() + { + setAftertouchEnabled(buttonAfterTouchActive->getToggleState()); + }; + addAndMakeVisible (buttonAfterTouchActive.get()); + + buttonLightOnKeyStrokes.reset (new juce::ToggleButton ("buttonLightOnKeyStrokes")); + buttonLightOnKeyStrokes->setButtonText (juce::translate("Light on Keystrokes")); + buttonLightOnKeyStrokes->onClick = [&]() + { + setLightOnKeyStrokes(buttonLightOnKeyStrokes->getToggleState()); + }; + addAndMakeVisible (buttonLightOnKeyStrokes.get()); + + labelExprContrSensitivity.reset (new juce::Label ("labelExprContrSensitivity", juce::translate("Sensitivity"))); + labelExprContrSensitivity->setFont(getAppFonts().getFont(LumatoneEditorFont::GothamNarrowMedium)); + labelExprContrSensitivity->setJustificationType (juce::Justification::centred); + labelExprContrSensitivity->setEditable (false, false, false); + labelExprContrSensitivity->setColour (juce::TextEditor::textColourId, juce::Colours::black); + labelExprContrSensitivity->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); + addAndMakeVisible (labelExprContrSensitivity.get()); + + btnInvertExpression.reset (new juce::ToggleButton ("btnInvertExpression")); + btnInvertExpression->setButtonText (juce::translate("Invert")); + btnInvertExpression->onClick = [&]() + { + setInvertExpression(btnInvertExpression->getToggleState()); + }; + addAndMakeVisible (btnInvertExpression.get()); + + lblExpression.reset (new juce::Label ("lblExpression", juce::translate("Expression"))); + lblExpression->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); + lblExpression->setJustificationType (juce::Justification::centredLeft); + lblExpression->setEditable (false, false, false); + lblExpression->setColour (juce::Label::textColourId, juce::Colour (0xff61acc8)); + lblExpression->setColour (juce::TextEditor::textColourId, juce::Colours::black); + lblExpression->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); + addAndMakeVisible (lblExpression.get()); + + sldExprCtrlSensitivity.reset (new juce::Slider ("sldExprCtrlSensitivity")); + sldExprCtrlSensitivity->setRange (0, 127, 1); + sldExprCtrlSensitivity->setSliderStyle (juce::Slider::RotaryHorizontalVerticalDrag); + sldExprCtrlSensitivity->setTextBoxStyle (juce::Slider::TextBoxBelow, false, 60, 20); + sldExprCtrlSensitivity->onValueChange = [&] () + { + exprSensitivitySliderCallback(); + }; + addAndMakeVisible (sldExprCtrlSensitivity.get()); + + btnInvertSustain.reset (new juce::ToggleButton ("btnInvertSustain")); + btnInvertSustain->setButtonText (juce::translate("Invert")); + btnInvertSustain->onClick = [&]() + { + setInvertSustain(btnInvertSustain->getToggleState()); + }; + addAndMakeVisible (btnInvertSustain.get()); + + lblSustain.reset (new juce::Label ("lblSustain", juce::translate("Sustain"))); + lblSustain->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); + lblSustain->setJustificationType (juce::Justification::centredLeft); + lblSustain->setEditable (false, false, false); + lblSustain->setColour (juce::Label::textColourId, juce::Colour (0xff61acc8)); + lblSustain->setColour (juce::TextEditor::textColourId, juce::Colours::black); + lblSustain->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); + addAndMakeVisible (lblSustain.get()); + + + addEditorListener(this); +} + +MappingSettingsComponent::~MappingSettingsComponent() +{ + removeEditorListener(this); + + labelGeneralSettingslTitle = nullptr; + buttonAfterTouchActive = nullptr; + buttonLightOnKeyStrokes = nullptr; +} + +//============================================================================== +void MappingSettingsComponent::paint (juce::Graphics& g) +{ + g.setColour(juce::Colour(0xff212626)); + g.fillRoundedRectangle(getLocalBounds().toFloat().withTop(proportionOfHeight(SETTINGSAREAMARGINHEIGHT)), roundedCornerSize); +} + +void MappingSettingsComponent::resized() +{ + float w = getWidth(); + float h = getHeight(); + + roundedCornerSize = roundToInt(getParentHeight() * ROUNDEDCORNERTOAPPHEIGHT); + + resizeLabelWithHeight(labelGeneralSettingslTitle.get(), roundToInt(getHeight() * SETTINGSLABELHEIGHT)); + labelGeneralSettingslTitle->setTopLeftPosition(roundToInt(getWidth() * SETTINGSLABELMARGINWIDTH), 0); + + int marginX = roundToInt(getParentWidth() * SETTINGSCONTROLMARGINTOAPPWIDTH); + + buttonAfterTouchActive->setBounds( + marginX, proportionOfHeight(0.3f), proportionOfWidth(1.0f), proportionOfHeight(SETTINGSTOGGLEHEIGHTSCALAR) + ); + + buttonLightOnKeyStrokes->setBounds( + marginX, proportionOfHeight(0.5f), proportionOfWidth(1.0f), proportionOfHeight(SETTINGSTOGGLEHEIGHTSCALAR) + ); + + roundedCornerSize = roundToInt(getParentHeight() * ROUNDEDCORNERTOAPPHEIGHT); + + int areaMarginWidth = roundToInt(w * sectionMarginWidth) * 0.5f; + int areaMarginHeight = roundToInt(h * SETTINGSAREAMARGINHEIGHT); + + expressionBounds = getLocalBounds().toFloat().withTop(areaMarginHeight).withRight(roundToInt(w * 0.5f - areaMarginWidth)); + sustainBounds = getLocalBounds().toFloat().withTop(areaMarginHeight).withLeft(roundToInt(w * 0.5f + areaMarginWidth)); + + int lblMarginX = roundToInt(w * SETTINGSLABELMARGINWIDTH); + int lblWidth = roundToInt(w * 0.5f); + int lblHeight = roundToInt(h * SETTINGSLABELHEIGHT); + lblExpression->setBounds(expressionBounds.getX() + lblMarginX, 0, lblWidth, lblHeight); + lblSustain->setBounds(sustainBounds.getX() + lblMarginX, 0, lblWidth, lblHeight); + + int controlMargin = roundToInt(getParentWidth() * SETTINGSCONTROLMARGINTOAPPWIDTH); + int buttonHeight = roundToInt(h * SETTINGSTOGGLEHEIGHTSCALAR); + int buttonY = roundToInt(h * 0.3f); + btnInvertExpression->setBounds(expressionBounds.withTrimmedLeft(controlMargin).withTop(buttonY).withHeight(buttonHeight).toNearestInt()); + btnInvertSustain->setBounds(sustainBounds.withTrimmedLeft(controlMargin).withTop(buttonY).withHeight(buttonHeight).toNearestInt()); + + sldExprCtrlSensitivity->setBounds( + expressionBounds.reduced(expressionBounds.getWidth() * 0.2f, 0) + .withTop(btnInvertExpression->getBottom() + buttonHeight) + .withTrimmedBottom(buttonHeight * 1.5f) + .toNearestInt() + ); + + labelExprContrSensitivity->setBounds( + expressionBounds.withTop(sldExprCtrlSensitivity->getBottom() + buttonHeight * 0.1f) + .withTrimmedBottom(buttonHeight * 0.5f) + .toNearestInt() + ); +} + +void MappingSettingsComponent::loadFromMapping() +{ + buttonAfterTouchActive->setToggleState(getAftertouchOn(), juce::NotificationType::dontSendNotification); + buttonLightOnKeyStrokes->setToggleState(getLightOnKeyStrokes(), juce::NotificationType::dontSendNotification); + btnInvertExpression->setToggleState(getInvertExpression(), juce::NotificationType::dontSendNotification); + btnInvertSustain->setToggleState(getInvertSustain(), juce::NotificationType::dontSendNotification); + sldExprCtrlSensitivity->setValue(getExpressionSensitivity(), juce::NotificationType::dontSendNotification); +} + +void MappingSettingsComponent::exprSensitivitySliderCallback() +{ + int newSensitvity = sldExprCtrlSensitivity->getValue(); + // ToDo value checking: encapsulate in keyboard data structure? + if (newSensitvity < 0) + { + newSensitvity = 0; + sldExprCtrlSensitivity->setValue(newSensitvity); + } + + if (newSensitvity > 0x7f) + { + newSensitvity = 0x7f; + sldExprCtrlSensitivity->setValue(newSensitvity); + } + + setExpressionSensitivity(newSensitvity); +} + +void MappingSettingsComponent::lightOnKeyStrokesChanged(bool lightOn) +{ + buttonLightOnKeyStrokes->setToggleState(getLightOnKeyStrokes(), dontSendNotification); +} + +void MappingSettingsComponent::aftertouchToggled(bool enabled) +{ + buttonAfterTouchActive->setToggleState(getAftertouchOn(), dontSendNotification); +} + +void MappingSettingsComponent::expressionPedalSensitivityChanged(unsigned char value) +{ + sldExprCtrlSensitivity->setValue(getExpressionSensitivity(), dontSendNotification); +} + +void MappingSettingsComponent::invertFootControllerChanged(bool inverted) +{ + btnInvertExpression->setToggleState(getInvertExpression(), dontSendNotification); +} + +void MappingSettingsComponent::invertSustainToggled(bool inverted) +{ + btnInvertSustain->setToggleState(getInvertSustain(), dontSendNotification); +} + +void MappingSettingsComponent::firmwareVersionChanged() +{ + if (getFirmwareSupport().versionAcknowledgesCommand(getLumatoneVersion(), INVERT_SUSTAIN_PEDAL)) + { + btnInvertSustain->setEnabled(true); + btnInvertSustain->setTooltip(""); + } + else + { + btnInvertSustain->setEnabled(false); + btnInvertSustain->setTooltip("This feature is not supported by the firmware version of your Lumatone."); + } +} diff --git a/Source/MappingSettingsComponent.h b/Source/MappingSettingsComponent.h new file mode 100644 index 0000000..3e1c2f1 --- /dev/null +++ b/Source/MappingSettingsComponent.h @@ -0,0 +1,67 @@ +/* + ============================================================================== + + MappingSettingsComponent.h + Created: 15 Jan 2023 + Author: Vincenzo + + ============================================================================== +*/ + +#ifndef LUMATONE_EDITOR_MAPPING_SETTINGS_COMPONENT_H +#define LUMATONE_EDITOR_MAPPING_SETTINGS_COMPONENT_H + +#include "./lumatone_editor_library/listeners/editor_listener.h" +#include "LumatoneEditorState.h" + +class MappingSettingsComponent : public juce::Component + , public LumatoneEditorState + , public LumatoneEditor::EditorListener +{ +public: + MappingSettingsComponent(const LumatoneEditorState& stateIn); + ~MappingSettingsComponent() override; + + void paint (juce::Graphics& g) override; + void resized() override; + + void loadFromMapping(); + + // LumatoneEditor::EditorListener Implementation + void lightOnKeyStrokesChanged(bool lightOn) override; + void aftertouchToggled(bool enabled) override; + + void expressionPedalSensitivityChanged(unsigned char value) override; + void invertFootControllerChanged(bool inverted) override; + + void invertSustainToggled(bool inverted) override; + + void firmwareVersionChanged() override; + +private: + + void exprSensitivitySliderCallback(); + +private: + int roundedCornerSize = 0; + juce::Rectangle expressionBounds; + juce::Rectangle sustainBounds; + const float sectionMarginWidth = 0.05f; + + //============================================================================== + std::unique_ptr labelGeneralSettingslTitle; + std::unique_ptr buttonAfterTouchActive; + std::unique_ptr buttonLightOnKeyStrokes; + + std::unique_ptr labelExprContrSensitivity; + std::unique_ptr btnInvertExpression; + std::unique_ptr lblExpression; + std::unique_ptr sldExprCtrlSensitivity; + std::unique_ptr btnInvertSustain; + std::unique_ptr lblSustain; + + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MappingSettingsComponent) +}; + +#endif // LUMATONE_EDITOR_MAPPING_SETTINGS_COMPONENT_H \ No newline at end of file diff --git a/Source/PedalSensitivityDlg.cpp b/Source/PedalSensitivityDlg.cpp deleted file mode 100644 index 42fcd85..0000000 --- a/Source/PedalSensitivityDlg.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* - ============================================================================== - - 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... -#include "./lumatone_editor_library/device/lumatone_controller.h" - -#include "LumatoneEditorStyleCommon.h" -#include "LumatoneEditorFontLibrary.h" -//[/Headers] - -#include "PedalSensitivityDlg.h" - - -//[MiscUserDefs] You can add your own user definitions and misc code here... -//[/MiscUserDefs] - -//============================================================================== -PedalSensitivityDlg::PedalSensitivityDlg (const LumatoneEditorState& stateIn) - : LumatoneEditorState("PedalSensitivityDialog", stateIn) -{ - //[Constructor_pre] You can add your own custom stuff here.. - //[/Constructor_pre] - - labelExprContrSensitivity.reset (new juce::Label ("new label", - TRANS("Sensitivity"))); - addAndMakeVisible (labelExprContrSensitivity.get()); - labelExprContrSensitivity->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular")); - labelExprContrSensitivity->setJustificationType (juce::Justification::centredLeft); - labelExprContrSensitivity->setEditable (false, false, false); - labelExprContrSensitivity->setColour (juce::TextEditor::textColourId, juce::Colours::black); - labelExprContrSensitivity->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); - - labelExprContrSensitivity->setBounds (13, 152, 74, 24); - - btnInvertExpression.reset (new juce::ToggleButton ("btnInvertExpression")); - addAndMakeVisible (btnInvertExpression.get()); - btnInvertExpression->setButtonText (TRANS("Invert")); - btnInvertExpression->addListener (this); - - btnInvertExpression->setBounds (10, 32, 99, 24); - - lblExpression.reset (new juce::Label ("lblExpression", - TRANS("Expression"))); - addAndMakeVisible (lblExpression.get()); - lblExpression->setFont (juce::Font (18.00f, juce::Font::plain).withTypefaceStyle ("Regular")); - lblExpression->setJustificationType (juce::Justification::centredLeft); - lblExpression->setEditable (false, false, false); - lblExpression->setColour (juce::Label::textColourId, juce::Colour (0xff61acc8)); - lblExpression->setColour (juce::TextEditor::textColourId, juce::Colours::black); - lblExpression->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); - - lblExpression->setBounds (6, 3, 104, 24); - - sldExprCtrlSensitivity.reset (new juce::Slider ("sldExprCtrlSensitivity")); - addAndMakeVisible (sldExprCtrlSensitivity.get()); - sldExprCtrlSensitivity->setRange (0, 127, 1); - sldExprCtrlSensitivity->setSliderStyle (juce::Slider::RotaryHorizontalVerticalDrag); - sldExprCtrlSensitivity->setTextBoxStyle (juce::Slider::TextBoxBelow, false, 60, 20); - sldExprCtrlSensitivity->addListener (this); - - sldExprCtrlSensitivity->setBounds (-32, 49, 160, 97); - - btnInvertSustain.reset (new juce::ToggleButton ("btnInvertSustain")); - addAndMakeVisible (btnInvertSustain.get()); - btnInvertSustain->setButtonText (TRANS("Invert")); - btnInvertSustain->addListener (this); - - btnInvertSustain->setBounds (125, 32, 86, 24); - - lblSustain.reset (new juce::Label ("lblSustain", - TRANS("Sustain"))); - addAndMakeVisible (lblSustain.get()); - lblSustain->setFont (juce::Font (18.00f, juce::Font::plain).withTypefaceStyle ("Regular")); - lblSustain->setJustificationType (juce::Justification::centredLeft); - lblSustain->setEditable (false, false, false); - lblSustain->setColour (juce::Label::textColourId, juce::Colour (0xff61acc8)); - lblSustain->setColour (juce::TextEditor::textColourId, juce::Colours::black); - lblSustain->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); - - lblSustain->setBounds (121, 3, 99, 24); - - - //[UserPreSize] - lblExpression->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); - lblSustain->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); - labelExprContrSensitivity->setFont(getAppFonts().getFont(LumatoneEditorFont::GothamNarrowMedium)); - labelExprContrSensitivity->setJustificationType(Justification::centred); - - addEditorListener(this); - //[/UserPreSize] - - setSize (134, 96); - - - //[Constructor] You can add your own custom stuff here.. - //[/Constructor] -} - -PedalSensitivityDlg::~PedalSensitivityDlg() -{ - //[Destructor_pre]. You can add your own custom destruction code here.. - removeEditorListener(this); - //[/Destructor_pre] - - labelExprContrSensitivity = nullptr; - btnInvertExpression = nullptr; - lblExpression = nullptr; - sldExprCtrlSensitivity = nullptr; - btnInvertSustain = nullptr; - lblSustain = nullptr; - - - //[Destructor]. You can add your own custom destruction code here.. - //[/Destructor] -} - -//============================================================================== -void PedalSensitivityDlg::paint (juce::Graphics& g) -{ - //[UserPrePaint] Add your own custom painting code here.. - //[/UserPrePaint] - - //[UserPaint] Add your own custom painting code here.. - g.setColour(Colour(0xff212626)); - g.fillRoundedRectangle(expressionBounds, roundedCornerSize); - g.fillRoundedRectangle(sustainBounds, roundedCornerSize); - //[/UserPaint] -} - -void PedalSensitivityDlg::resized() -{ - //[UserPreResize] Add your own custom resize code here.. - float w = getWidth(); - float h = getHeight(); - //[/UserPreResize] - - //[UserResized] Add your own custom resize handling here.. - - roundedCornerSize = roundToInt(getParentHeight() * ROUNDEDCORNERTOAPPHEIGHT); - - int areaMarginWidth = roundToInt(w * sectionMarginWidth) * 0.5f; - int areaMarginHeight = roundToInt(h * SETTINGSAREAMARGINHEIGHT); - - expressionBounds = getLocalBounds().toFloat().withTop(areaMarginHeight).withRight(roundToInt(w * 0.5f - areaMarginWidth)); - sustainBounds = getLocalBounds().toFloat().withTop(areaMarginHeight).withLeft(roundToInt(w * 0.5f + areaMarginWidth)); - - int lblMarginX = roundToInt(w * SETTINGSLABELMARGINWIDTH); - int lblWidth = roundToInt(w * 0.5f); - int lblHeight = roundToInt(h * SETTINGSLABELHEIGHT); - lblExpression->setBounds(expressionBounds.getX() + lblMarginX, 0, lblWidth, lblHeight); - lblSustain->setBounds(sustainBounds.getX() + lblMarginX, 0, lblWidth, lblHeight); - - int controlMargin = roundToInt(getParentWidth() * SETTINGSCONTROLMARGINTOAPPWIDTH); - int buttonHeight = roundToInt(h * SETTINGSTOGGLEHEIGHTSCALAR); - int buttonY = roundToInt(h * 0.3f); - btnInvertExpression->setBounds(expressionBounds.withTrimmedLeft(controlMargin).withTop(buttonY).withHeight(buttonHeight).toNearestInt()); - btnInvertSustain->setBounds(sustainBounds.withTrimmedLeft(controlMargin).withTop(buttonY).withHeight(buttonHeight).toNearestInt()); - - sldExprCtrlSensitivity->setBounds( - expressionBounds.reduced(expressionBounds.getWidth() * 0.2f, 0) - .withTop(btnInvertExpression->getBottom() + buttonHeight) - .withTrimmedBottom(buttonHeight * 1.5f) - .toNearestInt() - ); - - labelExprContrSensitivity->setBounds( - expressionBounds.withTop(sldExprCtrlSensitivity->getBottom() + buttonHeight * 0.1f) - .withTrimmedBottom(buttonHeight * 0.5f) - .toNearestInt() - ); - //[/UserResized] -} - -void PedalSensitivityDlg::buttonClicked (juce::Button* buttonThatWasClicked) -{ - //[UserbuttonClicked_Pre] - //[/UserbuttonClicked_Pre] - - if (buttonThatWasClicked == btnInvertExpression.get()) - { - //[UserButtonCode_btnInvertExpression] -- add your button handler code here.. - setInvertExpression(btnInvertExpression->getToggleState()); - //[/UserButtonCode_btnInvertExpression] - } - else if (buttonThatWasClicked == btnInvertSustain.get()) - { - //[UserButtonCode_btnInvertSustain] -- add your button handler code here.. - setInvertSustain(btnInvertSustain->getToggleState()); - //[/UserButtonCode_btnInvertSustain] - } - - //[UserbuttonClicked_Post] - //[/UserbuttonClicked_Post] -} - -void PedalSensitivityDlg::sliderValueChanged (juce::Slider* sliderThatWasMoved) -{ - //[UsersliderValueChanged_Pre] - //[/UsersliderValueChanged_Pre] - - if (sliderThatWasMoved == sldExprCtrlSensitivity.get()) - { - //[UserSliderCode_sldExprCtrlSensitivity] -- add your slider handling code here.. - int newSensitvity = sldExprCtrlSensitivity->getValue(); - // ToDo value checking: encapsulate in keyboard data structure? - if (newSensitvity < 0) - { - newSensitvity = 0; - sldExprCtrlSensitivity->setValue(newSensitvity); - } - - if (newSensitvity > 0x7f) - { - newSensitvity = 0x7f; - sldExprCtrlSensitivity->setValue(newSensitvity); - } - - setExpressionSensitivity(newSensitvity); - //[/UserSliderCode_sldExprCtrlSensitivity] - } - - //[UsersliderValueChanged_Post] - //[/UsersliderValueChanged_Post] -} - - - -//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... - -void PedalSensitivityDlg::lookAndFeelChanged() -{ - juce::Component::lookAndFeelChanged(); -// auto newLookAndFeel = dynamic_cast(&getLookAndFeel()); -// if (newLookAndFeel) -// { -// lblExpression->setColour(Label::ColourIds::textColourId, newLookAndFeel->findColour(LumatoneEditorColourIDs::LabelBlue)); -// lblSustain->setColour(Label::ColourIds::textColourId, newLookAndFeel->findColour(LumatoneEditorColourIDs::LabelBlue)); -// labelExprContrSensitivity->setColour(Label::ColourIds::textColourId, newLookAndFeel->findColour(LumatoneEditorColourIDs::DescriptionText)); -// } -} - -void PedalSensitivityDlg::loadFromMapping() -{ - // auto mappingInEdit = ((MainContentComponent*)getParentComponent())->getMappingInEdit(); - - btnInvertExpression->setToggleState(getInvertExpression(), juce::NotificationType::dontSendNotification); - btnInvertSustain->setToggleState(getInvertSustain(), juce::NotificationType::dontSendNotification); - sldExprCtrlSensitivity->setValue(getExpressionSensitivity(), juce::NotificationType::dontSendNotification); -} - -//void PedalSensitivityDlg::firmwareRevisionReceived(LumatoneFirmware::Version version) -//{ -// if (getFirmwareSupport().versionAcknowledgesCommand(version, INVERT_SUSTAIN_PEDAL)) -// { -// btnInvertSustain->setEnabled(true); -// btnInvertSustain->setTooltip(""); -// } -// else -// { -// btnInvertSustain->setEnabled(false); -// btnInvertSustain->setTooltip("This feature is not supported by the firmware version of your Lumatone."); -// } -//} - -//void PedalSensitivityDlg::presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) -//{ -// btnInvertExpression->setToggleState(presetFlags.expressionPedalInverted, dontSendNotification); -// btnInvertSustain->setToggleState(presetFlags.sustainPedalInverted, dontSendNotification); -//} - -//void PedalSensitivityDlg::expressionPedalSensitivityReceived(int sensitivity) -//{ -// sldExprCtrlSensitivity->setValue(sensitivity, dontSendNotification); -//} - -void PedalSensitivityDlg::expressionPedalSensitivityChanged(unsigned char value) -{ - sldExprCtrlSensitivity->setValue(getExpressionSensitivity(), dontSendNotification); -} - -void PedalSensitivityDlg::invertFootControllerChanged(bool inverted) -{ - btnInvertExpression->setToggleState(getInvertExpression(), dontSendNotification); -} - -void PedalSensitivityDlg::invertSustainToggled(bool inverted) -{ - btnInvertSustain->setToggleState(getInvertSustain(), dontSendNotification); -} - -void PedalSensitivityDlg::firmwareVersionChanged() -{ - if (getFirmwareSupport().versionAcknowledgesCommand(getLumatoneVersion(), INVERT_SUSTAIN_PEDAL)) - { - btnInvertSustain->setEnabled(true); - btnInvertSustain->setTooltip(""); - } - else - { - btnInvertSustain->setEnabled(false); - btnInvertSustain->setTooltip("This feature is not supported by the firmware version of your Lumatone."); - } -} - - -//[/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/PedalSensitivityDlg.h b/Source/PedalSensitivityDlg.h deleted file mode 100644 index b05dff8..0000000 --- a/Source/PedalSensitivityDlg.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - ============================================================================== - - 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 - -#include "LumatoneEditorState.h" - -#include "./lumatone_editor_library/listeners/editor_listener.h" -//[/Headers] - - - -//============================================================================== -/** - //[Comments] - An auto-generated component, created by the Projucer. - - Describe your class and how it works here! - //[/Comments] -*/ -class PedalSensitivityDlg : public juce::Component - , public LumatoneEditorState - //, private LumatoneEditor::FirmwareListener - , private LumatoneEditor::EditorListener - , private juce::Button::Listener - , private juce::Slider::Listener -{ -public: - //============================================================================== - PedalSensitivityDlg (const LumatoneEditorState& stateIn); - ~PedalSensitivityDlg() override; - - //============================================================================== - //[UserMethods] -- You can add your own custom methods in this section. - // New mapping is loaded. Display data. - void loadFromMapping(); - - void lookAndFeelChanged() override; - - // LumatoneEditor::FirmwareListener implementation - //void firmwareRevisionReceived(LumatoneFirmware::Version version) override; - //void presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) override; - //void expressionPedalSensitivityReceived(int sensitivity) override; - - // LumatoneEditor::Editor implementation - void expressionPedalSensitivityChanged(unsigned char value) override; - void invertFootControllerChanged(bool inverted) override; - - void invertSustainToggled(bool inverted) override; - - void firmwareVersionChanged() override; - - //[/UserMethods] - - void paint (juce::Graphics& g) override; - void resized() override; - void buttonClicked (juce::Button* buttonThatWasClicked) override; - void sliderValueChanged (juce::Slider* sliderThatWasMoved) override; - -private: - //[UserVariables] -- You can add your own custom variables in this section. - int roundedCornerSize = 0; - Rectangle expressionBounds; - Rectangle sustainBounds; - const float sectionMarginWidth = 0.05f; - - //[/UserVariables] - - //============================================================================== - std::unique_ptr labelExprContrSensitivity; - std::unique_ptr btnInvertExpression; - std::unique_ptr lblExpression; - std::unique_ptr sldExprCtrlSensitivity; - std::unique_ptr btnInvertSustain; - std::unique_ptr lblSustain; - - - //============================================================================== - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PedalSensitivityDlg) -}; - -//[EndFile] You can add extra defines here... -//[/EndFile]