Skip to content

Commit 81446df

Browse files
authored
Fixed not ligthing the sequencer "Save" button after Ins or Del a combination #2024 (#2036)
1 parent a047a73 commit 81446df

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Fixed the sequencer "Save file" button not lightening after inserting or deleting a combination https://github.com/GrandOrgue/grandorgue/issues/2024
12
- Fixed appearence, sizing and the scrollbar issues with the Stops window https://github.com/GrandOrgue/grandorgue/issues/1961
23
# 3.15.2 (2024-10-25)
34
- Fixed disengaging manually enabled stops when a crescendo was in the Override=Off mode https://github.com/GrandOrgue/grandorgue/issues/1935

src/grandorgue/combinations/GOSetter.cpp

+26-8
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,9 @@ void GOSetter::NotifyCmbChanged() {
557557
m_OrganController->SetOrganModified();
558558
}
559559

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

699+
bool GOSetter::CopyFrameGenerals(
700+
unsigned fromIdx, unsigned toIdx, bool changedBefore) {
701+
const GOGeneralCombination *pNewCmb = m_framegeneral[fromIdx];
702+
GOGeneralCombination *pOldCmb = m_framegeneral[toIdx];
703+
bool changed = (changedBefore || !pOldCmb->IsEmpty() || !pNewCmb->IsEmpty());
704+
705+
pOldCmb->Copy(pNewCmb);
706+
return changed;
707+
}
708+
698709
void GOSetter::ButtonStateChanged(int id, bool newState) {
699710
switch (id) {
700711

@@ -769,18 +780,25 @@ void GOSetter::ButtonStateChanged(int id, bool newState) {
769780
case ID_SETTER_CURRENT:
770781
SetPosition(m_pos);
771782
break;
772-
case ID_SETTER_DELETE:
783+
case ID_SETTER_DELETE: {
784+
bool changed = false;
785+
773786
for (unsigned j = m_pos; j < m_framegeneral.size() - 1; j++)
774-
m_framegeneral[j]->Copy(m_framegeneral[j + 1]);
787+
changed = CopyFrameGenerals(j + 1, j, changed);
775788
UpdateAllButtonsLight(nullptr, -1);
776-
NotifyCmbChanged();
789+
NotifyCmbPushed(changed, true);
777790
break;
778-
case ID_SETTER_INSERT:
791+
}
792+
case ID_SETTER_INSERT: {
793+
bool changed = false;
794+
779795
for (unsigned j = m_framegeneral.size() - 1; j > m_pos; j--)
780-
m_framegeneral[j]->Copy(m_framegeneral[j - 1]);
796+
changed = CopyFrameGenerals(j - 1, j, changed);
797+
UpdateAllButtonsLight(nullptr, -1);
781798
SetPosition(m_pos);
782-
NotifyCmbChanged();
799+
NotifyCmbPushed(changed, true);
783800
break;
801+
}
784802
case ID_SETTER_L0:
785803
case ID_SETTER_L1:
786804
case ID_SETTER_L2:

src/grandorgue/combinations/GOSetter.h

+15-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ class GOSetter : private GOSoundStateHandler,
8989
static const struct ButtonDefinitionEntry m_element_types[];
9090
const struct ButtonDefinitionEntry *GetButtonDefinitionList() override;
9191

92+
/**
93+
* Copy the sequencer combination
94+
* @param fromIdx - position of the source combination
95+
* @param toIdx - position of the destination combination
96+
* @param changedBefore - has the combination been changed before. If yes then
97+
* do not check more for changing
98+
* @return if any of two combinations is changed or changedBefore
99+
*/
100+
bool CopyFrameGenerals(unsigned fromIdx, unsigned toIdx, bool changedBefore);
101+
92102
void ButtonStateChanged(int id, bool newState) override;
93103

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

110123
/**
111124
* Update all setter combination buttons light.

0 commit comments

Comments
 (0)