Skip to content

Commit

Permalink
refactor layoutChanged listener callback, remove library newFileLoade…
Browse files Browse the repository at this point in the history
…d callback
  • Loading branch information
vsicurella committed Jul 18, 2024
1 parent 9c31617 commit 40625b2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Source/LumatoneEditorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ bool LumatoneEditorState::Controller::resetToCurrentFile()
// Add file to recent files list
editorState.recentFiles->addFile(editorState.currentFile);

getEditorListeners()->call(&LumatoneEditor::EditorListener::newFileLoaded, editorState.getCurrentFile());
// getEditorListeners()->call(&LumatoneEditor::EditorListener::newFileLoaded, editorState.getCurrentFile());

return true;
}
Expand Down
17 changes: 12 additions & 5 deletions Source/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,23 @@ void MainWindow::updateTitle()
setName(windowTitle);
}

void MainWindow::newFileLoaded(juce::File file)
{
updateTitle();
}
// void MainWindow::layoutChanged(const LumatoneLayout &mappingData)
// {
// updateTitle();
// }

// void MainWindow::newFileLoaded(juce::File file)
// {
// updateTitle();
// }

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

if (property == LumatoneEditorProperty::HasChangesToSave)
if (property == LumatoneEditorProperty::HasChangesToSave
|| property == LumatoneEditorProperty::CurrentFile
)
{
updateTitle();
}
Expand Down
3 changes: 2 additions & 1 deletion Source/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class MainWindow : public juce::DocumentWindow
void updateTitle();

// LumatoneEditor::EditorListener implementation
void newFileLoaded(juce::File file) override;
// void newFileLoaded(juce::File file) override;
// void layoutChanged(const LumatoneLayout& mappingData) override;

private:

Expand Down
4 changes: 2 additions & 2 deletions Source/lumatone_editor_library/data/application_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void LumatoneApplicationState::setCompleteConfig(const LumatoneLayout &layoutIn)
controller->sendCurrentCompleteConfig();
}

editorListeners->call(&LumatoneEditor::EditorListener::completeMappingLoaded, *mappingData);
editorListeners->call(&LumatoneEditor::EditorListener::layoutChanged, *mappingData);
editorListeners->call(&LumatoneEditor::EditorListener::expressionPedalSensitivityChanged, getExpressionSensitivity());
editorListeners->call(&LumatoneEditor::EditorListener::invertFootControllerChanged, getInvertExpression());
editorListeners->call(&LumatoneEditor::EditorListener::lightOnKeyStrokesChanged, getLightOnKeyStrokes());
Expand All @@ -269,7 +269,7 @@ void LumatoneApplicationState::setLayout(const LumatoneLayout &layoutIn)
controller->sendCompleteMapping(layoutIn);
}

editorListeners->call(&LumatoneEditor::EditorListener::completeMappingLoaded, *mappingData);
editorListeners->call(&LumatoneEditor::EditorListener::layoutChanged, *mappingData);
}

void LumatoneApplicationState::setBoard(const LumatoneBoard &boardIn, int boardId)
Expand Down
6 changes: 3 additions & 3 deletions Source/lumatone_editor_library/listeners/editor_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class EditorListener
virtual ~EditorListener() {}

// App Actions
virtual void completeMappingLoaded(const LumatoneLayout& mappingData) {}
virtual void layoutChanged(const LumatoneLayout& mappingData) {}
virtual void boardChanged(const LumatoneBoard& boardData) {}
virtual void keyChanged(int boardIndex, int keyIndex, const LumatoneKey& lumatoneKey) {}

virtual void keySetChanged(juce::Array<MappedLumatoneKey> selection) {}

virtual void newFileLoaded(juce::File file) {}
// virtual void newFileLoaded(juce::File file) {}

//virtual void tableChanged(LumatoneConfigTable::TableType type, const juce::uint8* table, int tableSize) {}

Expand Down Expand Up @@ -91,7 +91,7 @@ class LayoutChangeListener : public EditorListener

protected:

virtual void completeMappingLoaded(const LumatoneLayout& mappingData)
virtual void layoutChanged(const LumatoneLayout& mappingData)
{
layoutWasUpdated();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/lumatone_editor_library/ui/keyboard_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LumatoneKeyboardComponent::LumatoneKeyboardComponent(const LumatoneApplicationSt
addKeyListener(this);
setWantsKeyboardFocus(true);

completeMappingLoaded(*getMappingData());
layoutChanged(*getMappingData());
updateSelectedKeys(*getSelectedKeys());

addEditorListener(this);
Expand Down Expand Up @@ -191,7 +191,7 @@ void LumatoneKeyboardComponent::setUiMode(LumatoneKeyboardComponent::UiMode mode
uiMode = modeIn;
}

void LumatoneKeyboardComponent::completeMappingLoaded(const LumatoneLayout& mappingData)
void LumatoneKeyboardComponent::layoutChanged(const LumatoneLayout& mappingData)
{
for (int boardIndex = 0; boardIndex < octaveBoards.size(); boardIndex++)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/lumatone_editor_library/ui/keyboard_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class LumatoneKeyboardComponent : public juce::Component,

public:
// LumatoneEditor::EditorListener Implementation
void completeMappingLoaded(const LumatoneLayout& mappingData) override;
void layoutChanged(const LumatoneLayout& mappingData) override;
void boardChanged(const LumatoneBoard& boardData) override;
void contextChanged(LumatoneContext* newOrEmptyContext) override;
void keyChanged(int boardIndex, int keyIndex, const LumatoneKey& lumatoneKey) override;
Expand Down
8 changes: 4 additions & 4 deletions Source/mapping_editors/MultiSelectControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void MultiSelectControls::resized()
channelInput->setBounds(noteChannelColumnX, lblChannel->getBottom(), noteChannelColumnWidth, controlHeight);
}

void MultiSelectControls::completeMappingLoaded(const LumatoneLayout &mappingData)
void MultiSelectControls::layoutChanged(const LumatoneLayout &mappingData)
{
auto layoutColours = mappingData.getLayoutColours();
colourDropdown->setColourOptions(layoutColours);
Expand All @@ -220,15 +220,15 @@ void MultiSelectControls::boardChanged(const LumatoneBoard &boardData)
// colourDropdown->addItem(colour.toDisplayString(false), colourDropdown->getNumItems() + 1);
// }

completeMappingLoaded(*getMappingData());
layoutChanged(*getMappingData());
}

void MultiSelectControls::keyChanged(int boardIndex, int keyIndex, const LumatoneKey &lumatoneKey)
{
// auto colourOptions = colourDropdown->getColourOptions();
// if (!colourOptions.contains(lumatoneKey.getColour()))
// colourDropdown->addItem(lumatoneKey.getColour().toDisplayString(false), colourDropdown->getNumItems() + 1);
completeMappingLoaded(*getMappingData());
layoutChanged(*getMappingData());
}

void MultiSelectControls::keySetChanged(juce::Array<MappedLumatoneKey> selection)
Expand All @@ -241,5 +241,5 @@ void MultiSelectControls::keySetChanged(juce::Array<MappedLumatoneKey> selection

// colourDropdown->addItem(key.getColour().toDisplayString(false), colourDropdown->getNumItems() + 1);
// }
completeMappingLoaded(*getMappingData());
layoutChanged(*getMappingData());
}
2 changes: 1 addition & 1 deletion Source/mapping_editors/MultiSelectControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MultiSelectControls : public LumatoneEditorState
void resized() override;

private:
void completeMappingLoaded(const LumatoneLayout& mappingData) override;
void layoutChanged(const LumatoneLayout& mappingData) override;
void boardChanged(const LumatoneBoard& boardData) override;
void keyChanged(int boardIndex, int keyIndex, const LumatoneKey& lumatoneKey) override;
void keySetChanged(juce::Array<MappedLumatoneKey> selection) override;
Expand Down

0 comments on commit 40625b2

Please sign in to comment.