Skip to content

Commit

Permalink
refactor some editor listener calls and implement in controller options
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jan 5, 2024
1 parent b8500c4 commit 6f3d01a
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 41 deletions.
22 changes: 17 additions & 5 deletions Source/GeneralOptionsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ GeneralOptionsDlg::GeneralOptionsDlg (const LumatoneEditorState& stateIn)
//[UserPreSize]
labelGeneralSettingslTitle->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold));

// getLumatoneController()->addFirmwareListener(this);
addEditorListener(this);
//[/UserPreSize]

setSize (188, 96);
Expand All @@ -81,7 +81,7 @@ GeneralOptionsDlg::GeneralOptionsDlg (const LumatoneEditorState& stateIn)
GeneralOptionsDlg::~GeneralOptionsDlg()
{
//[Destructor_pre]. You can add your own custom destruction code here..
// getLumatoneController()->removeFirmwareListener(this);
removeEditorListener(this);
//[/Destructor_pre]

labelGeneralSettingslTitle = nullptr;
Expand Down Expand Up @@ -173,10 +173,22 @@ void GeneralOptionsDlg::loadFromMapping()
buttonLightOnKeyStrokes->setToggleState(getLightOnKeyStrokes(), juce::NotificationType::dontSendNotification);
}

void GeneralOptionsDlg::presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags)
//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(presetFlags.polyphonicAftertouch, dontSendNotification);
buttonLightOnKeyStrokes->setToggleState(presetFlags.lightsOnKeystroke, dontSendNotification);
buttonAfterTouchActive->setToggleState(getAftertouchOn(), dontSendNotification);

}

//[/MiscUserCode]
Expand Down
10 changes: 7 additions & 3 deletions Source/GeneralOptionsDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//[Headers] -- You can add your own extra header files here --
#include <JuceHeader.h>

#include "./lumatone_editor_library/listeners/firmware_listener.h"
#include "./lumatone_editor_library/listeners/editor_listener.h"

#include "LumatoneEditorState.h"
//[/Headers]
Expand All @@ -39,7 +39,7 @@
*/
class GeneralOptionsDlg : public juce::Component,
public LumatoneEditorState,
public LumatoneEditor::FirmwareListener,
public LumatoneEditor::EditorListener,
public juce::Button::Listener
{
public:
Expand All @@ -56,7 +56,11 @@ class GeneralOptionsDlg : public juce::Component,
void lookAndFeelChanged() override;

// LumatoneEditor::FirmwareListener Implementation
void presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) override;
//void presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) override;

// LumatoneEditor::EditorListener Implementation
void lightOnKeyStrokesChanged(bool lightOn) override;
void aftertouchToggled(bool enabled) override;

//[/UserMethods]

Expand Down
57 changes: 44 additions & 13 deletions Source/PedalSensitivityDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ PedalSensitivityDlg::PedalSensitivityDlg (const LumatoneEditorState& stateIn)
labelExprContrSensitivity->setFont(getAppFonts().getFont(LumatoneEditorFont::GothamNarrowMedium));
labelExprContrSensitivity->setJustificationType(Justification::centred);

// getLumatoneController()->addFirmwareListener(this);
addEditorListener(this);
//[/UserPreSize]

setSize (134, 96);
Expand All @@ -115,6 +115,7 @@ PedalSensitivityDlg::PedalSensitivityDlg (const LumatoneEditorState& stateIn)
PedalSensitivityDlg::~PedalSensitivityDlg()
{
//[Destructor_pre]. You can add your own custom destruction code here..
removeEditorListener(this);
//[/Destructor_pre]

labelExprContrSensitivity = nullptr;
Expand Down Expand Up @@ -263,9 +264,49 @@ void PedalSensitivityDlg::loadFromMapping()
sldExprCtrlSensitivity->setValue(getExpressionSensitivity(), juce::NotificationType::dontSendNotification);
}

void PedalSensitivityDlg::firmwareRevisionReceived(LumatoneFirmware::Version version)
//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)
{
if (getFirmwareSupport().versionAcknowledgesCommand(version, INVERT_SUSTAIN_PEDAL))
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("");
Expand All @@ -277,16 +318,6 @@ void PedalSensitivityDlg::firmwareRevisionReceived(LumatoneFirmware::Version ver
}
}

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);
}

//[/MiscUserCode]

Expand Down
29 changes: 18 additions & 11 deletions Source/PedalSensitivityDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "LumatoneEditorState.h"

#include "./lumatone_editor_library/listeners/firmware_listener.h"
#include "./lumatone_editor_library/listeners/editor_listener.h"
//[/Headers]


Expand All @@ -37,11 +37,12 @@
Describe your class and how it works here!
//[/Comments]
*/
class PedalSensitivityDlg : public juce::Component,
public LumatoneEditorState,
public LumatoneEditor::FirmwareListener,
public juce::Button::Listener,
public juce::Slider::Listener
class PedalSensitivityDlg : public juce::Component
, public LumatoneEditorState
//, private LumatoneEditor::FirmwareListener
, private LumatoneEditor::EditorListener
, private juce::Button::Listener
, private juce::Slider::Listener
{
public:
//==============================================================================
Expand All @@ -56,9 +57,17 @@ class PedalSensitivityDlg : public juce::Component,
void lookAndFeelChanged() override;

// LumatoneEditor::FirmwareListener implementation
void firmwareRevisionReceived(LumatoneFirmware::Version version) override;
void presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) override;
void expressionPedalSensitivityReceived(int sensitivity) override;
//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]

Expand All @@ -67,8 +76,6 @@ class PedalSensitivityDlg : public juce::Component,
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;
Expand Down
11 changes: 10 additions & 1 deletion Source/lumatone_editor_library/data/application_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ void LumatoneApplicationState::setCompleteConfig(const LumatoneLayout &layoutIn)
}

editorListeners->call(&LumatoneEditor::EditorListener::completeMappingLoaded, *mappingData);
editorListeners->call(&LumatoneEditor::EditorListener::expressionPedalSensitivityChanged, getExpressionSensitivity());
editorListeners->call(&LumatoneEditor::EditorListener::invertFootControllerChanged, getInvertExpression());
editorListeners->call(&LumatoneEditor::EditorListener::lightOnKeyStrokesChanged, getLightOnKeyStrokes());
editorListeners->call(&LumatoneEditor::EditorListener::aftertouchToggled, getAftertouchOn());

editorListeners->call(&LumatoneEditor::EditorListener::configTableChanged, LumatoneConfigTable::TableType::velocityInterval);
editorListeners->call(&LumatoneEditor::EditorListener::configTableChanged, LumatoneConfigTable::TableType::fader);
editorListeners->call(&LumatoneEditor::EditorListener::configTableChanged, LumatoneConfigTable::TableType::afterTouch);
editorListeners->call(&LumatoneEditor::EditorListener::configTableChanged, LumatoneConfigTable::TableType::lumaTouch);
}

void LumatoneApplicationState::setLayout(const LumatoneLayout &layoutIn)
Expand Down Expand Up @@ -335,7 +344,7 @@ void LumatoneApplicationState::setConfigTable(LumatoneConfigTable::TableType typ
controller->sendTableConfig(type, table.velocityValues);
}

editorListeners->call(&LumatoneEditor::EditorListener::configTableChanged, type, *mappingData->getConfigTable(type));
editorListeners->call(&LumatoneEditor::EditorListener::configTableChanged, type);
}
//
//void LumatoneApplicationState::setVelocityIntervalTable(const LumatoneConfigTable& tableIn)
Expand Down
16 changes: 8 additions & 8 deletions Source/lumatone_editor_library/listeners/editor_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@ class EditorListener

virtual void contextChanged(LumatoneContext* context) {}

virtual void configTableChanged(LumatoneConfigTable::TableType type, const LumatoneConfigTable& table) {}
virtual void configTableChanged(LumatoneConfigTable::TableType type) {}


// Firmware Actions
virtual void keyConfigChanged(int boardIndex, int keyIndex, LumatoneKey keyData) {}
virtual void keyColourChanged(int boardIndex, int keyIndex, juce::Colour keyColour) {}

virtual void expressionPedalSensitivityChanged(unsigned char value) {}
virtual void invertFootControllerChanged(bool inverted) {}

virtual void macroButtonActiveColourChagned(juce::Colour colour) {}
virtual void macroButtonInactiveColourChanged(juce::Colour colour) {}

virtual void lightOnKeyStrokesChanged(bool lightOn) {}


virtual void velocityConfigSaved() {}
virtual void velocityConfigReset() {}
virtual void velocityConfigChanged() {}

virtual void aftertouchToggled(bool enabled) {}
virtual void calibrateAftertouchToggled(bool active) {}

virtual void aftertouchConfigReset() {}
virtual void aftertouchConfigChanged() {}

virtual void serialIdentityRequested() {}
virtual void calibrateKeysRequested() {}
virtual void calibratePitchModWheelToggled(bool active) {}

virtual void lumatouchConfigReset() {}
virtual void lumatouchConfigChanged() {}

virtual void firmwareVersionRequested() {}
virtual void firmwareVersionChanged() {}
virtual void pingSent(juce::uint8 pingId) {}

virtual void peripheralChannelsChanged(int pitchWheelChannel, int modWheelChannel, int expressionChannel, int sustainChannel) {}
Expand Down

0 comments on commit 6f3d01a

Please sign in to comment.