Skip to content

Commit

Permalink
Fix handling of solo/mute indicators (fixes #935)
Browse files Browse the repository at this point in the history
  • Loading branch information
kybos committed Dec 30, 2020
1 parent a96a021 commit 7b27675
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
2 changes: 2 additions & 0 deletions muse3/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
30.12.2020
- Fix issue #935: Track list toggling of solo/mute indicators. (kybos)
28.12.2020
- Fix: Relative paths for temporary files didn't work from AppImage,
e.g. when calling external wave editor. (kybos)
Expand Down
64 changes: 30 additions & 34 deletions muse3/muse/arranger/tlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2220,26 +2220,27 @@ void TList::mousePressEvent(QMouseEvent* ev)
case COL_MUTE:
{
bool turnOff = (button == Qt::RightButton) || shift;
bool state = turnOff ? !t->off() : !t->mute();

if((t->selected() && tracks->countSelected() > 1) || ctrl)
if (((t->selected() && tracks->countSelected() > 1) || ctrl) && t->type() != MusECore::Track::AUDIO_OUTPUT)
{
// These are major operations not easily manually undoable. Let's make them undoable.
MusECore::Undo operations;
if (t->selected() && tracks->countSelected() > 1) // toggle all selected tracks
{
for (MusECore::iTrack myt = tracks->begin(); myt != tracks->end(); ++myt) {
if ((*myt)->selected() && (*myt)->type() != MusECore::Track::AUDIO_OUTPUT)
toggleMute(operations, *myt, turnOff);
for (const auto& it : *tracks) {
if (it->selected() && it->type() != MusECore::Track::AUDIO_OUTPUT)
setMute(operations, it, turnOff, state);
}
}
else if (ctrl) // toggle ALL tracks
{
for (MusECore::iTrack myt = tracks->begin(); myt != tracks->end(); ++myt) {
if ((*myt)->type() != MusECore::Track::AUDIO_OUTPUT)
toggleMute(operations, *myt, turnOff);
for (const auto& it : *tracks) {
if (it->type() != MusECore::Track::AUDIO_OUTPUT)
setMute(operations, it, turnOff, state);
}
}
if(!operations.empty())
if (!operations.empty())
{
MusEGlobal::song->applyOperationGroup(operations);
// Not required if undoable.
Expand All @@ -2249,16 +2250,13 @@ void TList::mousePressEvent(QMouseEvent* ev)
else { // toggle the clicked track
// This is a minor operation easily manually undoable. Let's not clog the undo list with it.
MusECore::PendingOperationList operations;
if(turnOff) {
if (turnOff)
operations.add(MusECore::PendingOperationItem(t, !t->off(), MusECore::PendingOperationItem::SetTrackOff));
}
else if (t->off())
operations.add(MusECore::PendingOperationItem(t, false, MusECore::PendingOperationItem::SetTrackOff));
else
{
if(t->off())
operations.add(MusECore::PendingOperationItem(t, false, MusECore::PendingOperationItem::SetTrackOff));
else
operations.add(MusECore::PendingOperationItem(t, !t->mute(), MusECore::PendingOperationItem::SetTrackMute));
}
operations.add(MusECore::PendingOperationItem(t, !t->mute(), MusECore::PendingOperationItem::SetTrackMute));

MusEGlobal::audio->msgExecutePendingOperations(operations, true);
}

Expand All @@ -2267,22 +2265,24 @@ void TList::mousePressEvent(QMouseEvent* ev)

case COL_SOLO:
{
if((t->selected() && tracks->countSelected() > 1) || ctrl)
bool state = !t->solo();

if (((t->selected() && tracks->countSelected() > 1) || ctrl) && t->type() != MusECore::Track::AUDIO_OUTPUT)
{
// These are major operations not easily manually undoable. Let's make them undoable.
MusECore::Undo operations;
if (t->selected() && tracks->countSelected() > 1) // toggle all selected tracks
{
for (MusECore::iTrack myt = tracks->begin(); myt != tracks->end(); ++myt) {
if ((*myt)->selected() && (*myt)->type() != MusECore::Track::AUDIO_OUTPUT)
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackSolo, *myt, !(*myt)->solo()));
for (const auto& it : *tracks) {
if (it->selected() && it->type() != MusECore::Track::AUDIO_OUTPUT)
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackSolo, it, state));
}
}
else if (ctrl) // toggle ALL tracks
{
for (MusECore::iTrack myt = tracks->begin(); myt != tracks->end(); ++myt) {
if ((*myt)->type() != MusECore::Track::AUDIO_OUTPUT)
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackSolo, *myt, !(*myt)->solo()));
for (const auto& it : *tracks) {
if (it->type() != MusECore::Track::AUDIO_OUTPUT)
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackSolo, it, state));
}
}
if(!operations.empty())
Expand All @@ -2296,7 +2296,7 @@ void TList::mousePressEvent(QMouseEvent* ev)
{
// This is a minor operation easily manually undoable. Let's not clog the undo list with it.
MusECore::PendingOperationList operations;
operations.add(MusECore::PendingOperationItem(t, !t->solo(), MusECore::PendingOperationItem::SetTrackSolo));
operations.add(MusECore::PendingOperationItem(t, state, MusECore::PendingOperationItem::SetTrackSolo));
MusEGlobal::audio->msgExecutePendingOperations(operations, true);
}
break;
Expand Down Expand Up @@ -2578,18 +2578,14 @@ void TList::mousePressEvent(QMouseEvent* ev)
redraw();
}

void TList::toggleMute(MusECore::Undo& operations, MusECore::Track *t, bool turnOff)
void TList::setMute(MusECore::Undo& operations, MusECore::Track *t, bool turnOff, bool state)
{
if (turnOff) {
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackOff, t, !t->off()));
}
if (turnOff)
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackOff, t, state));
else if (t->off())
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackOff, t, false));
else
{
if (t->off())
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackOff, t, false));
else
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackMute, t, !t->mute()));
}
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::SetTrackMute, t, state));
}

void TList::loadTrackDrummap(MusECore::MidiTrack* t, const char* fn_)
Expand Down
2 changes: 1 addition & 1 deletion muse3/muse/arranger/tlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class TList : public QWidget {
MusECore::TrackList getRecEnabledTracks();
void setHeaderToolTips();
PopupMenu* colorMenu(QColor c, int id, QWidget* parent);
void toggleMute(MusECore::Undo& operations, MusECore::Track *t, bool turnOff);
void setMute(MusECore::Undo& operations, MusECore::Track *t, bool turnOff, bool state);
void changeTrackToType(MusECore::Track *t, MusECore::Track::TrackType trackType);
void editTrackName(MusECore::Track *t);
void setTrackChannel(MusECore::Track *t, bool isDelta, int channel, int delta, bool doAllTracks = false);
Expand Down

0 comments on commit 7b27675

Please sign in to comment.