Skip to content

Commit

Permalink
implemenent set key settings action
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jun 13, 2024
1 parent 216e4b4 commit e5b3a73
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 42 deletions.
50 changes: 36 additions & 14 deletions Source/actions/EditorControlActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,30 @@ SetKeySettingsAction::SetKeySettingsAction(const LumatoneEditorState & stateIn,
: LumatoneEditorState("SetKeySettingsAction", stateIn)
, LumatoneEditorState::Controller(static_cast<LumatoneEditorState&>(*this))
, LumatoneAction(this, "SetKeySettingsAction")
, newEditData("SetKeySettingsActionData")
// , newEditData("SetKeySettingsActionData")
{
previousData = stateIn.getEditSelectionData();

newEditData.setKeyColour(setKeyColourIn, colourIn);
newEditData.setKeyType(setKeyTypeIn, typeIn);
newEditData.setKeyNote(setKeyNoteIn, noteIn);
newEditData.setKeyChannel(setKeyChannelIn, channelIn);
newEditData.setCCFader(setCCFaderDefaultIn, ccFaderDefaultIn);
newEditData.setColour = setKeyColourIn;
newEditData.colour = colourIn;

newEditData.setType = setKeyTypeIn;
newEditData.type = typeIn;

newEditData.setNote = setKeyNoteIn;
newEditData.note = noteIn;

newEditData.setChannel = setKeyChannelIn;
newEditData.channel = channelIn;

newEditData.setCCFaderDefault = setCCFaderDefaultIn;
newEditData.ccFaderDefault = ccFaderDefaultIn;
}

bool SetKeySettingsAction::perform()
{
LumatoneEditSelectionState::Data data = newEditData.getData();
setAssignKeyColour(data.setColour, data.colour);
setAssignKeyType(data.setType, data.type);
setAssignKeyNote(data.setNote, data.note);
setAssignKeyChannel(data.setChannel, data.channel);
setAssignCCFader(data.setCCFaderDefault, data.ccFaderDefault);
return false;
addToEditAassignment();
return true;
}

bool SetKeySettingsAction::undo()
Expand All @@ -44,7 +48,25 @@ bool SetKeySettingsAction::undo()
setAssignKeyNote(previousData.setNote, previousData.note);
setAssignKeyChannel(previousData.setChannel, previousData.channel);
setAssignCCFader(previousData.setCCFaderDefault, previousData.ccFaderDefault);
return false;
return true;
}

// void SetKeySettingsAction::assignToSelectedKeys()
// {
// }

void SetKeySettingsAction::addToEditAassignment()
{
if (newEditData.setColour)
setAssignKeyColour(newEditData.setColour, newEditData.colour);
if (newEditData.setType)
setAssignKeyType(newEditData.setType, newEditData.type);
if (newEditData.setNote)
setAssignKeyNote(newEditData.setNote, newEditData.note);
if (newEditData.setChannel)
setAssignKeyChannel(newEditData.setChannel, newEditData.channel);
if (newEditData.setCCFaderDefault)
setAssignCCFader(newEditData.setCCFaderDefault, newEditData.ccFaderDefault);
}

SetKeySettingsAction *SetKeySettingsAction::NewSetAssignColourAction(LumatoneEditorState &stateIn, juce::Colour colourIn)
Expand Down
18 changes: 5 additions & 13 deletions Source/actions/EditorControlActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class SetKeySettingsAction : public LumatoneEditorState

int getSizeInUnits() override { return sizeof(SetKeySettingsAction); }

// void assignToSelectedKeys();
void addToEditAassignment();

public:

static SetKeySettingsAction* NewSetAssignColourAction(LumatoneEditorState& stateIn, juce::Colour colourIn);
Expand All @@ -50,19 +53,8 @@ class SetKeySettingsAction : public LumatoneEditorState
private:

LumatoneEditSelectionState::Data previousData;
LumatoneEditSelectionState newEditData;

// bool setKeyColour = false;
// bool setKeyType = false;
// bool setKeyNote = false;
// bool setKeyChannel = false;
// bool setCCFaderDefault = false;

// juce::Colour colour;
// LumatoneKeyType type;
// int note;
// int channel;
// bool ccFaderDefault;
LumatoneEditSelectionState::Data newEditData;

};


Expand Down
58 changes: 45 additions & 13 deletions Source/mapping_editors/KeyEditorControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
// #include "../lumatone_editor_library/palettes/palette_selection_panel.h"
#include "../lumatone_editor_library/palettes/colour_picker_panel.h"

#include "../actions/EditorControlActions.h"

KeyEditorControls::KeyEditorControls(const LumatoneEditorState& stateIn)
: LumatoneEditorState(stateIn)
, juce::Component("KeyEditorControls")
: juce::Component("KeyEditorControls")
, LumatoneEditorState("KeyEditorControls", stateIn)
, LumatoneEditorState::Controller(static_cast<LumatoneEditorState&>(*this))
{
lblKeySettings = std::make_unique<juce::Label>("lblKeySettings", "Key Settings");
lblKeySettings->setColour(juce::Label::ColourIds::textColourId, getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::LabelBlue));
Expand All @@ -34,9 +37,6 @@ KeyEditorControls::KeyEditorControls(const LumatoneEditorState& stateIn)
colourSubwindow->setColourButtonMode(ColourViewComponent::ColourButtonMode::Dropper);
addAndMakeVisible(colourSubwindow.get());

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

keyTypeCombo = std::make_unique<juce::ComboBox>("keyTypeCombo");
keyTypeCombo->setEditableText (false);
keyTypeCombo->setJustificationType (juce::Justification::centredLeft);
Expand All @@ -46,20 +46,32 @@ KeyEditorControls::KeyEditorControls(const LumatoneEditorState& stateIn)
keyTypeCombo->addItem (juce::translate("Continuous controller"), 2);
keyTypeCombo->addItem (juce::translate("Lumatouch"), 3);
keyTypeCombo->addItem (juce::translate("Disabled"), 4);
keyTypeCombo->onChange = [&]()
{
performAction(SetKeySettingsAction::NewSetAssignKeyTypeAction(*this, LumatoneKeyType(keyTypeCombo->getSelectedId() - 1)));
};
addAndMakeVisible(keyTypeCombo.get());

noteInput = std::make_unique<juce::Slider>("noteInput");
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->onValueChange = [&]()
{
performAction(SetKeySettingsAction::NewSetAssignKeyNoteAction(*this, (int)noteInput->getValue()));
};
// noteInput->addListener (this);
addAndMakeVisible(noteInput.get());

channelInput = std::make_unique<juce::Slider>("channelInput");
channelInput->setRange (1, 16, 1);
channelInput->setSliderStyle (juce::Slider::IncDecButtons);
channelInput->setTextBoxStyle (juce::Slider::TextBoxLeft, false, 56, 20);
channelInput->onValueChange = [&]()
{
performAction(SetKeySettingsAction::NewSetAssignKeyChannelAction(*this, (int)channelInput->getValue()));
};
addAndMakeVisible(channelInput.get());

lblColour = std::make_unique<juce::Label>("lblColour", "Key Colour:");
Expand Down Expand Up @@ -88,14 +100,6 @@ KeyEditorControls::KeyEditorControls(const LumatoneEditorState& stateIn)

colourPalettePanel = std::make_unique<ColourPaletteWindow>(stateIn);
addAndMakeVisible(colourPalettePanel.get());
// colourPickerPanel = std::make_unique<CustomPickerPanel>();

// juce::Colour colourControlBackground = getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::ColourPaletteBackground);
// colourControlTabs = std::make_unique<juce::TabbedComponent>(juce::TabbedButtonBar::Orientation::TabsAtTop);
// colourControlTabs->addTab("Colour Palettes", colourControlBackground, colourPalettePanel.get(), false);
// colourControlTabs->addTab("Custom Picker", colourControlBackground, colourPickerPanel.get(), false);
// addAndMakeVisible(colourControlTabs.get());

}

KeyEditorControls::~KeyEditorControls()
Expand Down Expand Up @@ -174,3 +178,31 @@ void KeyEditorControls::resized()

colourPalettePanel->setBounds(colourColumnX, 0, colourColumnWidth, h - contentMarginHeight);
}

void KeyEditorControls::handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier &property)
{
LumatoneEditorState::handleStatePropertyChange(stateIn, property);

juce::var value = stateIn.getProperty(property);

if (property == LumatoneEditSelectionProperty::AssignKeyColour)
{

}
else if (property == LumatoneEditSelectionProperty::AssignKeyType)
{
keyTypeCombo->setSelectedId(((int)value) + 1, juce::NotificationType::dontSendNotification);
}
else if (property == LumatoneEditSelectionProperty::AssignKeyNote)
{
noteInput->setValue((int)value, juce::NotificationType::dontSendNotification);
}
else if (property == LumatoneEditSelectionProperty::AssignKeyChannel)
{
channelInput->setValue((int)value, juce::NotificationType::dontSendNotification);
}
else if (property == LumatoneEditSelectionProperty::AssignKeyCCFader)
{

}
}
9 changes: 7 additions & 2 deletions Source/mapping_editors/KeyEditorControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class ColourPaletteWindow;
class CustomPickerPanel;
class ColourPalettesPanel;

class KeyEditorControls : public LumatoneEditorState
, public juce::Component
class KeyEditorControls : public juce::Component
, public LumatoneEditorState
, private LumatoneEditorState::Controller
{
public:
KeyEditorControls(const LumatoneEditorState& stateIn);
Expand All @@ -32,6 +33,10 @@ class KeyEditorControls : public LumatoneEditorState
void resized() override;


private:

void handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier& property) override;

private:

std::unique_ptr<juce::Label> lblKeySettings;
Expand Down

0 comments on commit e5b3a73

Please sign in to comment.