Improved Action manager labels of stored actions

This commit is contained in:
brunoherbelin
2020-10-11 00:37:49 +02:00
parent 650017c8f3
commit babbddcf28
2 changed files with 106 additions and 50 deletions

View File

@@ -2,6 +2,8 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <sstream>
#include <iomanip>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
@@ -49,7 +51,7 @@ void ImGuiVisitor::visit(Group &n)
n.rotation_.z = 0.f; n.rotation_.z = 0.f;
n.scale_.x = 1.f; n.scale_.x = 1.f;
n.scale_.y = 1.f; n.scale_.y = 1.f;
Action::manager().store("Geometry", n.id()); Action::manager().store("Geometry Reset", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::Text("Geometry"); ImGui::Text("Geometry");
@@ -57,7 +59,7 @@ void ImGuiVisitor::visit(Group &n)
if (ImGuiToolkit::ButtonIcon(6, 15)) { if (ImGuiToolkit::ButtonIcon(6, 15)) {
n.translation_.x = 0.f; n.translation_.x = 0.f;
n.translation_.y = 0.f; n.translation_.y = 0.f;
Action::manager().store("Position", n.id()); Action::manager().store("Position 0.0, 0.0", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
float translation[2] = { n.translation_.x, n.translation_.y}; float translation[2] = { n.translation_.x, n.translation_.y};
@@ -67,23 +69,29 @@ void ImGuiVisitor::visit(Group &n)
n.translation_.x = translation[0]; n.translation_.x = translation[0];
n.translation_.y = translation[1]; n.translation_.y = translation[1];
} }
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Position", n.id()); std::ostringstream oss;
oss << "Position " << std::setprecision(3) << n.translation_.x << ", " << n.translation_.y;
Action::manager().store(oss.str(), n.id());
}
if (ImGuiToolkit::ButtonIcon(18, 9)){ if (ImGuiToolkit::ButtonIcon(18, 9)){
n.rotation_.z = 0.f; n.rotation_.z = 0.f;
Action::manager().store("Angle", n.id()); Action::manager().store("Angle 0.0", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderAngle("Angle", &(n.rotation_.z), -180.f, 180.f) ; ImGui::SliderAngle("Angle", &(n.rotation_.z), -180.f, 180.f) ;
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()) {
Action::manager().store("Angle", n.id()); std::ostringstream oss;
oss << "Angle " << std::setprecision(3) << n.rotation_.z * 180.f / M_PI;
Action::manager().store(oss.str(), n.id());
}
if (ImGuiToolkit::ButtonIcon(3, 15)) { if (ImGuiToolkit::ButtonIcon(3, 15)) {
n.scale_.x = 1.f; n.scale_.x = 1.f;
n.scale_.y = 1.f; n.scale_.y = 1.f;
Action::manager().store("Scale", n.id()); Action::manager().store("Scale 1.0 x 1.0", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
float scale[2] = { n.scale_.x, n.scale_.y} ; float scale[2] = { n.scale_.x, n.scale_.y} ;
@@ -93,8 +101,11 @@ void ImGuiVisitor::visit(Group &n)
n.scale_.x = CLAMP_SCALE(scale[0]); n.scale_.x = CLAMP_SCALE(scale[0]);
n.scale_.y = CLAMP_SCALE(scale[1]); n.scale_.y = CLAMP_SCALE(scale[1]);
} }
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Scale", n.id()); std::ostringstream oss;
oss << "Scale " << std::setprecision(3) << n.scale_.x << " x " << n.scale_.y;
Action::manager().store(oss.str(), n.id());
}
ImGui::PopID(); ImGui::PopID();
@@ -158,10 +169,30 @@ void ImGuiVisitor::visit(Shader &n)
// ImGui::SameLine(0, 5); // ImGui::SameLine(0, 5);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
int mode = n.blending; int mode = n.blending;
if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Inverse\0Addition\0Subtract\0") ) if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Inverse\0Addition\0Subtract\0") ) {
n.blending = Shader::BlendMode(mode); n.blending = Shader::BlendMode(mode);
if (ImGui::IsItemDeactivatedAfterEdit())
Action::manager().store("Blending", n.id()); std::ostringstream oss;
oss << "Blending ";
switch(n.blending) {
case Shader::BLEND_OPACITY:
oss<<"Normal";
break;
case Shader::BLEND_ADD:
oss<<"Screen";
break;
case Shader::BLEND_SUBSTRACT:
oss<<"Inverse";
break;
case Shader::BLEND_LAYER_ADD:
oss<<"Addition";
break;
case Shader::BLEND_LAYER_SUBSTRACT:
oss<<"Subtract";
break;
}
Action::manager().store(oss.str(), n.id());
}
ImGui::PopID(); ImGui::PopID();
} }
@@ -184,9 +215,8 @@ void ImGuiVisitor::visit(ImageShader &n)
else { else {
// TODO ask for custom mask // TODO ask for custom mask
} }
Action::manager().store("Mask "+ std::string(ImageShader::mask_names[n.mask]), n.id());
} }
if (ImGui::IsItemDeactivatedAfterEdit())
Action::manager().store("Mask", n.id());
ImGui::PopID(); ImGui::PopID();
} }
@@ -210,13 +240,16 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::ColorEdit3("Gamma Color", glm::value_ptr(n.gamma), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel) ; ImGui::ColorEdit3("Gamma Color", glm::value_ptr(n.gamma), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel) ;
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit())
Action::manager().store("Gamma Color", n.id()); Action::manager().store("Gamma Color changed", n.id());
ImGui::SameLine(0, 5); ImGui::SameLine(0, 5);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderFloat("Gamma", &n.gamma.w, 0.5f, 10.f, "%.2f", 2.f); ImGui::SliderFloat("Gamma", &n.gamma.w, 0.5f, 10.f, "%.2f", 2.f);
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Gamma", n.id()); std::ostringstream oss;
oss << "Gamma " << std::setprecision(2) << n.gamma.w;
Action::manager().store(oss.str(), n.id());
}
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); // ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
// ImGui::SliderFloat4("Levels", glm::value_ptr(n.levels), 0.0, 1.0); // ImGui::SliderFloat4("Levels", glm::value_ptr(n.levels), 0.0, 1.0);
@@ -224,7 +257,7 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGuiToolkit::ButtonIcon(4, 1)) { if (ImGuiToolkit::ButtonIcon(4, 1)) {
n.brightness = 0.f; n.brightness = 0.f;
n.contrast = 0.f; n.contrast = 0.f;
Action::manager().store("B & C", n.id()); Action::manager().store("B & C 0.0 0.0", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
@@ -234,91 +267,115 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
n.brightness = bc[0]; n.brightness = bc[0];
n.contrast = bc[1]; n.contrast = bc[1];
} }
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("B & C", n.id()); std::ostringstream oss;
oss << "B & C " << std::setprecision(2) << n.brightness << " " << n.contrast;
Action::manager().store(oss.str(), n.id());
}
if (ImGuiToolkit::ButtonIcon(2, 1)) { if (ImGuiToolkit::ButtonIcon(2, 1)) {
n.saturation = 0.f; n.saturation = 0.f;
Action::manager().store("Saturation", n.id()); Action::manager().store("Saturation 0.0", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderFloat("Saturation", &n.saturation, -1.0, 1.0); ImGui::SliderFloat("Saturation", &n.saturation, -1.0, 1.0);
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Saturation", n.id()); std::ostringstream oss;
oss << "Saturation " << std::setprecision(2) << n.saturation;
Action::manager().store(oss.str(), n.id());
}
if (ImGuiToolkit::ButtonIcon(12, 4)) { if (ImGuiToolkit::ButtonIcon(12, 4)) {
n.hueshift = 0.f; n.hueshift = 0.f;
Action::manager().store("Hue shift", n.id()); Action::manager().store("Hue shift 0.0", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderFloat("Hue shift", &n.hueshift, 0.0, 1.0); ImGui::SliderFloat("Hue shift", &n.hueshift, 0.0, 1.0);
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Hue shift", n.id()); std::ostringstream oss;
oss << "Hue shift " << std::setprecision(2) << n.hueshift;
Action::manager().store(oss.str(), n.id());
}
if (ImGuiToolkit::ButtonIcon(18, 1)) { if (ImGuiToolkit::ButtonIcon(18, 1)) {
n.nbColors = 0; n.nbColors = 0;
Action::manager().store("Posterize", n.id()); Action::manager().store("Posterize None", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderInt("Posterize", &n.nbColors, 0, 16, n.nbColors == 0 ? "None" : "%d colors"); ImGui::SliderInt("Posterize", &n.nbColors, 0, 16, n.nbColors == 0 ? "None" : "%d colors");
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Posterize", n.id()); std::ostringstream oss;
oss << "Posterize ";
if (n.nbColors == 0) oss << "None"; else oss << n.nbColors;
Action::manager().store(oss.str(), n.id());
}
if (ImGuiToolkit::ButtonIcon(8, 1)) { if (ImGuiToolkit::ButtonIcon(8, 1)) {
n.threshold = 0.f; n.threshold = 0.f;
Action::manager().store("Threshold", n.id()); Action::manager().store("Threshold None", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderFloat("Threshold", &n.threshold, 0.0, 1.0, n.threshold < 0.001 ? "None" : "%.2f"); ImGui::SliderFloat("Threshold", &n.threshold, 0.0, 1.0, n.threshold < 0.001 ? "None" : "%.2f");
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Threshold", n.id()); 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());
}
if (ImGuiToolkit::ButtonIcon(3, 1)) { if (ImGuiToolkit::ButtonIcon(3, 1)) {
n.lumakey = 0.f; n.lumakey = 0.f;
Action::manager().store("Lumakey", n.id()); Action::manager().store("Lumakey 0.0", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderFloat("Lumakey", &n.lumakey, 0.0, 1.0); ImGui::SliderFloat("Lumakey", &n.lumakey, 0.0, 1.0);
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Lumakey", n.id()); std::ostringstream oss;
oss << "Lumakey " << std::setprecision(2) << n.lumakey;
Action::manager().store(oss.str(), n.id());
}
if (ImGuiToolkit::ButtonIcon(13, 4)) { if (ImGuiToolkit::ButtonIcon(13, 4)) {
n.chromakey = glm::vec4(0.f, 0.8f, 0.f, 1.f); n.chromakey = glm::vec4(0.f, 0.8f, 0.f, 1.f);
n.chromadelta = 0.f; n.chromadelta = 0.f;
Action::manager().store("Chromakey & Color", n.id()); Action::manager().store("Chromakey & Color Reset", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::ColorEdit3("Chroma color", glm::value_ptr(n.chromakey), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ; ImGui::ColorEdit3("Chroma color", glm::value_ptr(n.chromakey), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ;
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit())
Action::manager().store("Chroma color", n.id()); Action::manager().store("Chroma color changed", n.id());
ImGui::SameLine(0, 5); ImGui::SameLine(0, 5);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, n.chromadelta < 0.001 ? "None" : "Tolerance %.2f"); ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, n.chromadelta < 0.001 ? "None" : "Tolerance %.2f");
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Chromakey", n.id()); 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());
}
if (ImGuiToolkit::ButtonIcon(7, 1)) { if (ImGuiToolkit::ButtonIcon(7, 1)) {
n.invert = 0; n.invert = 0;
Action::manager().store("Invert", n.id()); Action::manager().store("Invert None", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0")) if (ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0"))
Action::manager().store("Invert", n.id()); Action::manager().store("Invert " + std::string(n.invert<1 ? "None": (n.invert>1 ? "Luminance" : "Color")), n.id());
if (ImGuiToolkit::ButtonIcon(1, 7)) { if (ImGuiToolkit::ButtonIcon(1, 7)) {
n.filterid = 0; n.filterid = 0;
Action::manager().store("Filter", n.id()); Action::manager().store("Filter None", n.id());
} }
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::Combo("Filter", &n.filterid, ImageProcessingShader::filter_names, IM_ARRAYSIZE(ImageProcessingShader::filter_names) ) ) if (ImGui::Combo("Filter", &n.filterid, ImageProcessingShader::filter_names, IM_ARRAYSIZE(ImageProcessingShader::filter_names) ) )
Action::manager().store("Filter", n.id()); Action::manager().store("Filter " + std::string(ImageProcessingShader::filter_names[n.filterid]), n.id());
ImGui::PopID(); ImGui::PopID();

View File

@@ -1014,7 +1014,7 @@ void UserInterface::RenderHistory()
std::string step_label_ = Action::manager().label(i); std::string step_label_ = Action::manager().label(i);
bool enable = i == Action::manager().current(); bool enable = i == Action::manager().current();
if (ImGui::Selectable( step_label_.c_str(), enable, ImGuiSelectableFlags_AllowDoubleClick )) { if (ImGui::Selectable( step_label_.c_str(), &enable, ImGuiSelectableFlags_AllowDoubleClick )) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
@@ -1417,27 +1417,26 @@ void MediaController::Render()
if (ImGui::Selectable( "Reset Speed" )){ if (ImGui::Selectable( "Reset Speed" )){
speed = 1.f; speed = 1.f;
mp_->setPlaySpeed( static_cast<double>(speed) ); mp_->setPlaySpeed( static_cast<double>(speed) );
// Action::manager().store("Reset Speed", mp_->id());
} }
if (ImGui::Selectable( "Reset Timeline" )){ if (ImGui::Selectable( "Reset Timeline" )){
timeline_zoom = 1.f; timeline_zoom = 1.f;
mp_->timeline()->clearFading(); mp_->timeline()->clearFading();
mp_->timeline()->clearGaps(); mp_->timeline()->clearGaps();
Action::manager().store("Reset Timeline", mp_->id()); Action::manager().store("Timeline Reset", mp_->id());
} }
ImGui::Separator(); ImGui::Separator();
ImGui::SetNextItemWidth(150); ImGui::SetNextItemWidth(150);
int smoothcurve = 0; int smoothcurve = 0;
if (ImGui::Combo("##SmoothCurve", &smoothcurve, "Smooth curve\0Just a little\0A bit more\0Quite a lot\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) ); mp_->timeline()->smoothFading( 10 * (int) pow(4, smoothcurve-1) );
Action::manager().store("Smooth curve Timeline", mp_->id()); Action::manager().store("Timeline Smooth curve", mp_->id());
} }
ImGui::SetNextItemWidth(150); ImGui::SetNextItemWidth(150);
int autofade = 0; int autofade = 0;
if (ImGui::Combo("##Autofade", &autofade, "Auto fading\0 250 ms\0 500 ms\0 1 second\0 2 seconds\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()->autoFading( 250 * (int ) pow(2, autofade-1) );
mp_->timeline()->smoothFading( 10 * autofade ); mp_->timeline()->smoothFading( 10 * autofade );
Action::manager().store("Auto fading Timeline", mp_->id()); Action::manager().store("Timeline Auto fading", mp_->id());
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
@@ -1466,7 +1465,7 @@ void MediaController::Render()
mp_->timeline()->update(); mp_->timeline()->update();
} }
else if (released) { else if (released) {
Action::manager().store("Timeline", mp_->id()); Action::manager().store("Timeline change", mp_->id());
} }
// custom timeline slider // custom timeline slider