Improved Save and continue recording

When triggered from menu, prepare the UI for next openning of the new source pannel
This commit is contained in:
Bruno Herbelin
2021-12-06 00:16:53 +01:00
parent ffe05368e8
commit a18d53c637
2 changed files with 39 additions and 37 deletions

View File

@@ -334,8 +334,7 @@ void UserInterface::handleKeyboard()
} }
// normal case: Ctrl+R stop recording // normal case: Ctrl+R stop recording
else { else {
// prepare for next open new source panel to show the recording // stop recording
navigator.setNewMedia(Navigator::MEDIA_RECORDING, video_recorder_->filename());
video_recorder_->stop(); video_recorder_->stop();
} }
} }
@@ -1332,31 +1331,29 @@ void UserInterface::RenderPreview()
if ( ImGui::MenuItem( ICON_FA_CAMERA_RETRO " Capture frame", CTRL_MOD "Shitf+R") ) if ( ImGui::MenuItem( ICON_FA_CAMERA_RETRO " Capture frame", CTRL_MOD "Shitf+R") )
FrameGrabbing::manager().add(new PNGRecorder); FrameGrabbing::manager().add(new PNGRecorder);
// Stop recording menu if main recorder already exists // temporary disabled
if (!_video_recorders.empty()) { if (!_video_recorders.empty()) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(IMGUI_COLOR_RECORD, 0.8f)); ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(IMGUI_COLOR_RECORD, 0.8f));
ImGui::MenuItem( ICON_FA_SQUARE " Record starting", CTRL_MOD "R", false, false); ImGui::MenuItem( ICON_FA_SQUARE " Record", CTRL_MOD "R", false, false);
ImGui::MenuItem( ICON_FA_STOP_CIRCLE " Save & continue", CTRL_MOD "Alt+R", false, false);
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
} }
// Stop recording menu (recorder already exists)
else if (video_recorder_) { else if (video_recorder_) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(IMGUI_COLOR_RECORD, 0.8f)); ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(IMGUI_COLOR_RECORD, 0.8f));
if ( ImGui::MenuItem( ICON_FA_SQUARE " Stop Record", CTRL_MOD "R") ) { if ( ImGui::MenuItem( ICON_FA_SQUARE " Stop Record", CTRL_MOD "R") )
video_recorder_->stop(); video_recorder_->stop();
// prepare for next open new source panel to show the recording // offer the 'save & continue' recording
navigator.setNewMedia(Navigator::MEDIA_RECORDING, video_recorder_->filename()); if ( ImGui::MenuItem( ICON_FA_STOP_CIRCLE " Save & continue", CTRL_MOD "Alt+R") ) {
} // prepare for next time user open new source panel to show the recording
// offer the 'save & continue' recording for undefined duration Settings::application.recentRecordings.load_at_start = true;
if (Settings::application.record.timeout == RECORD_MAX_TIMEOUT) { Settings::application.source.new_type = Navigator::SOURCE_FILE;
if ( ImGui::MenuItem( ICON_FA_ARROW_ALT_CIRCLE_DOWN " Save & continue", CTRL_MOD "Alt+R") ) { navigator.setNewMedia(Navigator::MEDIA_RECORDING);
// prepare for next open new source panel to show the recording // create a new recorder chainned to the current one
navigator.setNewMedia(Navigator::MEDIA_RECORDING, video_recorder_->filename()); VideoRecorder *rec = new VideoRecorder;
// create a new recorder chainned to the current one FrameGrabbing::manager().chain(video_recorder_, rec);
VideoRecorder *rec = new VideoRecorder; // swap recorder
FrameGrabbing::manager().chain(video_recorder_, rec); video_recorder_ = rec;
// swap recorder
video_recorder_ = rec;
}
} }
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
} }
@@ -1367,6 +1364,7 @@ void UserInterface::RenderPreview()
_video_recorders.emplace_back( std::async(std::launch::async, delayTrigger, new VideoRecorder, _video_recorders.emplace_back( std::async(std::launch::async, delayTrigger, new VideoRecorder,
std::chrono::seconds(Settings::application.record.delay)) ); std::chrono::seconds(Settings::application.record.delay)) );
} }
ImGui::MenuItem( ICON_FA_STOP_CIRCLE " Save & continue", CTRL_MOD "Alt+R", false, false);
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
} }
// Options menu // Options menu
@@ -1407,11 +1405,6 @@ void UserInterface::RenderPreview()
ImGui::SliderInt("Trigger", &Settings::application.record.delay, 0, 5, ImGui::SliderInt("Trigger", &Settings::application.record.delay, 0, 5,
Settings::application.record.delay < 1 ? "Immediate" : "After %d s"); Settings::application.record.delay < 1 ? "Immediate" : "After %d s");
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
// ImGui::SliderInt("Buffer", &Settings::application.record.buffering_mode, 0, VIDEO_RECORDER_BUFFERING_NUM_PRESET-1,
// VideoRecorder::buffering_preset_name[Settings::application.record.buffering_mode]);
//
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (ImGui::BeginMenu("Share")) if (ImGui::BeginMenu("Share"))
@@ -4053,12 +4046,10 @@ void Navigator::RenderSourcePannel(Source *s)
void Navigator::setNewMedia(MediaCreateMode mode, std::string path) void Navigator::setNewMedia(MediaCreateMode mode, std::string path)
{ {
// switch new source to Media pannel
Settings::application.source.new_type = SOURCE_FILE;
// change mode // change mode
new_media_mode = mode; new_media_mode = mode;
new_media_mode_changed = true; new_media_mode_changed = true;
// mode dependent actions // mode dependent actions
switch (new_media_mode) { switch (new_media_mode) {
case MEDIA_RECENT: case MEDIA_RECENT:
@@ -4223,6 +4214,7 @@ void Navigator::RenderNewPannel()
// show list of recent imports // show list of recent imports
Settings::application.recentImport.validate(); Settings::application.recentImport.validate();
sourceMediaFiles = Settings::application.recentImport.filenames; sourceMediaFiles = Settings::application.recentImport.filenames;
// done changed
Settings::application.recentImport.changed = false; Settings::application.recentImport.changed = false;
} }
// MODE RECORDINGS // MODE RECORDINGS
@@ -4230,6 +4222,14 @@ void Navigator::RenderNewPannel()
// show list of recent records // show list of recent records
Settings::application.recentRecordings.validate(); Settings::application.recentRecordings.validate();
sourceMediaFiles = Settings::application.recentRecordings.filenames; sourceMediaFiles = Settings::application.recentRecordings.filenames;
//
if (Settings::application.recentRecordings.load_at_start && Settings::application.recentRecordings.changed){
Settings::application.recentRecordings.load_at_start = false;
sourceMediaFileCurrent = sourceMediaFiles.front();
std::string label = BaseToolkit::transliterate( sourceMediaFileCurrent );
new_source_preview_.setSource( Mixer::manager().createSourceFile(sourceMediaFileCurrent), label);
}
// done changed
Settings::application.recentRecordings.changed = false; Settings::application.recentRecordings.changed = false;
} }
// MODE LIST FOLDER // MODE LIST FOLDER

View File

@@ -81,7 +81,18 @@ class Navigator
void RenderViewPannel(ImVec2 draw_pos, ImVec2 draw_size); void RenderViewPannel(ImVec2 draw_pos, ImVec2 draw_size);
public: public:
typedef enum {
SOURCE_FILE = 0,
SOURCE_SEQUENCE,
SOURCE_CONNECTED,
SOURCE_GENERATED,
SOURCE_INTERNAL,
SOURCE_TYPES
} NewSourceType;
Navigator(); Navigator();
void Render();
bool pannelVisible() { return pannel_visible_; } bool pannelVisible() { return pannel_visible_; }
void hidePannel(); void hidePannel();
@@ -97,18 +108,9 @@ public:
} MediaCreateMode; } MediaCreateMode;
void setNewMedia(MediaCreateMode mode, std::string path = std::string()); void setNewMedia(MediaCreateMode mode, std::string path = std::string());
void Render();
private: private:
// for new source panel // for new source panel
typedef enum {
SOURCE_FILE = 0,
SOURCE_SEQUENCE,
SOURCE_CONNECTED,
SOURCE_GENERATED,
SOURCE_INTERNAL,
SOURCE_TYPES
} NewSourceType;
SourcePreview new_source_preview_; SourcePreview new_source_preview_;
std::list<std::string> sourceSequenceFiles; std::list<std::string> sourceSequenceFiles;
std::list<std::string> sourceMediaFiles; std::list<std::string> sourceMediaFiles;