Added Snapshot Replace

This commit is contained in:
Bruno
2021-04-18 21:02:23 +02:00
parent a50a6e129c
commit c19acda62d
4 changed files with 60 additions and 5 deletions

View File

@@ -177,6 +177,40 @@ void Action::snapshot(const std::string &label)
#endif
}
void Action::replace(uint64_t snapshotid)
{
// ignore if locked or if no label is given
if (locked_)
return;
// get snapshot node of target in current session
Session *se = Mixer::manager().session();
XMLElement *sessionNode = se->snapshots()->xmlDoc_->FirstChildElement( SNAPSHOT_NODE(snapshotid) );
if (sessionNode) {
std::string l = sessionNode->Attribute("label");
se->snapshots()->xmlDoc_->DeleteChild( sessionNode );
// create snapshot node
sessionNode = se->snapshots()->xmlDoc_->NewElement( SNAPSHOT_NODE(snapshotid) );
se->snapshots()->xmlDoc_->InsertEndChild(sessionNode);
// label describes the snapshot
sessionNode->SetAttribute("label", l.c_str());
// save all sources using source visitor
SessionVisitor sv(se->snapshots()->xmlDoc_, sessionNode);
for (auto iter = se->begin(); iter != se->end(); ++iter, sv.setRoot(sessionNode) )
(*iter)->accept(sv);
// debug
#ifdef ACTION_DEBUG
Log::Info("Snapshot replaced %d '%s'", id, label.c_str());
#endif
}
}
std::list<uint64_t> Action::snapshots() const
{
@@ -241,3 +275,8 @@ void Action::restore(uint64_t snapshotid)
store("Snapshot " + label(snapshotid));
}
void Action::interpolate(uint64_t snapshotid, float val)
{
}

View File

@@ -39,7 +39,9 @@ public:
void snapshot(const std::string &label);
std::list<uint64_t> snapshots() const;
void replace(uint64_t snapshotid);
void restore(uint64_t snapshotid);
void interpolate(uint64_t snapshotid, float val);
void remove (uint64_t snapshotid);
std::string label(uint64_t snapshotid) const;

View File

@@ -1211,11 +1211,11 @@ static int InputTextCallback(ImGuiInputTextCallbackData* data)
bool ImGuiToolkit::InputText(const char* label, std::string* str)
{
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CallbackResize;
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CallbackResize | ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CharsNoBlank;
InputTextCallback_UserData cb_user_data;
cb_user_data.Str = str;
return ImGui::InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
return ImGui::InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
}
bool ImGuiToolkit::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, int linesize)

View File

@@ -3153,8 +3153,8 @@ void Navigator::RenderMainPannelVimix()
current_snapshot = *snapit;
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
// trigger snapshot
// current_snapshot = snapshots.end();
Action::manager().restore(current_snapshot);
current_snapshot = 0;
}
}
// context menu
@@ -3173,11 +3173,13 @@ void Navigator::RenderMainPannelVimix()
current_snapshot = 0;
}
if (ImGui::Selectable( ICON_FA_STAR "_ Remove", false, 0, size )) {
Action::manager().remove(current_snapshot);
current_snapshot = 0;
}
if (ImGui::Selectable( ICON_FA_STAR "= Replace", false, 0, size )) {
Action::manager().replace(current_snapshot);
current_snapshot = 0;
}
ImGui::TextDisabled("Rename");
ImGui::SetNextItemWidth(size.x);
if ( current_snapshot > 0 ) {
@@ -3196,7 +3198,11 @@ void Navigator::RenderMainPannelVimix()
ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y ));
if ( ImGuiToolkit::IconButton( ICON_FA_STAR "+")) {
Action::manager().snapshot( SystemToolkit::date_time_string() );
current_snapshot = 0;
}
if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip("Take Snapshot ", CTRL_MOD "Y");
// // active list element : delete snapshot button
// ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_bot.y - ImGui::GetFrameHeightWithSpacing()));
// if (current_snapshot != snapshots.end()) {
@@ -3209,6 +3215,14 @@ void Navigator::RenderMainPannelVimix()
// else
// ImGui::TextDisabled( ICON_FA_STAR "_" );
if (current_snapshot > 0) {
ImGui::SetCursorPos( pos_bot );
static float interpolation = 0.f;
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if ( ImGui::SliderFloat("Animate", &interpolation, 0.f, 1.f) ) {
}
}
}