Entire cleanup of ActionManager

History of previous id of sources is now obtained in SessionLoader; no
need to store the id of the source in action manager XML (so also
removed in View current id).
This commit is contained in:
brunoherbelin
2021-03-19 23:09:49 +01:00
parent b07009f3ce
commit 112b583379
11 changed files with 86 additions and 115 deletions

View File

@@ -34,7 +34,7 @@ void Action::clear()
store("Session start");
}
void Action::store(const std::string &label, uint64_t id)
void Action::store(const std::string &label)
{
// ignore if locked or if no label is given
if (locked_ || label.empty())
@@ -58,8 +58,6 @@ void Action::store(const std::string &label, uint64_t id)
xmlDoc_.InsertEndChild(sessionNode);
// label describes the action
sessionNode->SetAttribute("label", label.c_str());
// id indicates which object was modified
sessionNode->SetAttribute("id", id);
// view indicates the view when this action occured
sessionNode->SetAttribute("view", (int) Mixer::manager().view()->mode());
@@ -104,24 +102,11 @@ void Action::stepTo(uint target)
// get reasonable target
uint t = CLAMP(target, 1, max_step_);
// going backward
if ( t < step_ ) {
// go back one step at a time
while (t < step_)
undo();
}
// step forward
else if ( t > step_ ) {
// go forward one step at a time
while (t > step_)
redo();
}
// ignore t == step_
// restore(t);
if (t != step_)
restore(t);
}
std::string Action::label(uint s) const
{
std::string l = "";

View File

@@ -22,7 +22,7 @@ public:
return _instance;
}
void store(const std::string &label, uint64_t id = 0);
void store(const std::string &label);
void clear();
void undo();

View File

@@ -273,7 +273,7 @@ void GeometryView::draw()
s->group(mode_)->rotation_.z = 0;
s->group(mode_)->translation_ = glm::vec3(0.f);
s->touch();
Action::manager().store(s->name() + std::string("Source Fit."), s->id());
Action::manager().store(s->name() + std::string("Source Fit."));
}
if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset" )){
s->group(mode_)->scale_ = glm::vec3(1.f);
@@ -281,23 +281,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(s->name() + std::string("Source Reset."), s->id());
Action::manager().store(s->name() + std::string("Source Reset."));
}
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("Source Reset position."), s->id());
Action::manager().store(s->name() + std::string("Source Reset position."));
}
if (ImGui::Selectable( ICON_FA_COMPASS " Reset rotation" )){
s->group(mode_)->rotation_.z = 0;
s->touch();
Action::manager().store(s->name() + std::string("Source Reset rotation."), s->id());
Action::manager().store(s->name() + std::string("Source Reset rotation."));
}
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("Source Reset aspect ratio."), s->id());
Action::manager().store(s->name() + std::string("Source Reset aspect ratio."));
}
}
ImGui::EndPopup();
@@ -321,7 +321,7 @@ void GeometryView::draw()
(*sit)->group(mode_)->translation_ = glm::vec3(0.f);
(*sit)->touch();
}
Action::manager().store(std::string("Selection Fit all."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Fit all."));
}
if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset all" )){
// apply to every sources in selection
@@ -332,7 +332,7 @@ void GeometryView::draw()
(*sit)->group(mode_)->translation_ = glm::vec3(0.f);
(*sit)->touch();
}
Action::manager().store(std::string("Selection Reset all."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Reset all."));
}
// if (ImGui::Selectable( ICON_FA_TH " Mosaic" )){ // TODO
@@ -343,7 +343,7 @@ void GeometryView::draw()
glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), -overlay_selection_->translation_);
initiate();
applySelectionTransform(T);
Action::manager().store(std::string("Selection Center."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Center."));
}
if (ImGui::Selectable( ICON_FA_COMPASS " Align" )){
// apply to every sources in selection
@@ -351,7 +351,7 @@ void GeometryView::draw()
(*sit)->group(mode_)->rotation_.z = overlay_selection_->rotation_.z;
(*sit)->touch();
}
Action::manager().store(std::string("Selection Align."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Align."));
}
if (ImGui::Selectable( ICON_FA_COMPRESS " Best Fit" )){
glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), -overlay_selection_->translation_);
@@ -369,7 +369,7 @@ void GeometryView::draw()
glm::mat4 M = S * R * T;
initiate();
applySelectionTransform(M);
Action::manager().store(std::string("Selection Best Fit."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Best Fit."));
}
if (ImGui::Selectable( ICON_FA_EXCHANGE_ALT " Mirror" )){
glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), -overlay_selection_->translation_);
@@ -377,7 +377,7 @@ void GeometryView::draw()
glm::mat4 M = glm::inverse(T) * F * T;
initiate();
applySelectionTransform(M);
Action::manager().store(std::string("Selection Mirror."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Mirror."));
}
ImGui::PopStyleColor(2);
@@ -576,7 +576,6 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
// store action in history
current_action_ = "Scale selection";
current_id_ = Mixer::selection().front()->id();
ret.type = Cursor_ResizeNWSE;
}
// if interaction with selection ROTATION handle
@@ -626,7 +625,6 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
// store action in history
current_action_ = "Scale and rotate selection";
current_id_ = Mixer::selection().front()->id();
ret.type = Cursor_Hand;
}
@@ -975,7 +973,6 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
// store action in history
current_action_ = s->name() + ": " + info.str();
current_id_ = s->id();
// update cursor
ret.info = info.str();
@@ -1070,7 +1067,6 @@ void GeometryView::arrow (glm::vec2 movement)
info << "Position " << std::fixed << std::setprecision(3) << sourceNode->translation_.x;
info << ", " << sourceNode->translation_.y ;
current_action_ = (*it)->name() + ": " + info.str();
current_id_ = (*it)->id();
// delta for others to follow
delta_translation = dest_translation - sourceNode->translation_;

View File

@@ -52,7 +52,7 @@ void ImGuiVisitor::visit(Group &n)
n.rotation_.z = 0.f;
n.scale_.x = 1.f;
n.scale_.y = 1.f;
Action::manager().store("Geometry Reset", n.id());
Action::manager().store("Geometry Reset");
}
ImGui::SameLine(0, 10);
ImGui::Text("Geometry");
@@ -60,7 +60,7 @@ void ImGuiVisitor::visit(Group &n)
if (ImGuiToolkit::ButtonIcon(6, 15)) {
n.translation_.x = 0.f;
n.translation_.y = 0.f;
Action::manager().store("Position 0.0, 0.0", n.id());
Action::manager().store("Position 0.0, 0.0");
}
ImGui::SameLine(0, 10);
float translation[2] = { n.translation_.x, n.translation_.y};
@@ -73,12 +73,12 @@ void ImGuiVisitor::visit(Group &n)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << "Position " << std::setprecision(3) << n.translation_.x << ", " << n.translation_.y;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(3, 15)) {
n.scale_.x = 1.f;
n.scale_.y = 1.f;
Action::manager().store("Scale 1.0 x 1.0", n.id());
Action::manager().store("Scale 1.0 x 1.0");
}
ImGui::SameLine(0, 10);
float scale[2] = { n.scale_.x, n.scale_.y} ;
@@ -91,12 +91,12 @@ void ImGuiVisitor::visit(Group &n)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << "Scale " << std::setprecision(3) << n.scale_.x << " x " << n.scale_.y;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(18, 9)){
n.rotation_.z = 0.f;
Action::manager().store("Angle 0.0", n.id());
Action::manager().store("Angle 0.0");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -104,7 +104,7 @@ void ImGuiVisitor::visit(Group &n)
if (ImGui::IsItemDeactivatedAfterEdit()) {
std::ostringstream oss;
oss << "Angle " << std::setprecision(3) << n.rotation_.z * 180.f / M_PI;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
@@ -132,7 +132,7 @@ void ImGuiVisitor::visit(Scene &n)
void ImGuiVisitor::visit(Primitive &n)
{
ImGui::PushID(std::to_string(n.id()).c_str());
ImGui::Text("Primitive %d", n.id());
ImGui::Text("Primitive %d");
n.shader()->accept(*this);
@@ -206,7 +206,7 @@ void ImGuiVisitor::visit(Shader &n)
oss<<"None";
break;
}
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
ImGui::PopID();
@@ -228,7 +228,7 @@ void ImGuiVisitor::visit(Shader &n)
// else {
// // TODO ask for custom mask
// }
// Action::manager().store("Mask "+ std::string(ImageShader::mask_names[n.mask]), n.id());
// Action::manager().store("Mask "+ std::string(ImageShader::mask_names[n.mask]));
// }
// ImGui::PopID();
//}
@@ -240,19 +240,19 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGuiToolkit::ButtonIcon(6, 2)) {
ImageProcessingShader defaultvalues;
n = defaultvalues;
Action::manager().store("Reset Filters", n.id());
Action::manager().store("Reset Filters");
}
ImGui::SameLine(0, 10);
ImGui::Text("Filters");
if (ImGuiToolkit::ButtonIcon(6, 4)) {
n.gamma = glm::vec4(1.f, 1.f, 1.f, 1.f);
Action::manager().store("Gamma & Color", n.id());
Action::manager().store("Gamma & Color");
}
ImGui::SameLine(0, 10);
ImGui::ColorEdit3("Gamma Color", glm::value_ptr(n.gamma), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel) ;
if (ImGui::IsItemDeactivatedAfterEdit())
Action::manager().store("Gamma Color changed", n.id());
Action::manager().store("Gamma Color changed");
ImGui::SameLine(0, 5);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -260,7 +260,7 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << "Gamma " << std::setprecision(2) << n.gamma.w;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -269,7 +269,7 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGuiToolkit::ButtonIcon(5, 16)) {
n.brightness = 0.f;
n.contrast = 0.f;
Action::manager().store("B & C 0.0 0.0", n.id());
Action::manager().store("B & C 0.0 0.0");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -282,12 +282,12 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << "B & C " << std::setprecision(2) << n.brightness << " " << n.contrast;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(9, 16)) {
n.saturation = 0.f;
Action::manager().store("Saturation 0.0", n.id());
Action::manager().store("Saturation 0.0");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -295,12 +295,12 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << "Saturation " << std::setprecision(2) << n.saturation;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(12, 4)) {
n.hueshift = 0.f;
Action::manager().store("Hue shift 0.0", n.id());
Action::manager().store("Hue shift 0.0");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -308,12 +308,12 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << "Hue shift " << std::setprecision(2) << n.hueshift;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(18, 1)) {
n.nbColors = 0;
Action::manager().store("Posterize None", n.id());
Action::manager().store("Posterize None");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -322,12 +322,12 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
std::ostringstream oss;
oss << "Posterize ";
if (n.nbColors == 0) oss << "None"; else oss << n.nbColors;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(8, 1)) {
n.threshold = 0.f;
Action::manager().store("Threshold None", n.id());
Action::manager().store("Threshold None");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -336,12 +336,12 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
std::ostringstream oss;
oss << "Threshold ";
if (n.threshold < 0.001) oss << "None"; else oss << std::setprecision(2) << n.threshold;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(3, 1)) {
n.lumakey = 0.f;
Action::manager().store("Lumakey 0.0", n.id());
Action::manager().store("Lumakey 0.0");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -349,18 +349,18 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << "Lumakey " << std::setprecision(2) << n.lumakey;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(13, 4)) {
n.chromakey = glm::vec4(0.f, 0.8f, 0.f, 1.f);
n.chromadelta = 0.f;
Action::manager().store("Chromakey & Color Reset", n.id());
Action::manager().store("Chromakey & Color Reset");
}
ImGui::SameLine(0, 10);
ImGui::ColorEdit3("Chroma color", glm::value_ptr(n.chromakey), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ;
if (ImGui::IsItemDeactivatedAfterEdit())
Action::manager().store("Chroma color changed", n.id());
Action::manager().store("Chroma color changed");
ImGui::SameLine(0, 5);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, n.chromadelta < 0.001 ? "None" : "Tolerance %.2f");
@@ -368,26 +368,26 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
std::ostringstream oss;
oss << "Chromakey ";
if (n.chromadelta < 0.001) oss << "None"; else oss << std::setprecision(2) << n.chromadelta;
Action::manager().store(oss.str(), n.id());
Action::manager().store(oss.str());
}
if (ImGuiToolkit::ButtonIcon(6, 16)) {
n.invert = 0;
Action::manager().store("Invert None", n.id());
Action::manager().store("Invert None");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0"))
Action::manager().store("Invert " + std::string(n.invert<1 ? "None": (n.invert>1 ? "Luminance" : "Color")), n.id());
Action::manager().store("Invert " + std::string(n.invert<1 ? "None": (n.invert>1 ? "Luminance" : "Color")));
if (ImGuiToolkit::ButtonIcon(1, 7)) {
n.filterid = 0;
Action::manager().store("Filter None", n.id());
Action::manager().store("Filter None");
}
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::Combo("Filter", &n.filterid, ImageProcessingShader::filter_names, IM_ARRAYSIZE(ImageProcessingShader::filter_names) ) )
Action::manager().store("Filter " + std::string(ImageProcessingShader::filter_names[n.filterid]), n.id());
Action::manager().store("Filter " + std::string(ImageProcessingShader::filter_names[n.filterid]));
ImGui::PopID();
@@ -445,11 +445,11 @@ void ImGuiVisitor::visit (Source& s)
s.setLocked(l);
if (l) {
Mixer::selection().clear();
Action::manager().store(s.name() + std::string(" lock."), s.id());
Action::manager().store(s.name() + std::string(" lock."));
}
else {
Mixer::selection().set(&s);
Action::manager().store(s.name() + std::string(" unlock."), s.id());
Action::manager().store(s.name() + std::string(" unlock."));
}
}
@@ -459,7 +459,7 @@ void ImGuiVisitor::visit (Source& s)
if ( ImGuiToolkit::ButtonToggle(ICON_FA_MAGIC, &on) ){
std::ostringstream oss;
oss << s.name() << ": " << ( on ? "Enable Filter" : "Disable Filter");
Action::manager().store(oss.str(), s.id());
Action::manager().store(oss.str());
}
s.setImageProcessingEnabled(on);
@@ -509,7 +509,7 @@ void ImGuiVisitor::visit (SessionFileSource& s)
if (ImGui::IsItemDeactivatedAfterEdit()){
std::ostringstream oss;
oss << s.name() << ": Fading " << std::setprecision(2) << f;
Action::manager().store(oss.str(), s.id());
Action::manager().store(oss.str());
}
if ( ImGui::Button( ICON_FA_FILE_UPLOAD " Open File", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
@@ -567,7 +567,7 @@ void ImGuiVisitor::visit (PatternSource& s)
s.setPattern(p, s.pattern()->resolution());
std::ostringstream oss;
oss << s.name() << ": Pattern " << Pattern::pattern_types[p];
Action::manager().store(oss.str(), s.id());
Action::manager().store(oss.str());
}
}
ImGui::EndCombo();
@@ -589,7 +589,7 @@ void ImGuiVisitor::visit (DeviceSource& s)
s.setDevice(namedev);
std::ostringstream oss;
oss << s.name() << " Device " << namedev;
Action::manager().store(oss.str(), s.id());
Action::manager().store(oss.str());
}
}
ImGui::EndCombo();

View File

@@ -104,7 +104,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());
Action::manager().store(std::string("Selection Flatten."));
}
}
else {
@@ -122,7 +122,7 @@ void LayerView::draw()
depth += depth_inc;
(*it)->setDepth(depth);
}
Action::manager().store(std::string("Selection Layer Distribute."), dsl.front()->id());
Action::manager().store(std::string("Selection Layer Distribute."));
View::need_deep_update_++;
}
if (ImGui::Selectable( ICON_FA_RULER_HORIZONTAL " Compress" )){
@@ -133,7 +133,7 @@ void LayerView::draw()
depth += LAYER_STEP;
(*it)->setDepth(depth);
}
Action::manager().store(std::string("Selection Layer Compress."), dsl.front()->id());
Action::manager().store(std::string("Selection Layer Compress."));
View::need_deep_update_++;
}
if (ImGui::Selectable( ICON_FA_EXCHANGE_ALT " Reverse order" )){
@@ -143,7 +143,7 @@ void LayerView::draw()
for (; it != dsl.end(); it++, rit++) {
(*it)->setDepth((*rit)->depth());
}
Action::manager().store(std::string("Selection Layer Reverse order."), dsl.front()->id());
Action::manager().store(std::string("Selection Layer Reverse order."));
View::need_deep_update_++;
}
@@ -310,7 +310,6 @@ View::Cursor LayerView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair
// store action in history
current_action_ = s->name() + ": " + info.str();
current_id_ = s->id();
return Cursor(Cursor_ResizeNESW, info.str() );
}
@@ -358,7 +357,6 @@ void LayerView::arrow (glm::vec2 movement)
std::ostringstream info;
info << "Depth " << std::fixed << std::setprecision(2) << (*it)->depth() << " ";
current_action_ = (*it)->name() + ": " + info.str();
current_id_ = (*it)->id();
// delta for others to follow
delta_translation = dest_translation - sourceNode->translation_;

View File

@@ -419,7 +419,7 @@ void Mixer::insertSource(Source *s, View::Mode m)
attach(s);
// new state in history manager
Action::manager().store(s->name() + std::string(" inserted"), s->id());
Action::manager().store(s->name() + std::string(" inserted"));
// if requested to show the source in a given view
// (known to work for View::MIXING et TRANSITION: other views untested)
@@ -524,7 +524,7 @@ void Mixer::deleteSource(Source *s, bool withundo)
// store new state in history manager
if (withundo)
Action::manager().store(name + std::string(" deleted"), id);
Action::manager().store(name + std::string(" deleted"));
// log
Log::Notify("Source %s deleted.", name.c_str());

View File

@@ -135,7 +135,7 @@ void MixingView::draw()
if (ImGui::Selectable( ICON_FA_LINK " Link" )){
// assemble a MixingGroup
Mixer::manager().session()->link(selected, scene.fg() );
Action::manager().store(std::string("Sources linked."), selected.front()->id());
Action::manager().store(std::string("Sources linked."));
// clear selection and select one of the sources of the group
Source *cur = Mixer::selection().front();
Mixer::manager().unsetCurrentSource();
@@ -148,7 +148,7 @@ void MixingView::draw()
if (ImGui::Selectable( ICON_FA_UNLINK " Unlink" )){
// dismantle MixingGroup(s)
Mixer::manager().session()->unlink(selected);
Action::manager().store(std::string("Sources unlinked."), selected.front()->id());
Action::manager().store(std::string("Sources unlinked."));
}
}
@@ -167,7 +167,7 @@ void MixingView::draw()
(*it)->group(View::MIXING)->translation_ -= glm::vec3(center, 0.f);
(*it)->touch();
}
Action::manager().store(std::string("Selection Mixing Center."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Mixing Center."));
}
if (ImGui::Selectable( ICON_FA_HAYKAL " Distribute" )){
SourceList list;
@@ -196,21 +196,21 @@ void MixingView::draw()
(*it)->touch();
angle -= glm::two_pi<float>() / float(list.size());
}
Action::manager().store(std::string("Selection Mixing Distribute."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Mixing Distribute."));
}
if (ImGui::Selectable( ICON_FA_CLOUD_SUN " Expand & hide" )){
SourceList::iterator it = Mixer::selection().begin();
for (; it != Mixer::selection().end(); it++) {
(*it)->setAlpha(0.f);
}
Action::manager().store(std::string("Selection Mixing Expand & hide."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Mixing Expand & hide."));
}
if (ImGui::Selectable( ICON_FA_SUN " Compress & show" )){
SourceList::iterator it = Mixer::selection().begin();
for (; it != Mixer::selection().end(); it++) {
(*it)->setAlpha(0.99f);
}
Action::manager().store(std::string("Selection Mixing Compress & show."), Mixer::selection().front()->id());
Action::manager().store(std::string("Selection Mixing Compress & show."));
}
ImGui::PopStyleColor(2);
ImGui::EndPopup();
@@ -462,7 +462,6 @@ View::Cursor MixingView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pai
// store action in history
current_action_ = s->name() + ": " + info.str();
current_id_ = s->id();
// update cursor
ret.info = info.str();
@@ -529,7 +528,6 @@ void MixingView::arrow (glm::vec2 movement)
else
info << "Inactive " << ICON_FA_SNOWFLAKE;
current_action_ = (*it)->name() + ": " + info.str();
current_id_ = (*it)->id();
// delta for others to follow
delta_translation = dest_translation - sourceNode->translation_;

View File

@@ -581,7 +581,7 @@ void TextureView::draw()
// store action history
std::ostringstream oss;
oss << edit_source_->name() << ": Mask " << (mode>1?"Shape":(mode>0?"Paint":"None"));
Action::manager().store(oss.str(), edit_source_->id());
Action::manager().store(oss.str());
}
// GUI for drawing mask
@@ -692,7 +692,7 @@ void TextureView::draw()
// store action history
std::ostringstream oss;
oss << edit_source_->name() << ": Mask Paint Clear";
Action::manager().store(oss.str(), edit_source_->id());
Action::manager().store(oss.str());
}
if (ImGui::Selectable( ICON_FA_ADJUST "\tInvert")) {
edit_source_->maskShader()->effect = 2;
@@ -701,7 +701,7 @@ void TextureView::draw()
// store action history
std::ostringstream oss;
oss << edit_source_->name() << ": Mask Paint Invert";
Action::manager().store(oss.str(), edit_source_->id());
Action::manager().store(oss.str());
}
if (ImGui::Selectable( ICON_FA_WAVE_SQUARE "\tEdge")) {
edit_source_->maskShader()->effect = 3;
@@ -710,7 +710,7 @@ void TextureView::draw()
// store action history
std::ostringstream oss;
oss << edit_source_->name() << ": Mask Paint Edge";
Action::manager().store(oss.str(), edit_source_->id());
Action::manager().store(oss.str());
}
ImGui::PopFont();
ImGui::EndPopup();
@@ -767,7 +767,7 @@ void TextureView::draw()
// store action history
std::ostringstream oss;
oss << edit_source_->name() << ": Mask Shape " << MaskShader::mask_shapes[shape];
Action::manager().store(oss.str(), edit_source_->id());
Action::manager().store(oss.str());
}
ImGui::SameLine(0, 20);
@@ -788,7 +788,7 @@ void TextureView::draw()
// store action history
std::ostringstream oss;
oss << edit_source_->name() << ": Mask Shape Blur " << blur_percent << "%";
Action::manager().store(oss.str(), edit_source_->id());
Action::manager().store(oss.str());
smoothchanged = false;
}
if (ImGui::IsItemHovered()) {
@@ -843,12 +843,12 @@ void TextureView::draw()
if (s->textureMirrored()) {
if (ImGui::Selectable( ICON_FA_TH " Repeat " )){
s->setTextureMirrored(false);
Action::manager().store(s->name() + std::string(": Texture Repeat."), s->id());
Action::manager().store(s->name() + std::string(": Texture Repeat."));
}
} else {
if (ImGui::Selectable( ICON_FA_TH " Mirror " )){
s->setTextureMirrored(true);
Action::manager().store(s->name() + std::string(": Texture Mirror."), s->id());
Action::manager().store(s->name() + std::string(": Texture Mirror."));
}
}
ImGui::Separator();
@@ -859,23 +859,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());
Action::manager().store(s->name() + std::string(": Texture Reset."));
}
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());
Action::manager().store(s->name() + std::string(": Texture Reset position."));
}
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());
Action::manager().store(s->name() + std::string(": Texture Reset rotation."));
}
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());
Action::manager().store(s->name() + std::string(": Texture Reset aspect ratio."));
}
}
ImGui::PopStyleColor(2);
@@ -951,7 +951,6 @@ View::Cursor TextureView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pa
// store action in history
current_action_ = edit_source_->name() + ": " + info.str();
current_id_ = edit_source_->id();
}
return ret;
@@ -1262,7 +1261,6 @@ View::Cursor TextureView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pa
// store action in history
current_action_ = s->name() + ": " + info.str();
current_id_ = s->id();
// update cursor
ret.info = info.str();
@@ -1351,7 +1349,6 @@ void TextureView::arrow (glm::vec2 movement)
info << "Texture Shift " << std::fixed << std::setprecision(3) << sourceNode->translation_.x;
info << ", " << sourceNode->translation_.y ;
current_action_ = s->name() + ": " + info.str();
current_id_ = s->id();
// request update
s->touch();

View File

@@ -1783,7 +1783,7 @@ void MediaController::Render()
if (ImGui::DragFloat( "##Speed", &speed, 0.01f, -10.f, 10.f, "Speed x %.1f", 2.f))
mp_->setPlaySpeed( static_cast<double>(speed) );
// if (ImGui::IsItemDeactivatedAfterEdit())
// Action::manager().store("Play Speed", mp_->id());
// Action::manager().store("Play Speed");
// TODO: avoid seek every time speed is set
// Timeline popup menu
@@ -1799,21 +1799,21 @@ void MediaController::Render()
timeline_zoom = 1.f;
mp_->timeline()->clearFading();
mp_->timeline()->clearGaps();
Action::manager().store("Timeline Reset", mp_->id());
Action::manager().store("Timeline Reset");
}
ImGui::Separator();
ImGui::SetNextItemWidth(150);
int smoothcurve = 0;
if (ImGui::Combo("##SmoothCurve", &smoothcurve, "Smooth curve\0Just a little\0A bit more\0Quite a lot\0") ){
mp_->timeline()->smoothFading( 10 * (int) pow(4, smoothcurve-1) );
Action::manager().store("Timeline Smooth curve", mp_->id());
Action::manager().store("Timeline Smooth curve");
}
ImGui::SetNextItemWidth(150);
int autofade = 0;
if (ImGui::Combo("##Autofade", &autofade, "Auto fading\0 250 ms\0 500 ms\0 1 second\0 2 seconds\0") ){
mp_->timeline()->autoFading( 250 * (int ) pow(2, autofade-1) );
mp_->timeline()->smoothFading( 10 * autofade );
Action::manager().store("Timeline Auto fading", mp_->id());
Action::manager().store("Timeline Auto fading");
}
ImGui::EndPopup();
}
@@ -1842,7 +1842,7 @@ void MediaController::Render()
mp_->timeline()->update();
}
else if (released) {
Action::manager().store("Timeline change", mp_->id());
Action::manager().store("Timeline change");
}
// custom timeline slider

View File

@@ -113,7 +113,6 @@ std::pair<Node *, glm::vec2> View::pick(glm::vec2 P)
void View::initiate()
{
current_action_ = "";
current_id_ = 0;
for (auto sit = Mixer::manager().session()->begin();
sit != Mixer::manager().session()->end(); sit++){
@@ -126,9 +125,8 @@ void View::terminate()
{
std::regex r("\\n");
current_action_ = std::regex_replace(current_action_, r, " ");
Action::manager().store(current_action_, current_id_);
Action::manager().store(current_action_);
current_action_ = "";
current_id_ = 0;
}
void View::zoom( float factor )
@@ -268,8 +266,8 @@ void View::lock(Source *s, bool on)
{
s->setLocked(on);
if (on)
Action::manager().store(s->name() + std::string(" lock."), s->id());
Action::manager().store(s->name() + std::string(" lock."));
else
Action::manager().store(s->name() + std::string(" unlock."), s->id());
Action::manager().store(s->name() + std::string(" unlock."));
}

1
View.h
View File

@@ -103,7 +103,6 @@ protected:
virtual void saveSettings ();
std::string current_action_;
uint64_t current_id_;
Mode mode_;
// selection