Skip to content

Commit

Permalink
Fixed not ligthing the sequencer "Save" button after Ins or Del a com…
Browse files Browse the repository at this point in the history
…bination #2024 (#2036)
  • Loading branch information
oleg68 authored Nov 14, 2024
1 parent a047a73 commit 81446df
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixed the sequencer "Save file" button not lightening after inserting or deleting a combination https://github.com/GrandOrgue/grandorgue/issues/2024
- Fixed appearence, sizing and the scrollbar issues with the Stops window https://github.com/GrandOrgue/grandorgue/issues/1961
# 3.15.2 (2024-10-25)
- Fixed disengaging manually enabled stops when a crescendo was in the Override=Off mode https://github.com/GrandOrgue/grandorgue/issues/1935
Expand Down
34 changes: 26 additions & 8 deletions src/grandorgue/combinations/GOSetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,9 @@ void GOSetter::NotifyCmbChanged() {
m_OrganController->SetOrganModified();
}

void GOSetter::NotifyCmbPushed(bool isChanged) {
if (isChanged && m_state.m_IsActive && !m_state.m_IsModified) {
void GOSetter::NotifyCmbPushed(bool isChanged, bool isForceSet) {
if (
isChanged && (m_state.m_IsActive || isForceSet) && !m_state.m_IsModified) {
m_state.m_IsModified = true;
// light the save button if the last loaded combination file is displayed
if (
Expand Down Expand Up @@ -695,6 +696,16 @@ void GOSetter::FromYaml(const YAML::Node &yamlNode) {
>> *m_framegeneral[i];
}

bool GOSetter::CopyFrameGenerals(
unsigned fromIdx, unsigned toIdx, bool changedBefore) {
const GOGeneralCombination *pNewCmb = m_framegeneral[fromIdx];
GOGeneralCombination *pOldCmb = m_framegeneral[toIdx];
bool changed = (changedBefore || !pOldCmb->IsEmpty() || !pNewCmb->IsEmpty());

pOldCmb->Copy(pNewCmb);
return changed;
}

void GOSetter::ButtonStateChanged(int id, bool newState) {
switch (id) {

Expand Down Expand Up @@ -769,18 +780,25 @@ void GOSetter::ButtonStateChanged(int id, bool newState) {
case ID_SETTER_CURRENT:
SetPosition(m_pos);
break;
case ID_SETTER_DELETE:
case ID_SETTER_DELETE: {
bool changed = false;

for (unsigned j = m_pos; j < m_framegeneral.size() - 1; j++)
m_framegeneral[j]->Copy(m_framegeneral[j + 1]);
changed = CopyFrameGenerals(j + 1, j, changed);
UpdateAllButtonsLight(nullptr, -1);
NotifyCmbChanged();
NotifyCmbPushed(changed, true);
break;
case ID_SETTER_INSERT:
}
case ID_SETTER_INSERT: {
bool changed = false;

for (unsigned j = m_framegeneral.size() - 1; j > m_pos; j--)
m_framegeneral[j]->Copy(m_framegeneral[j - 1]);
changed = CopyFrameGenerals(j - 1, j, changed);
UpdateAllButtonsLight(nullptr, -1);
SetPosition(m_pos);
NotifyCmbChanged();
NotifyCmbPushed(changed, true);
break;
}
case ID_SETTER_L0:
case ID_SETTER_L1:
case ID_SETTER_L2:
Expand Down
17 changes: 15 additions & 2 deletions src/grandorgue/combinations/GOSetter.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ class GOSetter : private GOSoundStateHandler,
static const struct ButtonDefinitionEntry m_element_types[];
const struct ButtonDefinitionEntry *GetButtonDefinitionList() override;

/**
* Copy the sequencer combination
* @param fromIdx - position of the source combination
* @param toIdx - position of the destination combination
* @param changedBefore - has the combination been changed before. If yes then
* do not check more for changing
* @return if any of two combinations is changed or changedBefore
*/
bool CopyFrameGenerals(unsigned fromIdx, unsigned toIdx, bool changedBefore);

void ButtonStateChanged(int id, bool newState) override;

void ControlChanged(GOControl *control) override;
Expand All @@ -102,10 +112,13 @@ class GOSetter : private GOSoundStateHandler,
void NotifyCmbChanged();
/**
* Called after a combination is pushed
* When Set is active then marks the cpmbinations as modified
* When Set is active then marks the combinations as modified
* Temporary it calls mOrganController->SetModified()
* @param isChanged is the combination actually changed
* @param isForceSet is the combination memory changed even the Set button
* is not engaged (for example, Ins or Del are pushed)
*/
void NotifyCmbPushed(bool isChanged = true);
void NotifyCmbPushed(bool isChanged = true, bool isForceSet = false);

/**
* Update all setter combination buttons light.
Expand Down

0 comments on commit 81446df

Please sign in to comment.