Skip to content

Commit

Permalink
sketch out key settings panel and fix control area height
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jun 4, 2024
1 parent f38586f commit 8333fcf
Show file tree
Hide file tree
Showing 9 changed files with 401 additions and 24 deletions.
30 changes: 7 additions & 23 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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<KeyEditorPanel>(stateIn);
mappingSettingsComponent = std::make_unique<MappingSettingsPanel>(stateIn);

// curvesArea.reset(new CurvesArea(stateIn));
Expand All @@ -69,7 +68,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j
sectionTabs = std::make_unique<juce::TabbedComponent>(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);
Expand Down Expand Up @@ -126,7 +125,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j
btnImportFile->setEnabled(false);

// DEBUG
sectionTabs->setCurrentTabIndex(3);
// sectionTabs->setCurrentTabIndex(3);

// Initialize mapping structure
//deleteAll();
Expand All @@ -149,6 +148,7 @@ MainContentComponent::~MainContentComponent()
globalSettingsArea = nullptr;

mappingSettingsComponent = nullptr;
keyEditorPanel = nullptr;

allKeysOverview = nullptr;
midiEditArea = nullptr;
Expand Down Expand Up @@ -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);
Expand All @@ -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, " ");
Expand Down
2 changes: 2 additions & 0 deletions Source/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
class LumatoneKeyboardComponent;

class MidiEditArea;
class KeyEditorPanel;
class MappingSettingsPanel;
class GlobalSettingsArea;

Expand Down Expand Up @@ -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> noteEditArea;
std::unique_ptr<KeyEditorPanel> keyEditorPanel;
std::unique_ptr<MappingSettingsPanel> mappingSettingsComponent;

// std::unique_ptr<CurvesArea> curvesArea;
Expand Down
116 changes: 116 additions & 0 deletions Source/mapping_editors/KeyEditorControls.cpp
Original file line number Diff line number Diff line change
@@ -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<juce::Label>("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::TabbedComponent>(juce::TabbedButtonBar::Orientation::TabsAtTop);
addAndMakeVisible(colourControlTabs.get());

colourTextEditor = std::make_unique<ColourTextEditor>("colourTextEditor", "000000");
addAndMakeVisible(colourTextEditor.get());

colourSubwindow = std::make_unique<ColourViewComponent>();
addAndMakeVisible(colourSubwindow.get());

colourPickerToggle = std::make_unique<juce::TextButton>("Pick");
addAndMakeVisible(colourPickerToggle.get());

keyTypeCombo = std::make_unique<juce::ComboBox>();
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<juce::Slider>();
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<juce::Slider>();
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);
}
79 changes: 79 additions & 0 deletions Source/mapping_editors/KeyEditorControls.h
Original file line number Diff line number Diff line change
@@ -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<juce::Label> lblKeySettings;

std::unique_ptr<juce::TabbedComponent> colourControlTabs;

std::unique_ptr<ColourTextEditor> colourTextEditor;
std::unique_ptr<ColourViewComponent> colourSubwindow;
std::unique_ptr<juce::TextButton> colourPickerToggle;

std::unique_ptr<juce::ComboBox> keyTypeCombo;
std::unique_ptr<juce::Slider> noteInput;
std::unique_ptr<juce::Slider> 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
55 changes: 55 additions & 0 deletions Source/mapping_editors/KeyEditorPanel.cpp
Original file line number Diff line number Diff line change
@@ -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<KeyEditorControls>(stateIn);
addAndMakeVisible(keyEditorControls.get());

multiSelectControls = std::make_unique<MultiSelectControls>(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<float>(0, areaMargin, roundToInt(w * keySettingsAndSelectAreaW), areaHeight);

int batchToolsAreaWidth = roundToInt(w * batchToolsAreaW);
batchToolsArea = juce::Rectangle<float>(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());
}
Loading

0 comments on commit 8333fcf

Please sign in to comment.