From 1390eff646a00abe57f99380ba57b9b06c663554 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Sun, 11 Oct 2020 16:02:41 +0200 Subject: [PATCH] Action manager follows View of restored action (user settings) --- ActionManager.cpp | 9 +++++++++ MediaPlayer.cpp | 6 +++++- Settings.h | 2 ++ UserInterfaceManager.cpp | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ActionManager.cpp b/ActionManager.cpp index 36e770f..5277192 100644 --- a/ActionManager.cpp +++ b/ActionManager.cpp @@ -7,6 +7,7 @@ #include "tinyxml2Toolkit.h" #include "SessionVisitor.h" #include "SessionCreator.h" +#include "Settings.h" #include "ActionManager.h" @@ -57,6 +58,8 @@ void Action::store(const std::string &label, uint64_t id) 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()); // get session to operate on Session *se = Mixer::manager().session(); @@ -150,6 +153,12 @@ void Action::restore(uint target, uint64_t id) std::string nodename = "H" + std::to_string(step_); XMLElement *sessionNode = xmlDoc_.FirstChildElement( nodename.c_str() ); + // ask view to refresh, and switch to action view if user prefers + int view = Settings::application.current_view ; + if (Settings::application.action_history_follow_view) + sessionNode->QueryIntAttribute("view", &view); + Mixer::manager().setView( (View::Mode) view); + #ifdef ACTION_DEBUG Log::Info("Restore %s '%s' ", nodename.c_str(), sessionNode->Attribute("label")); #endif diff --git a/MediaPlayer.cpp b/MediaPlayer.cpp index 590302b..ce530da 100644 --- a/MediaPlayer.cpp +++ b/MediaPlayer.cpp @@ -375,6 +375,10 @@ void MediaPlayer::close() glDeleteBuffers(2, pbo_); pbo_size_ = 0; +#ifdef MEDIA_PLAYER_DEBUG + Log::Info("MediaPlayer %s closed", std::to_string(id_).c_str()); +#endif + // unregister media player MediaPlayer::registered_.remove(this); } @@ -871,7 +875,7 @@ void MediaPlayer::execute_seek_command(GstClockTime target) else { seeking_ = true; #ifdef MEDIA_PLAYER_DEBUG - Log::Info("MediaPlayer %s Seek %ld %f", std::to_string(id_).c_str(), seek_pos, rate_); + Log::Info("MediaPlayer %s Seek %ld %.1f", std::to_string(id_).c_str(), seek_pos, rate_); #endif } diff --git a/Settings.h b/Settings.h index 3b3503e..ceb16c6 100644 --- a/Settings.h +++ b/Settings.h @@ -171,6 +171,7 @@ struct Application bool pannel_stick; bool smooth_transition; bool smooth_cursor; + bool action_history_follow_view; // Settings of widgets WidgetsConfig widget; @@ -205,6 +206,7 @@ struct Application pannel_stick = false; smooth_transition = true; smooth_cursor = false; + action_history_follow_view = false; current_view = 1; windows = std::vector(3); windows[0].name = APP_NAME APP_TITLE; diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 5fe4cbf..a9a0ac5 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -991,6 +991,8 @@ void UserInterface::RenderHistory() if ( ImGui::MenuItem( ICON_FA_REDO " Redo", CTRL_MOD "+Shift Z") ) Action::manager().redo(); + ImGui::MenuItem( ICON_FA_DIRECTIONS " Follow view", nullptr, &Settings::application.action_history_follow_view); + if ( ImGui::MenuItem( ICON_FA_TIMES " Close") ) Settings::application.widget.history = false;