diff --git a/src/MixingView.cpp b/src/MixingView.cpp index 0b78cdd..3d71582 100644 --- a/src/MixingView.cpp +++ b/src/MixingView.cpp @@ -191,27 +191,30 @@ void MixingView::draw() // special action of Mixing view: link or unlink SourceList selected = Mixer::selection().getCopy(); - if ( Mixer::manager().session()->canlink( selected )) { - // the selected sources can be linked - if (ImGui::Selectable( ICON_FA_LINK " Link" )){ - // assemble a MixingGroup - Mixer::manager().session()->link(selected, scene.fg() ); - Action::manager().store(std::string("Sources linked.")); - // clear selection and select one of the sources of the group - Source *cur = Mixer::selection().front(); - Mixer::manager().unsetCurrentSource(); - Mixer::selection().clear(); - Mixer::manager().setCurrentSource( cur ); + bool do_link = false; + if (Mixer::manager().session()->hasLink(selected)) { + if (ImGui::Selectable(ICON_FA_LINK " Re-link")) { + do_link = true; } - } - else { - // the selected sources cannot be linked: offer to unlink! if (ImGui::Selectable( ICON_FA_UNLINK " Unlink" )){ // dismantle MixingGroup(s) Mixer::manager().session()->unlink(selected); Action::manager().store(std::string("Sources unlinked.")); } } + else if (ImGui::Selectable( ICON_FA_LINK " Link" )){ + do_link = true; + } + if (do_link){ + // assemble a MixingGroup + Mixer::manager().session()->link(selected, scene.fg() ); + Action::manager().store(std::string("Sources linked.")); + // clear selection and select one of the sources of the group + Source *cur = Mixer::selection().front(); + Mixer::manager().unsetCurrentSource(); + Mixer::selection().clear(); + Mixer::manager().setCurrentSource( cur ); + } ImGui::Separator(); diff --git a/src/Session.cpp b/src/Session.cpp index c7ad83b..1e77447 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -606,9 +606,9 @@ void Session::move(int current_index, int target_index) sources_.insert(to, s); } -bool Session::canlink (SourceList sources) +bool Session::hasLink (SourceList sources) { - bool canlink = true; + bool _haslink = false; // verify that all sources given are valid in the sesion validate(sources); @@ -617,11 +617,11 @@ bool Session::canlink (SourceList sources) // if this source is linked if ( (*it)->mixingGroup() != nullptr ) { // ask its group to detach it - canlink = false; + _haslink = true; } } - return canlink; + return _haslink; } void Session::link(SourceList sources, Group *parent) diff --git a/src/Session.h b/src/Session.h index 390cb64..6b9a69b 100644 --- a/src/Session.h +++ b/src/Session.h @@ -145,7 +145,7 @@ public: // get the list of sources in mixing groups std::list getMixingGroups () const; // returns true if something can be done to create a mixing group - bool canlink (SourceList sources); + bool hasLink (SourceList sources); // try to link sources of the given list: // can either create a new mixing group or extend an existing group void link (SourceList sources, Group *parent = nullptr);