Added undo-redo to locking of sources.

This commit is contained in:
brunoherbelin
2021-03-18 21:56:06 +01:00
parent ac5e885fb3
commit 09f052a5d6
7 changed files with 31 additions and 12 deletions

View File

@@ -428,11 +428,11 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
} }
// pick on the lock icon; unlock source // pick on the lock icon; unlock source
else if ( pick.first == current->lock_ ) { else if ( pick.first == current->lock_ ) {
current->setLocked(false); lock(current, false);
} }
// pick on the open lock icon; lock source and cancel pick // pick on the open lock icon; lock source and cancel pick
else if ( pick.first == current->unlock_ ) { else if ( pick.first == current->unlock_ ) {
current->setLocked(true); lock(current, 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 without CTRL key; cancel pick
@@ -452,7 +452,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
Source *s = Mixer::manager().findSource((*itp).first); Source *s = Mixer::manager().findSource((*itp).first);
// lock icon of a source (not current) is picked : unlock // lock icon of a source (not current) is picked : unlock
if ( s!=nullptr && (*itp).first == s->lock_) { if ( s!=nullptr && (*itp).first == s->lock_) {
s->setLocked(false); lock(s, false);
pick = { s->locker_, (*itp).second }; pick = { s->locker_, (*itp).second };
break; break;
} }

View File

@@ -443,10 +443,14 @@ void ImGuiVisitor::visit (Source& s)
bool l = s.locked(); bool l = s.locked();
if (ImGuiToolkit::IconToggle(15,6,17,6, &l, tooltip ) ) { if (ImGuiToolkit::IconToggle(15,6,17,6, &l, tooltip ) ) {
s.setLocked(l); s.setLocked(l);
if (l) if (l) {
Mixer::selection().clear(); Mixer::selection().clear();
else Action::manager().store(s.name() + std::string(" lock."), s.id());
}
else {
Mixer::selection().set(&s); Mixer::selection().set(&s);
Action::manager().store(s.name() + std::string(" unlock."), s.id());
}
} }
// toggle enable/disable image processing // toggle enable/disable image processing

View File

@@ -222,12 +222,12 @@ std::pair<Node *, glm::vec2> LayerView::pick(glm::vec2 P)
if (s != nullptr) { if (s != nullptr) {
// pick on the lock icon; unlock source // pick on the lock icon; unlock source
if ( pick.first == s->lock_) { if ( pick.first == s->lock_) {
s->setLocked(false); lock(s, false);
pick = { s->locker_, pick.second }; pick = { s->locker_, pick.second };
} }
// pick on the open lock icon; lock source and cancel pick // pick on the open lock icon; lock source and cancel pick
else if ( pick.first == s->unlock_ ) { else if ( pick.first == s->unlock_ ) {
s->setLocked(true); lock(s, true);
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
} }
// pick a locked source; cancel pick // pick a locked source; cancel pick

View File

@@ -337,12 +337,12 @@ std::pair<Node *, glm::vec2> MixingView::pick(glm::vec2 P)
if (s != nullptr) { if (s != nullptr) {
// pick on the lock icon; unlock source // pick on the lock icon; unlock source
if ( pick.first == s->lock_) { if ( pick.first == s->lock_) {
s->setLocked(false); lock(s, false);
pick = { s->locker_, pick.second }; pick = { s->locker_, pick.second };
} }
// pick on the open lock icon; lock source and cancel pick // pick on the open lock icon; lock source and cancel pick
else if ( pick.first == s->unlock_ ) { else if ( pick.first == s->unlock_ ) {
s->setLocked(true); lock(s, true);
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
} }
// pick a locked source ; cancel pick // pick a locked source ; cancel pick

View File

@@ -830,11 +830,15 @@ void TextureView::draw()
if (s != nullptr) { if (s != nullptr) {
if (s->textureMirrored()) { if (s->textureMirrored()) {
if (ImGui::Selectable( ICON_FA_TH " Repeat " )) if (ImGui::Selectable( ICON_FA_TH " Repeat " )){
s->setTextureMirrored(false); s->setTextureMirrored(false);
Action::manager().store(s->name() + std::string(": Texture Repeat."), s->id());
}
} else { } else {
if (ImGui::Selectable( ICON_FA_TH " Mirror " )) if (ImGui::Selectable( ICON_FA_TH " Mirror " )){
s->setTextureMirrored(true); s->setTextureMirrored(true);
Action::manager().store(s->name() + std::string(": Texture Mirror."), s->id());
}
} }
ImGui::Separator(); ImGui::Separator();

View File

@@ -263,3 +263,13 @@ void View::updateSelectionOverlay()
overlay_selection_->scale_ = glm::vec3(0.f, 0.f, 1.f); overlay_selection_->scale_ = glm::vec3(0.f, 0.f, 1.f);
} }
void View::lock(Source *s, bool on)
{
s->setLocked(on);
if (on)
Action::manager().store(s->name() + std::string(" lock."), s->id());
else
Action::manager().store(s->name() + std::string(" unlock."), s->id());
}

3
View.h
View File

@@ -80,7 +80,7 @@ public:
return Cursor (); return Cursor ();
} }
// test mouse over provided a point in screen coordinates //TODO: test mouse over provided a point in screen coordinates
virtual Cursor over (glm::vec2) { virtual Cursor over (glm::vec2) {
return Cursor (); return Cursor ();
} }
@@ -120,6 +120,7 @@ protected:
} ContextMenu; } ContextMenu;
ContextMenu show_context_menu_; ContextMenu show_context_menu_;
inline void openContextMenu (ContextMenu m) { show_context_menu_ = m; } inline void openContextMenu (ContextMenu m) { show_context_menu_ = m; }
void lock(Source *s, bool on);
}; };