New mechanism for source update with callbacks

Similarly to Node update callbacks, sources now have SourceCallbacks called at the start of each update. Several SourceCallback are implemented to ensure thread safe update of more complex properties (mixing alpha, depth, etc.).
This commit is contained in:
Bruno Herbelin
2021-12-20 00:25:42 +01:00
parent 8deb364025
commit f921e7610c
9 changed files with 464 additions and 169 deletions

View File

@@ -138,10 +138,9 @@ void LayerView::draw()
float depth_inc = (dsl.back()->depth() - depth) / static_cast<float>(Mixer::selection().size()-1);
for (++it; it != dsl.end(); ++it) {
depth += depth_inc;
(*it)->setDepth(depth);
(*it)->call( new SetDepth(depth, 80.f) );
}
Action::manager().store(std::string("Selection: Layer Distribute"));
++View::need_deep_update_;
}
if (ImGui::Selectable( ICON_FA_RULER_HORIZONTAL " Compress" )){
SourceList dsl = depth_sorted(Mixer::selection().getCopy());
@@ -149,20 +148,18 @@ void LayerView::draw()
float depth = (*it)->depth();
for (++it; it != dsl.end(); ++it) {
depth += LAYER_STEP;
(*it)->setDepth(depth);
(*it)->call( new SetDepth(depth, 80.f) );
}
Action::manager().store(std::string("Selection: Layer Compress"));
++View::need_deep_update_;
}
if (ImGui::Selectable( ICON_FA_EXCHANGE_ALT " Reverse order" )){
SourceList dsl = depth_sorted(Mixer::selection().getCopy());
SourceList::iterator it = dsl.begin();
SourceList::reverse_iterator rit = dsl.rbegin();
for (; it != dsl.end(); ++it, ++rit) {
(*it)->setDepth((*rit)->depth());
(*it)->call( new SetDepth((*rit)->depth(), 80.f) );
}
Action::manager().store(std::string("Selection: Layer Reverse order"));
++View::need_deep_update_;
}
ImGui::PopStyleColor(2);