From 8333fcfde2cf823bd2a302a93da0bb7a7aa0c137 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Tue, 4 Jun 2024 00:54:00 -0400 Subject: [PATCH] sketch out key settings panel and fix control area height --- Source/MainComponent.cpp | 30 ++--- Source/MainComponent.h | 2 + Source/mapping_editors/KeyEditorControls.cpp | 116 ++++++++++++++++++ Source/mapping_editors/KeyEditorControls.h | 79 ++++++++++++ Source/mapping_editors/KeyEditorPanel.cpp | 55 +++++++++ Source/mapping_editors/KeyEditorPanel.h | 64 ++++++++++ .../mapping_editors/MappingSettingsPanel.cpp | 2 +- .../mapping_editors/MultiSelectControls.cpp | 42 +++++++ Source/mapping_editors/MultiSelectControls.h | 35 ++++++ 9 files changed, 401 insertions(+), 24 deletions(-) create mode 100644 Source/mapping_editors/KeyEditorControls.cpp create mode 100644 Source/mapping_editors/KeyEditorControls.h create mode 100644 Source/mapping_editors/KeyEditorPanel.cpp create mode 100644 Source/mapping_editors/KeyEditorPanel.h create mode 100644 Source/mapping_editors/MultiSelectControls.cpp create mode 100644 Source/mapping_editors/MultiSelectControls.h diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 0c05075..03c9e62 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -15,12 +15,10 @@ #include "LumatoneMenu.h" #include "MidiEditArea.h" -// #include "NoteEditArea.h" -// #include "IsomorphicMassAssign.h" -// #include "CurvesArea.h" +#include "mapping_editors/KeyEditorPanel.h" +#include "mapping_editors/MappingSettingsPanel.h" #include "GlobalSettingsArea.h" -#include "MappingSettingsPanel.h" #include "./ColourPaletteWindow.h" @@ -51,6 +49,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j // noteEditArea->getOctaveBoardSelectorTab()->addChangeListener(this); // noteEditArea->getColourViewComponent()->addListener(this); // Open up ColourPaletteWindow + keyEditorPanel = std::make_unique(stateIn); mappingSettingsComponent = std::make_unique(stateIn); // curvesArea.reset(new CurvesArea(stateIn)); @@ -69,7 +68,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j sectionTabs = std::make_unique(juce::TabbedButtonBar::TabsAtTop); sectionTabs->setColour(juce::TabbedComponent::ColourIds::outlineColourId, juce::Colours::transparentBlack); addAndMakeVisible(*sectionTabs); - sectionTabs->addTab("Key Editor", juce::Colour(), mappingSettingsComponent.get(), false); + sectionTabs->addTab("Key Editor", juce::Colour(), keyEditorPanel.get(), false); sectionTabs->addTab("AutoGenerator", juce::Colour(), mappingSettingsComponent.get(), false); sectionTabs->addTab("Advanced", juce::Colour(), mappingSettingsComponent.get(), false); sectionTabs->addTab("Mapping Settings", juce::Colour(), mappingSettingsComponent.get(), false); @@ -126,7 +125,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j btnImportFile->setEnabled(false); // DEBUG - sectionTabs->setCurrentTabIndex(3); + // sectionTabs->setCurrentTabIndex(3); // Initialize mapping structure //deleteAll(); @@ -149,6 +148,7 @@ MainContentComponent::~MainContentComponent() globalSettingsArea = nullptr; mappingSettingsComponent = nullptr; + keyEditorPanel = nullptr; allKeysOverview = nullptr; midiEditArea = nullptr; @@ -490,11 +490,6 @@ void MainContentComponent::resized() controlsLabelYPos = controlsArea.getY() - proportionOfHeight(controlsLabelHeight); - // All keys overview/virtual keyboard playing - // int newKeysOverviewAreaHeight = jmax(controlsLabelYPos - midiAreaHeight, MINIMALTERPSTRAKEYSETAREAHEIGHT); - // int keyboardMarginTop = juce::roundToInt(newKeysOverviewAreaHeight * lumatoneGraphicMarginTop); - // int keyboardHeight = juce::roundToInt(newKeysOverviewAreaHeight * lumatoneGraphicH); - allKeysOverview->setBounds(contentMargin, midiAreaHeight, contentWidth, controlsLabelYPos - midiAreaHeight); int btnHeight = roundToInt(getHeight() * fileButtonH); @@ -507,27 +502,16 @@ void MainContentComponent::resized() btnLoadFile->setBounds(halfWidthX - btnMargin - saveLoadWidth, btnY, saveLoadWidth, btnHeight); btnSaveFile->setBounds(halfWidthX + btnMargin, btnY, saveLoadWidth, btnHeight); - //octaveLineY = lumatoneBounds.getBottom() + roundToInt(getHeight() * octaveLineYRatio); - int importY = allKeysOverview->getY() - roundToInt(getHeight() * importYFromImageTop); int importWidth = roundToInt(getWidth() * importW); 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()); - lblEditTitle->setTopLeftPosition(contentMargin, controlsLabelYPos); resizeLabelWithHeight(lblEditTitle.get(), (controlsArea.getY() - controlsLabelYPos) * 0.8f); - sectionTabs->setBounds(contentMargin, controlsLabelYPos, contentWidth, footerY - controlsArea.getY()); - // sectionTabs->setOff(lblEditTitle->getWidth()); + sectionTabs->setBounds(contentMargin, controlsLabelYPos, contentWidth, footerY - controlsLabelYPos); resizeEditSectionTabs(); - // generalOptionsArea->setBounds(getLocalBounds().toFloat().getProportion(generalSettingsBounds).toNearestInt()); - // pedalSensitivityDlg->setBounds(getLocalBounds().toFloat().getProportion(pedalSettingsBounds).toNearestInt()); - // curvesArea->setBounds(getLocalBounds().toFloat().getProportion(curvesAreaBounds).toNearestInt()); - globalSettingsArea->setBounds(getLocalBounds().withTop(roundToInt(getHeight() * footerAreaY))); resizeLabelWithHeight(lblAppName.get(), roundToInt(footerHeight * lumatoneVersionHeight), 1.0f, " "); diff --git a/Source/MainComponent.h b/Source/MainComponent.h index de644a4..f15b495 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -19,6 +19,7 @@ class LumatoneKeyboardComponent; class MidiEditArea; +class KeyEditorPanel; class MappingSettingsPanel; class GlobalSettingsArea; @@ -94,6 +95,7 @@ class MainContentComponent : public juce::Component // Edit fields for setting key and button parameters, and edits for single keys // std::unique_ptr noteEditArea; + std::unique_ptr keyEditorPanel; std::unique_ptr mappingSettingsComponent; // std::unique_ptr curvesArea; diff --git a/Source/mapping_editors/KeyEditorControls.cpp b/Source/mapping_editors/KeyEditorControls.cpp new file mode 100644 index 0000000..8d4716e --- /dev/null +++ b/Source/mapping_editors/KeyEditorControls.cpp @@ -0,0 +1,116 @@ +/* + ============================================================================== + + KeyEditorControls.h + Created: 3 June 2024 + Author: Vincenzo + + ============================================================================== +*/ + +#include "KeyEditorControls.h" +#include "../LumatoneEditorLookAndFeel.h" + +#include "../colour_view_component.h" +#include "../lumatone_editor_library/palettes/colour_edit_textbox.h" + +KeyEditorControls::KeyEditorControls(const LumatoneEditorState& stateIn) + : LumatoneEditorState(stateIn) + , juce::Component("KeyEditorControls") +{ + lblKeySettings = std::make_unique("lblKeySettings", "Key Settings"); + lblKeySettings->setColour(juce::Label::ColourIds::textColourId, getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::LabelBlue)); + lblKeySettings->setFont(getAppFonts().getFont(LumatoneEditorFont::FranklinGothic)); + addAndMakeVisible(lblKeySettings.get()); + + colourControlTabs = std::make_unique(juce::TabbedButtonBar::Orientation::TabsAtTop); + addAndMakeVisible(colourControlTabs.get()); + + colourTextEditor = std::make_unique("colourTextEditor", "000000"); + addAndMakeVisible(colourTextEditor.get()); + + colourSubwindow = std::make_unique(); + addAndMakeVisible(colourSubwindow.get()); + + colourPickerToggle = std::make_unique("Pick"); + addAndMakeVisible(colourPickerToggle.get()); + + keyTypeCombo = std::make_unique(); + keyTypeCombo->setEditableText (false); + keyTypeCombo->setJustificationType (juce::Justification::centredLeft); + keyTypeCombo->setTextWhenNothingSelected (juce::String()); + keyTypeCombo->setTextWhenNoChoicesAvailable (juce::translate("(no choices)")); + keyTypeCombo->addItem (juce::translate("Note on/Note off"), 1); + keyTypeCombo->addItem (juce::translate("Continuous controller"), 2); + keyTypeCombo->addItem (juce::translate("Lumatouch"), 3); + keyTypeCombo->addItem (juce::translate("Disabled"), 4); + addAndMakeVisible(keyTypeCombo.get()); + + noteInput = std::make_unique(); + noteInput->setTooltip (juce::translate("MIDI note or MIDI controller no. (for key type \'continuous controller\')")); + noteInput->setRange (0, 127, 1); + noteInput->setSliderStyle (juce::Slider::IncDecButtons); + noteInput->setTextBoxStyle (juce::Slider::TextBoxLeft, false, 56, 20); + // noteInput->addListener (this); + addAndMakeVisible(noteInput.get()); + + channelInput = std::make_unique(); + channelInput->setRange (1, 16, 1); + channelInput->setSliderStyle (juce::Slider::IncDecButtons); + channelInput->setTextBoxStyle (juce::Slider::TextBoxLeft, false, 56, 20); + addAndMakeVisible(channelInput.get()); + +} + +KeyEditorControls::~KeyEditorControls() +{ + channelInput = nullptr; + noteInput = nullptr; + keyTypeCombo = nullptr; + colourPickerToggle = nullptr; + colourSubwindow = nullptr; + colourTextEditor = nullptr; + colourControlTabs = nullptr; + lblKeySettings = nullptr; +} + +void KeyEditorControls::paint(juce::Graphics& g) +{ + g.setColour(getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::ControlAreaBackground)); + g.fillPath(controlPath); + + g.setColour(getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::ControlAreaHeader)); + g.fillPath(headerPath); +} + +void KeyEditorControls::resized() +{ + float w = (float)getWidth(); + float h = (float)getHeight(); + + headerHeight = roundToInt(h * headerH); + headerPath = getConnectedRoundedRectPath(getLocalBounds().withBottom(headerHeight + 1).toFloat(), getRoundedRectCornerSize(), juce::Button::ConnectedEdgeFlags::ConnectedOnBottom); + controlPath = getConnectedRoundedRectPath(getLocalBounds().withTop(headerHeight).toFloat(), getRoundedRectCornerSize(), juce::Button::ConnectedEdgeFlags::ConnectedOnTop); + + contentMarginWidth = roundToInt(w * contentMarginW); + contentMarginHeight = roundToInt(h * controlMarginH); + + labelHeight = roundToInt(headerHeight * labelToHeaderH); + lblKeySettings->setTopLeftPosition(contentMarginWidth, 0); + resizeLabelWithHeight(lblKeySettings.get(), headerHeight, labelToHeaderH); + + keyControlColumnWidth = roundToInt(w * keyControlColumnW); + keyControlHeight = roundToInt(h * keyControlH); + keyControlMarginHeight = roundToInt(h * keyControlMarginH); + + colourTextEditor->setBounds(contentMarginWidth, headerHeight + contentMarginHeight, keyControlColumnWidth, keyControlHeight); + keyTypeCombo->setBounds(contentMarginWidth, colourTextEditor->getBottom() + keyControlMarginHeight, keyControlColumnWidth, keyControlHeight); + noteInput->setBounds(contentMarginWidth, keyTypeCombo->getBottom() + keyControlMarginHeight, keyControlColumnWidth, keyControlHeight); + channelInput->setBounds(contentMarginWidth, noteInput->getBottom() + keyControlMarginHeight, keyControlColumnWidth, keyControlHeight); + + colourColumnX = contentMarginWidth + keyControlColumnWidth + roundToInt(w * columnMarginW); + colourColumnWidth = w - colourColumnX - contentMarginWidth; + colourColumnHeight = roundToInt(h * colourColumnH); + + colourControlTabs->setBounds(colourColumnX, headerHeight + contentMarginHeight, colourColumnWidth, colourColumnHeight); +} diff --git a/Source/mapping_editors/KeyEditorControls.h b/Source/mapping_editors/KeyEditorControls.h new file mode 100644 index 0000000..fe97581 --- /dev/null +++ b/Source/mapping_editors/KeyEditorControls.h @@ -0,0 +1,79 @@ +/* + ============================================================================== + + KeyEditorControls.h + Created: 3 June 2024 + Author: Vincenzo + + ============================================================================== +*/ + +#ifndef LUMATONE_EDITOR_KEY_EDITOR_CONTROLS_H +#define LUMATONE_EDITOR_KEY_EDITOR_CONTROLS_H + +#include "../LumatoneEditorState.h" + +class ColourViewComponent; +class ColourTextEditor; + +class KeyEditorControls : public LumatoneEditorState + , public juce::Component +{ +public: + KeyEditorControls(const LumatoneEditorState& stateIn); + + virtual ~KeyEditorControls() override; + + + void paint(juce::Graphics&) override; + void resized() override; + + +private: + + std::unique_ptr lblKeySettings; + + std::unique_ptr colourControlTabs; + + std::unique_ptr colourTextEditor; + std::unique_ptr colourSubwindow; + std::unique_ptr colourPickerToggle; + + std::unique_ptr keyTypeCombo; + std::unique_ptr noteInput; + std::unique_ptr channelInput; + + + const float headerH = 0.19f; + int headerHeight; + juce::Path headerPath; + juce::Path controlPath; + + int contentMarginWidth; + const float contentMarginW = 0.0414f; + + int contentMarginHeight; + const float controlMarginH = 0.08f; + + int labelHeight; + const float labelToHeaderH = 0.5f; + + int keyControlColumnWidth; + const float keyControlColumnW = 0.3f; + + int keyControlHeight; + const float keyControlH = 0.128f; + + int keyControlMarginHeight; + const float keyControlMarginH = 0.059f; + + int colourColumnX; + int colourColumnWidth; + const float columnMarginW = 0.055f; + + int colourColumnHeight; + const float colourColumnH = 0.6f; + +}; + +#endif // LUMATONE_EDITOR_KEY_EDITOR_CONTROLS_H diff --git a/Source/mapping_editors/KeyEditorPanel.cpp b/Source/mapping_editors/KeyEditorPanel.cpp new file mode 100644 index 0000000..f8c0291 --- /dev/null +++ b/Source/mapping_editors/KeyEditorPanel.cpp @@ -0,0 +1,55 @@ +#include "KeyEditorPanel.h" +#include "../LumatoneEditorLookAndFeel.h" + +#include "./KeyEditorControls.h" +#include "./MultiSelectControls.h" + +KeyEditorPanel::KeyEditorPanel(const LumatoneEditorState &stateIn) + : juce::Component("KeyEditorPanel") + , LumatoneEditorState(stateIn) +{ + keyEditorControls = std::make_unique(stateIn); + addAndMakeVisible(keyEditorControls.get()); + + multiSelectControls = std::make_unique(stateIn); + addAndMakeVisible(multiSelectControls.get()); +} + +KeyEditorPanel::~KeyEditorPanel() +{ + multiSelectControls = nullptr; + keyEditorControls = nullptr; +} + +void KeyEditorPanel::paint(juce::Graphics &g) +{ + g.setColour(getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::MediumBackground)); + g.fillRoundedRectangle(keySettingsAndMultiSelectArea, getRoundedRectCornerSize()); + g.fillRoundedRectangle(batchToolsArea, getRoundedRectCornerSize()); +} + +void KeyEditorPanel::resized() +{ + float w = (float)getWidth(); + float h = (float)getHeight(); + + areaHeight = roundToInt(h * areaHeightRatio); + areaMargin = roundToInt((h - areaHeight) * 0.5f); + + keySettingsAndMultiSelectArea = juce::Rectangle(0, areaMargin, roundToInt(w * keySettingsAndSelectAreaW), areaHeight); + + int batchToolsAreaWidth = roundToInt(w * batchToolsAreaW); + batchToolsArea = juce::Rectangle(w - batchToolsAreaWidth, areaMargin, batchToolsAreaWidth, areaHeight); + + contentHeight = roundToInt(h * contentHeightRatio); + contentMargin = roundToInt(h - (float)contentHeight) * 0.5; + + keyEditorControls->setBounds(keySettingsAndMultiSelectArea.reduced(contentMargin) + .withWidth(roundToInt(keySettingsAndMultiSelectArea.getWidth() * keySettingsComponentAreaW)) + .toNearestInt()); + + multiSelectWidth = roundToInt(keySettingsAndMultiSelectArea.getWidth() * multiSelectComponentAreaW); + multiSelectControls->setBounds(keySettingsAndMultiSelectArea.reduced(contentMargin) + .withLeft(keySettingsAndMultiSelectArea.getRight() - multiSelectWidth - contentMargin) + .toNearestInt()); +} diff --git a/Source/mapping_editors/KeyEditorPanel.h b/Source/mapping_editors/KeyEditorPanel.h new file mode 100644 index 0000000..a617883 --- /dev/null +++ b/Source/mapping_editors/KeyEditorPanel.h @@ -0,0 +1,64 @@ +/* + ============================================================================== + + KeyEditorPanel.h + Created: 3 June 2024 + Author: Vincenzo + + ============================================================================== +*/ + +#ifndef LUMATONE_EDITOR_KEY_EDITOR_PANEL_H +#define LUMATONE_EDITOR_KEY_EDITOR_PANEL_H + +// #include "./lumatone_editor_library/listeners/editor_listener.h" +#include "../LumatoneEditorState.h" + +class KeyEditorControls; +class MultiSelectControls; + +class KeyEditorPanel : public juce::Component + , public LumatoneEditorState + // , public LumatoneEditor::EditorListener +{ +public: + KeyEditorPanel(const LumatoneEditorState& stateIn); + ~KeyEditorPanel() override; + + void paint(juce::Graphics& g) override; + void resized() override; + +private: + + std::unique_ptr keyEditorControls; + std::unique_ptr multiSelectControls; + + juce::Rectangle keySettingsAndMultiSelectArea; + juce::Rectangle keySettingsArea; + juce::Rectangle multiSelectArea; + juce::Rectangle batchToolsArea; + + const float areaHeightRatio = 0.865f; + const float keySettingsAndSelectAreaW = 0.71f; + const float batchToolsAreaW = 0.27f; + + const float keySettingsComponentW = 0.471f; + const float batchToolsComponentW = 0.232f; + + const float keySettingsComponentAreaW = 0.66f; + const float multiSelectComponentAreaW = 0.253f; + + int areaHeight; + int areaMargin; + int contentMargin; + int contentHeight; + int multiSelectWidth; + + const float contentHeightRatio = 0.81f; + + const float controlsWidthRatio = 0.466f; + const float curvesAreaWidthRatio = 0.512f; + +}; + +#endif //LUMATONE_EDITOR_KEY_EDITOR_PANEL_H diff --git a/Source/mapping_editors/MappingSettingsPanel.cpp b/Source/mapping_editors/MappingSettingsPanel.cpp index 5c3f36a..0042b31 100644 --- a/Source/mapping_editors/MappingSettingsPanel.cpp +++ b/Source/mapping_editors/MappingSettingsPanel.cpp @@ -37,7 +37,7 @@ void MappingSettingsPanel::paint(juce::Graphics& g) void MappingSettingsPanel::resized() { contentMarginY = proportionOfHeight(contentMarginHeightRatio); - contentHeight = juce::roundToInt(getHeight() - contentMarginY); + contentHeight = juce::roundToInt(getHeight() - contentMarginY * 2); settingsControls->setBounds(0, contentMarginY, proportionOfWidth(controlsWidthRatio), contentHeight); diff --git a/Source/mapping_editors/MultiSelectControls.cpp b/Source/mapping_editors/MultiSelectControls.cpp new file mode 100644 index 0000000..d9846ab --- /dev/null +++ b/Source/mapping_editors/MultiSelectControls.cpp @@ -0,0 +1,42 @@ +/* + ============================================================================== + + MultiSelectControls.h + Created: 3 June 2024 + Author: Vincenzo + + ============================================================================== +*/ + +#include "MultiSelectControls.h" +#include "../LumatoneEditorLookAndFeel.h" + +MultiSelectControls::MultiSelectControls(const LumatoneEditorState& stateIn) + : LumatoneEditorState(stateIn) + , juce::Component("MultiSelectControls") +{ + +} + +MultiSelectControls::~MultiSelectControls() +{ + +} + +void MultiSelectControls::paint(juce::Graphics& g) +{ + g.setColour(getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::ControlAreaBackground)); + g.fillPath(controlPath); + + g.setColour(getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::ControlAreaHeader)); + g.fillPath(headerPath); +} + +void MultiSelectControls::resized() +{ + float h = (float)getHeight(); + + headerHeight = roundToInt(h * headerH); + headerPath = getConnectedRoundedRectPath(getLocalBounds().withBottom(headerHeight + 1).toFloat(), getRoundedRectCornerSize(), juce::Button::ConnectedEdgeFlags::ConnectedOnBottom); + controlPath = getConnectedRoundedRectPath(getLocalBounds().withTop(headerHeight).toFloat(), getRoundedRectCornerSize(), juce::Button::ConnectedEdgeFlags::ConnectedOnTop); +} diff --git a/Source/mapping_editors/MultiSelectControls.h b/Source/mapping_editors/MultiSelectControls.h new file mode 100644 index 0000000..42032a8 --- /dev/null +++ b/Source/mapping_editors/MultiSelectControls.h @@ -0,0 +1,35 @@ +/* + ============================================================================== + + MultiSelectControls.h + Created: 3 June 2024 + Author: Vincenzo + + ============================================================================== +*/ + +#ifndef LUMATONE_EDITOR_MULTI_SELECT_CONTROLS_H +#define LUMATONE_EDITOR_MULTI_SELECT_CONTROLS_H + +#include "../LumatoneEditorState.h" + +class MultiSelectControls : public LumatoneEditorState + , public juce::Component +{ +public: + MultiSelectControls(const LumatoneEditorState& stateIn); + + virtual ~MultiSelectControls() override; + + void paint(juce::Graphics&) override; + void resized() override; + +private: + const float headerH = 0.19f; + int headerHeight; + juce::Path headerPath; + juce::Path controlPath; + +}; + +#endif // LUMATONE_EDITOR_MULTI_SELECT_CONTROLS_H