From ce38bf72b8afc5b4677450332d3d2b0c8b52e30e Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Mon, 15 Mar 2021 22:55:22 +0100 Subject: [PATCH] Action manager for undo of context menu actions --- GeometryView.cpp | 10 +++++----- LayerView.cpp | 6 +++++- TextureView.cpp | 4 ++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/GeometryView.cpp b/GeometryView.cpp index 337090c..7f796c6 100644 --- a/GeometryView.cpp +++ b/GeometryView.cpp @@ -274,7 +274,7 @@ void GeometryView::draw() s->group(mode_)->rotation_.z = 0; s->group(mode_)->translation_ = glm::vec3(0.f); s->touch(); - Action::manager().store(std::string("Source Fit."), s->id()); + Action::manager().store(s->name() + std::string("Source Fit."), s->id()); } if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset" )){ s->group(mode_)->scale_ = glm::vec3(1.f); @@ -282,23 +282,23 @@ void GeometryView::draw() s->group(mode_)->crop_ = glm::vec3(1.f); s->group(mode_)->translation_ = glm::vec3(0.f); s->touch(); - Action::manager().store(std::string("Source Reset."), s->id()); + Action::manager().store(s->name() + std::string("Source Reset."), s->id()); } if (ImGui::Selectable( ICON_FA_CROSSHAIRS " Reset position" )){ s->group(mode_)->translation_ = glm::vec3(0.f); s->touch(); - Action::manager().store(std::string("Source Reset position."), s->id()); + Action::manager().store(s->name() + std::string("Source Reset position."), s->id()); } if (ImGui::Selectable( ICON_FA_COMPASS " Reset rotation" )){ s->group(mode_)->rotation_.z = 0; s->touch(); - Action::manager().store(std::string("Source Reset rotation."), s->id()); + Action::manager().store(s->name() + std::string("Source Reset rotation."), s->id()); } if (ImGui::Selectable( ICON_FA_EXPAND_ALT " Reset aspect ratio" )){ s->group(mode_)->scale_.x = s->group(mode_)->scale_.y; s->group(mode_)->scale_.x *= s->group(mode_)->crop_.x / s->group(mode_)->crop_.y; s->touch(); - Action::manager().store(std::string("Source aspect ratio."), s->id()); + Action::manager().store(s->name() + std::string("Source Reset aspect ratio."), s->id()); } } ImGui::EndPopup(); diff --git a/LayerView.cpp b/LayerView.cpp index 037c3a0..98e9eef 100644 --- a/LayerView.cpp +++ b/LayerView.cpp @@ -17,6 +17,7 @@ #include "Decorations.h" #include "UserInterfaceManager.h" #include "BoundingBoxVisitor.h" +#include "ActionManager.h" #include "Log.h" #include "LayerView.h" @@ -100,7 +101,7 @@ void LayerView::draw() if (candidate_flatten_group){ if (ImGui::Selectable( ICON_FA_DOWNLOAD " Flatten" )) { Mixer::manager().groupSelection(); - +// Action::manager().store(std::string("Selection Flatten."), Mixer::selection().front()->id()); } } else { @@ -118,6 +119,7 @@ void LayerView::draw() depth += depth_inc; (*it)->setDepth(depth); } + Action::manager().store(std::string("Selection Distribute."), dsl.front()->id()); View::need_deep_update_++; } if (ImGui::Selectable( ICON_FA_RULER_HORIZONTAL " Space equally" )){ @@ -128,6 +130,7 @@ void LayerView::draw() depth += 2.f * LAYER_STEP; (*it)->setDepth(depth); } + Action::manager().store(std::string("Selection Space equally."), dsl.front()->id()); View::need_deep_update_++; } if (ImGui::Selectable( ICON_FA_EXCHANGE_ALT " Reverse order" )){ @@ -137,6 +140,7 @@ void LayerView::draw() for (; it != dsl.end(); it++, rit++) { (*it)->setDepth((*rit)->depth()); } + Action::manager().store(std::string("Selection Reverse order."), dsl.front()->id()); View::need_deep_update_++; } diff --git a/TextureView.cpp b/TextureView.cpp index 30b1d85..a97edfa 100644 --- a/TextureView.cpp +++ b/TextureView.cpp @@ -833,19 +833,23 @@ void TextureView::draw() s->group(mode_)->crop_ = glm::vec3(1.f); s->group(mode_)->translation_ = glm::vec3(0.f); s->touch(); + Action::manager().store(s->name() + std::string(": Texture Reset."), s->id()); } if (ImGui::Selectable( ICON_FA_CROSSHAIRS " Reset position" )){ s->group(mode_)->translation_ = glm::vec3(0.f); s->touch(); + Action::manager().store(s->name() + std::string(": Texture Reset position."), s->id()); } if (ImGui::Selectable( ICON_FA_COMPASS " Reset rotation" )){ s->group(mode_)->rotation_.z = 0; s->touch(); + Action::manager().store(s->name() + std::string(": Texture Reset rotation."), s->id()); } if (ImGui::Selectable( ICON_FA_EXPAND_ALT " Reset aspect ratio" )){ s->group(mode_)->scale_.x = s->group(mode_)->scale_.y; s->group(mode_)->scale_.x *= s->group(mode_)->crop_.x / s->group(mode_)->crop_.y; s->touch(); + Action::manager().store(s->name() + std::string(": Texture Reset aspect ratio."), s->id()); } } ImGui::PopStyleColor(2);