Skip to content

Commit

Permalink
Changes the behavior of "solo" so it doesn't mute Automation Tracks (#…
Browse files Browse the repository at this point in the history
…5547)

* Changes the toggleSolo method

- Changes the toggleSolo method so it doesn't mute automation tracks (keeps their original state)

* Stop restoring Automation Track's mute values

- Since Automation Tracks are not affected by enabling solo on other tracks, there's no need (and it's even counter intuitive) to restore their previous mute value.
- Reduces a line by using "else if".

* Saves two lines merging 2 conditionals in 1

* Adds the new solo behavior as a new LED button

To allow the user choosing between the old solo behavior and the new one, a new LED button was added which will be used to enable the solo keeping the automation tracks states, while the red LED will enable the solo with the current behavior.

Changes to the code:
	- Added a purple LED image that will be used on the new button.
	- Increased the default width of the widget that holds the mute and solo buttons so the third one fits.
	- Changed the positioning of the LEDs on both the standard and compact track modes to accomodate them.
	- Added a new model called m_soloAutomationsModel, which is connected to the new LED button (m_soloAutomationsBtn). This will dictate the behavior of the toggleSolo method.
	- The red LED calls the toggleSolo method as before. The purple LED will change the m_soloAutomationsModel value and toggle the red LED, which will then call toggleSolo. But since the value of m_soloAutomationsModel will be different, the new behavior will be used on the method.

* Revert "Adds the new solo behavior as a new LED button"

This reverts commit fdbc8b2.

After consulting fellow users and devs about this change to the PR, it was decided that adding a third button for the new solo behavior was not the best approach. This reverts the commit so we go back to just changing the solo behavior. Later an option can be added on LMMS settings to choose between the old and new behaviors.

* Adds an option to use the legacy solo behavior

This commit adds an option on LMMS settings (saved to the config file) to go back to the legacy behavior of the track solo button. The option can be found on Settings>General>"Use solo legacy behavior"

Changes to the code:
	- Since there's a change to the configuration file, an upgrade method was created (upgrade_1_3_0) to add the value to the config XML if it isn't already present (safety check).
	- An attribute is added to the DOM structure of the app configuration under the "app" tag, called "sololegacybehavior", which can be either 0 or 1.
	- Changes were made to include/SetupDialog.h, include/ConfigManager.h and src/core/ConfigManager.cpp to implement this new configuration option.
	- The toggleSolo method was changed to behave according to the value of the "sololegacybehavior" configuration.

* Changes the description of the solo setting

Changes the description of the solo setting on the Setup Dialog from "Use solo legacy behavior" to "Mute automation tracks during solo" since the latter is more descriptive and new users wouldn't be confused about what the legacy behavior was.

* Merges "if"s and "if-else"s where possible

A conditional could be merged by using the "||" logical operator and there was a "if" nested inside an "else" that could be merged into a single "if-else".

Very small code format change (keeping code block curly braces in separate lines).

* Uses default value instead of upgrading ConfigFile

Instead of using an upgrade method on the ConfigManager class to set a value to the sololegacybehavior parameter, we now use a default value on every call to ConfigManager::value that requests it.

* Removes repetitive method call

To make the loop more efficient, a local variable was created to hold the behavior of the solo selected in the setup dialog, instead of calling the ConfigManager::value method repeated times.

Observation:

Since no code was added/removed from ConfigManager.cpp, it was restored to its original state. There's however a TAB character in a blank line on line 145, which was there at the beginning of this PR but removed during it. It was written again in this commit to remove ConfigManager.cpp from the "Files changed" list.

* Saves one line of code and adds a comment
  • Loading branch information
IanCaio authored Aug 1, 2020
1 parent e37f379 commit 639f3a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private slots:
void toggleCompactTrackButtons(bool enabled);
void toggleOneInstrumentTrackWindow(bool enabled);
void toggleSideBarOnRight(bool enabled);
void toggleSoloLegacyBehavior(bool enabled);
void toggleMMPZ(bool enabled);
void toggleDisableBackup(bool enabled);
void toggleOpenLastProject(bool enabled);
Expand Down Expand Up @@ -132,6 +133,7 @@ private slots:
bool m_compactTrackButtons;
bool m_oneInstrumentTrackWindow;
bool m_sideBarOnRight;
bool m_soloLegacyBehavior;
bool m_MMPZ;
bool m_disableBackup;
bool m_openLastProject;
Expand Down
20 changes: 18 additions & 2 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,9 @@ void Track::toggleSolo()
}

const bool solo = m_soloModel.value();
// Should we use the new behavior of solo or the older/legacy one?
const bool soloLegacyBehavior = ConfigManager::inst()->value("app", "sololegacybehavior", "0").toInt();

for( TrackContainer::TrackList::const_iterator it = tl.begin();
it != tl.end(); ++it )
{
Expand All @@ -2649,15 +2652,28 @@ void Track::toggleSolo()
{
( *it )->m_mutedBeforeSolo = ( *it )->isMuted();
}
( *it )->setMuted( *it == this ? false : true );
// Don't mute AutomationTracks (keep their original state) unless we are on the sololegacybehavior mode
if( *it == this )
{
( *it )->setMuted( false );
}
else if( soloLegacyBehavior || ( *it )->type() != AutomationTrack )
{
( *it )->setMuted( true );
}
if( *it != this )
{
( *it )->m_soloModel.setValue( false );
}
}
else if( !soloBefore )
{
( *it )->setMuted( ( *it )->m_mutedBeforeSolo );
// Unless we are on the sololegacybehavior mode, only restores the
// mute state if the track isn't an Automation Track
if( soloLegacyBehavior || ( *it )->type() != AutomationTrack )
{
( *it )->setMuted( ( *it )->m_mutedBeforeSolo );
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/gui/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) :
"ui", "oneinstrumenttrackwindow").toInt()),
m_sideBarOnRight(ConfigManager::inst()->value(
"ui", "sidebaronright").toInt()),
m_soloLegacyBehavior(ConfigManager::inst()->value(
"app", "sololegacybehavior", "0").toInt()),
m_MMPZ(!ConfigManager::inst()->value(
"app", "nommpz").toInt()),
m_disableBackup(!ConfigManager::inst()->value(
Expand Down Expand Up @@ -233,6 +235,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) :
m_oneInstrumentTrackWindow, SLOT(toggleOneInstrumentTrackWindow(bool)), true);
addLedCheckBox("Show sidebar on the right-hand side", gui_tw, counter,
m_sideBarOnRight, SLOT(toggleSideBarOnRight(bool)), true);
addLedCheckBox("Mute automation tracks during solo", gui_tw, counter,
m_soloLegacyBehavior, SLOT(toggleSoloLegacyBehavior(bool)), false);

gui_tw->setFixedHeight(YDelta + YDelta * counter);

Expand Down Expand Up @@ -905,6 +909,8 @@ void SetupDialog::accept()
QString::number(m_oneInstrumentTrackWindow));
ConfigManager::inst()->setValue("ui", "sidebaronright",
QString::number(m_sideBarOnRight));
ConfigManager::inst()->setValue("app", "sololegacybehavior",
QString::number(m_soloLegacyBehavior));
ConfigManager::inst()->setValue("app", "nommpz",
QString::number(!m_MMPZ));
ConfigManager::inst()->setValue("app", "disablebackup",
Expand Down Expand Up @@ -1041,6 +1047,10 @@ void SetupDialog::setLanguage(int lang)
}


void SetupDialog::toggleSoloLegacyBehavior(bool enabled)
{
m_soloLegacyBehavior = enabled;
}


// Performance settings slots.
Expand Down

0 comments on commit 639f3a4

Please sign in to comment.