forked from hsstraub/TerpstraSysEx.2014
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sketch out key settings panel and fix control area height
- Loading branch information
1 parent
f38586f
commit 8333fcf
Showing
9 changed files
with
401 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |
Oops, something went wrong.