Fixed source picking problems

Allow unlock of source in geometry, do not allow selection of locked
source with CTRL
This commit is contained in:
brunoherbelin
2021-03-17 21:56:35 +01:00
parent b8fe0d7c69
commit cd4d8f02cb
3 changed files with 52 additions and 53 deletions

View File

@@ -441,28 +441,33 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
} }
} }
// the clicked source changed (not the current source) // the clicked source changed (not the current source)
if (current == nullptr){ if (current == nullptr) {
// default to failed pick // default to failed pick
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
// loop over all nodes picked // loop over all nodes picked to detect clic on locks
for (auto itp = pv.rbegin(); itp != pv.rend(); itp++){ for (auto itp = pv.rbegin(); itp != pv.rend(); itp++){
// get if a source was picked // get if a source was picked
Source *s = Mixer::manager().findSource((*itp).first); Source *s = Mixer::manager().findSource((*itp).first);
// accept picked sources in current workspaces
if ( s!=nullptr && s->workspace() == Settings::application.current_workspace) {
// lock icon of a source (not current) is picked : unlock // lock icon of a source (not current) is picked : unlock
if ( (*itp).first == s->lock_) { if ( s!=nullptr && (*itp).first == s->lock_) {
s->setLocked(false); s->setLocked(false);
pick = { s->locker_, (*itp).second }; pick = { s->locker_, (*itp).second };
break; break;
} }
}
// no lock icon picked, find what else was picked
if ( pick.first == nullptr) {
// loop over all nodes picked
for (auto itp = pv.rbegin(); itp != pv.rend(); itp++){
// get if a source was picked
Source *s = Mixer::manager().findSource((*itp).first);
// accept picked sources in current workspaces
if ( s!=nullptr && s->workspace() == Settings::application.current_workspace) {
// a non-locked source is picked (anywhere) // a non-locked source is picked (anywhere)
else if ( !s->locked() ) { if ( !s->locked() ) {
// not in an active selection? don't pick this one! // not in an active selection? don't pick this one!
if ( !UserInterface::manager().ctrlModifier() && if ( !UserInterface::manager().ctrlModifier() &&
Mixer::selection().size() > 1 && Mixer::selection().size() > 1 &&
@@ -472,14 +477,9 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
pick = { s->locker_, (*itp).second }; pick = { s->locker_, (*itp).second };
break; break;
} }
// force pick a locked source with CTRL key
else if ( s->locked() && UserInterface::manager().ctrlModifier() ) {
pick = { s->locker_, (*itp).second };
break;
}
} }
// no source picked // not a source picked
else { else {
// picked on selection handles // picked on selection handles
if ( (*itp).first == overlay_selection_scale_ || (*itp).first == overlay_selection_rotate_ ) { if ( (*itp).first == overlay_selection_scale_ || (*itp).first == overlay_selection_rotate_ ) {
@@ -497,9 +497,8 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
break; break;
} }
} }
} }
}
} }
} }

View File

@@ -228,8 +228,8 @@ std::pair<Node *, glm::vec2> LayerView::pick(glm::vec2 P)
s->setLocked(true); s->setLocked(true);
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
} }
// pick a locked source without CTRL key; cancel pick // pick a locked source; cancel pick
else if ( s->locked() && !UserInterface::manager().ctrlModifier() ) else if ( s->locked() )
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
} }
else else

View File

@@ -345,8 +345,8 @@ std::pair<Node *, glm::vec2> MixingView::pick(glm::vec2 P)
s->setLocked(true); s->setLocked(true);
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
} }
// pick a locked source without CTRL key; cancel pick // pick a locked source ; cancel pick
else if ( s->locked() && !UserInterface::manager().ctrlModifier() ) { else if ( s->locked() ) {
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
} }
// pick on the mixing group rotation icon // pick on the mixing group rotation icon