mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
Changed Group ALL sources action to Group ACTIVE sources
Manage mixing groups and clones on the way. This makes the action more flexible for the user, allowing to group only a selection.
This commit is contained in:
34
Mixer.cpp
34
Mixer.cpp
@@ -746,7 +746,7 @@ void Mixer::groupSelection()
|
||||
}
|
||||
}
|
||||
|
||||
void Mixer::groupAll()
|
||||
void Mixer::groupAll(bool only_active)
|
||||
{
|
||||
// obvious cancel
|
||||
if (session_->empty())
|
||||
@@ -759,16 +759,38 @@ void Mixer::groupAll()
|
||||
// remember groups before emptying the session
|
||||
std::list<SourceList> allgroups = session_->getMixingGroups();
|
||||
|
||||
// empty the session (does not delete sources)
|
||||
for ( Source *s = session_->popSource(); s != nullptr; s = session_->popSource()) {
|
||||
if ( sessiongroup->import(s) )
|
||||
detach(s);
|
||||
// loop over sources from the current mixer session
|
||||
for(auto it = session_->begin(); it != session_->end(); ) {
|
||||
// if request for only active, take only active source
|
||||
// and if could import the source in the new session group
|
||||
if ( ( !only_active || (*it)->active() ) && sessiongroup->import( *it ) ) {
|
||||
// detatch the source from mixer
|
||||
detach( *it );
|
||||
// take out source from session and go to next (does not delete the source)
|
||||
it = session_->removeSource( *it );
|
||||
}
|
||||
// otherwise just iterate (leave source in mixer)
|
||||
else
|
||||
break;
|
||||
++it;
|
||||
}
|
||||
|
||||
// successful creation of a session group
|
||||
if (sessiongroup->session()->size() > 0) {
|
||||
|
||||
// if a clone was left orphan in the mixer current session, take in in the group
|
||||
for(auto it = session_->begin(); it != session_->end(); ) {
|
||||
CloneSource *cs = dynamic_cast<CloneSource*>(*it);
|
||||
if ( cs != nullptr && session_->find( cs->origin() ) == session_->end() && sessiongroup->import( *it ) ) {
|
||||
// detatch the source from mixer
|
||||
detach( *it );
|
||||
// take out source from session and go to next (does not delete the source)
|
||||
it = session_->removeSource( *it );
|
||||
}
|
||||
// otherwise just iterate (leave source in mixer)
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
// recreate groups in session group
|
||||
for (auto git = allgroups.begin(); git != allgroups.end(); ++git)
|
||||
sessiongroup->session()->link( *git );
|
||||
|
||||
2
Mixer.h
2
Mixer.h
@@ -67,7 +67,7 @@ public:
|
||||
// operations on selection
|
||||
void deleteSelection ();
|
||||
void groupSelection ();
|
||||
void groupAll ();
|
||||
void groupAll (bool only_active = false);
|
||||
void ungroupAll ();
|
||||
void groupSession ();
|
||||
|
||||
|
||||
@@ -305,8 +305,10 @@ SourceList::iterator Session::deleteSource(Source *s)
|
||||
return its;
|
||||
}
|
||||
|
||||
void Session::removeSource(Source *s)
|
||||
SourceList::iterator Session::removeSource(Source *s)
|
||||
{
|
||||
SourceList::iterator ret = sources_.end();
|
||||
|
||||
// lock before change
|
||||
access_.lock();
|
||||
|
||||
@@ -320,11 +322,13 @@ void Session::removeSource(Source *s)
|
||||
if (s->mixingGroup() != nullptr)
|
||||
s->mixingGroup()->detach(s);
|
||||
// erase the source from the update list & get next element
|
||||
sources_.erase(its);
|
||||
ret = sources_.erase(its);
|
||||
}
|
||||
|
||||
// unlock access
|
||||
access_.unlock();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Source *Session::popSource()
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
// remove this source from the session
|
||||
// Does not delete the source
|
||||
void removeSource(Source *s);
|
||||
SourceList::iterator removeSource (Source *s);
|
||||
|
||||
// get ptr to front most source and remove it from the session
|
||||
// Does not delete the source
|
||||
|
||||
@@ -45,6 +45,17 @@ SourceList playable_only (const SourceList &list)
|
||||
return pl;
|
||||
}
|
||||
|
||||
bool notactive (const Source *s) { return !s->active(); }
|
||||
|
||||
SourceList active_only (const SourceList &list)
|
||||
{
|
||||
SourceList pl = list;
|
||||
|
||||
pl.remove_if(notactive);
|
||||
|
||||
return pl;
|
||||
}
|
||||
|
||||
SourceList depth_sorted(const SourceList &list)
|
||||
{
|
||||
SourceList sl = list;
|
||||
|
||||
@@ -12,6 +12,7 @@ typedef std::list<Source *> SourceList;
|
||||
typedef std::list<SourceCore *> SourceCoreList;
|
||||
|
||||
SourceList playable_only (const SourceList &list);
|
||||
SourceList active_only (const SourceList &list);
|
||||
SourceList depth_sorted (const SourceList &list);
|
||||
SourceList mixing_sorted (const SourceList &list, glm::vec2 center = glm::vec2(0.f, 0.f));
|
||||
SourceList intersect (const SourceList &first, const SourceList &second);
|
||||
|
||||
@@ -985,13 +985,13 @@ void UserInterface::showMenuFile()
|
||||
|
||||
// GROUP
|
||||
ImGui::Separator();
|
||||
if (ImGuiToolkit::MenuItemIcon(11, 2, " Group all sources", false, Mixer::manager().numSource() > 0)) {
|
||||
// create a new group session with all sources
|
||||
Mixer::manager().groupAll();
|
||||
if (ImGuiToolkit::MenuItemIcon(11, 2, " Group active sources", false, Mixer::manager().numSource() > 0)) {
|
||||
// create a new group session with only active sources
|
||||
Mixer::manager().groupAll( true );
|
||||
// switch pannel to show first source (created)
|
||||
navigator.showPannelSource(0);
|
||||
}
|
||||
if (ImGuiToolkit::MenuItemIcon(7, 2, " Expand all groups", false, Mixer::manager().numSource() > 0)) {
|
||||
if (ImGuiToolkit::MenuItemIcon(7, 2, " Expand groups", false, Mixer::manager().numSource() > 0)) {
|
||||
// create a new group session with all sources
|
||||
Mixer::manager().ungroupAll();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user