prepare saving video-export settings.

* migrate dialog from Editor to UI.
* make it a WM proxied window
* prepare applying state after construction..
This commit is contained in:
Robin Gareus 2015-02-27 23:17:26 +01:00
parent c0411de949
commit c90400364a
9 changed files with 131 additions and 90 deletions

View File

@ -105,6 +105,8 @@ typedef uint64_t microseconds_t;
#include "big_clock_window.h"
#include "bundle_manager.h"
#include "engine_dialog.h"
#include "export_video_dialog.h"
#include "export_video_infobox.h"
#include "gain_meter.h"
#include "global_port_matrix.h"
#include "gui_object.h"
@ -206,6 +208,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, location_ui (X_("locations"), _("Locations"))
, route_params (X_("inspector"), _("Tracks and Busses"))
, audio_midi_setup (X_("audio-midi-setup"), _("Audio/MIDI Setup"))
, export_video_dialog (X_("video-export"), _("Video Export Dialog"))
, session_option_editor (X_("session-options-editor"), _("Properties"), boost::bind (&ARDOUR_UI::create_session_option_editor, this))
, add_video_dialog (X_("add-video"), _("Add Tracks/Busses"), boost::bind (&ARDOUR_UI::create_add_video_dialog, this))
, bundle_manager (X_("bundle-manager"), _("Bundle Manager"), boost::bind (&ARDOUR_UI::create_bundle_manager, this))
@ -358,6 +361,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
big_clock_window.set_state (*ui_xml);
audio_port_matrix.set_state (*ui_xml);
midi_port_matrix.set_state (*ui_xml);
export_video_dialog.set_state (*ui_xml);
}
WM::Manager::instance().register_window (&key_editor);
@ -369,6 +373,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
WM::Manager::instance().register_window (&add_video_dialog);
WM::Manager::instance().register_window (&route_params);
WM::Manager::instance().register_window (&audio_midi_setup);
WM::Manager::instance().register_window (&export_video_dialog);
WM::Manager::instance().register_window (&bundle_manager);
WM::Manager::instance().register_window (&location_ui);
WM::Manager::instance().register_window (&big_clock_window);
@ -2439,6 +2444,10 @@ ARDOUR_UI::save_state (const string & name, bool switch_to_it)
_session->add_extra_xml (*node);
if (export_video_dialog) {
_session->add_extra_xml (export_video_dialog->get_state());
}
save_state_canfail (name, switch_to_it);
}
@ -3821,6 +3830,8 @@ ARDOUR_UI::remove_video ()
_session->add_extra_xml(*node);
node = new XMLNode(X_("Videomonitor"));
_session->add_extra_xml(*node);
node = new XMLNode(X_("Videoexport"));
_session->add_extra_xml(*node);
stop_video_server();
}
@ -3835,6 +3846,29 @@ ARDOUR_UI::flush_videotimeline_cache (bool localcacheonly)
editor->queue_visual_videotimeline_update();
}
void
ARDOUR_UI::export_video (bool range)
{
if (ARDOUR::Config->get_show_video_export_info()) {
ExportVideoInfobox infobox (_session);
Gtk::ResponseType rv = (Gtk::ResponseType) infobox.run();
if (infobox.show_again()) {
ARDOUR::Config->set_show_video_export_info(false);
}
switch (rv) {
case GTK_RESPONSE_YES:
PBD::open_uri (ARDOUR::Config->get_reference_manual_url() + "/video-timeline/operations/#export");
break;
default:
break;
}
}
export_video_dialog->set_session (_session);
export_video_dialog->apply_state(editor->get_selection().time, range);
export_video_dialog->run ();
export_video_dialog->hide ();
}
XMLNode*
ARDOUR_UI::mixer_settings () const
{

View File

@ -73,6 +73,7 @@
#include "ardour_window.h"
#include "editing.h"
#include "engine_dialog.h"
#include "export_video_dialog.h"
#include "meterbridge.h"
#include "ui_config.h"
#include "enums.h"
@ -243,6 +244,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
bool start_video_server (Gtk::Window* float_window, bool popup_msg);
void stop_video_server (bool ask_confirm=false);
void flush_videotimeline_cache (bool localcacheonly=false);
void export_video (bool range = false);
void session_add_audio_track (
int input_channels,
@ -624,6 +626,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
WM::Proxy<LocationUIWindow> location_ui;
WM::Proxy<RouteParams_UI> route_params;
WM::Proxy<EngineControl> audio_midi_setup;
WM::Proxy<ExportVideoDialog> export_video_dialog;
/* Windows/Dialogs that require a creator method */

View File

@ -138,7 +138,7 @@ ARDOUR_UI::install_actions ()
sigc::mem_fun (*this, &ARDOUR_UI::remove_video));
act->set_sensitive (false);
act = ActionManager::register_action (main_actions, X_("ExportVideo"), _("Export To Video File"),
hide_return (sigc::bind (sigc::mem_fun(*editor, &PublicEditor::export_video), false)));
hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::export_video), false)));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (main_actions, X_("Snapshot"), _("Snapshot..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), false));

View File

@ -1878,7 +1878,7 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), false, true)));
edit_items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_selection)));
if (ARDOUR_UI::instance()->video_timeline->get_duration() > 0) {
edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*this, &Editor::export_video), true)));
edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*(ARDOUR_UI::instance()), &ARDOUR_UI::export_video), true)));
}
}

View File

@ -994,7 +994,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void toggle_ruler_video (bool onoff) {ruler_video_action->set_active(onoff);}
int videotl_bar_height; /* in units of timebar_height; default: 4 */
int get_videotl_bar_height () const { return videotl_bar_height; }
void export_video (bool range = false);
void toggle_region_video_lock ();
friend class EditorCursor;

View File

@ -32,7 +32,6 @@
#include "audio_time_axis.h"
#include "video_image_frame.h"
#include "export_video_dialog.h"
#include "export_video_infobox.h"
#include "interthread_progress_window.h"
#include "pbd/openuri.h"
@ -105,26 +104,3 @@ Editor::embed_audio_from_video (std::string path, framepos_t n, bool lock_positi
import_status.all_done = true;
::g_unlink(path.c_str());
}
void
Editor::export_video (bool range)
{
if (ARDOUR::Config->get_show_video_export_info()) {
ExportVideoInfobox infobox (_session);
Gtk::ResponseType rv = (Gtk::ResponseType) infobox.run();
if (infobox.show_again()) {
ARDOUR::Config->set_show_video_export_info(false);
}
switch (rv) {
case GTK_RESPONSE_YES:
PBD::open_uri (ARDOUR::Config->get_reference_manual_url() + "/video-timeline/operations/#export");
break;
default:
break;
}
}
ExportVideoDialog dialog (_session, get_selection().time, range);
Gtk::ResponseType r = (Gtk::ResponseType) dialog.run();
(void) r; // keep gcc quiet
dialog.hide();
}

View File

@ -63,9 +63,8 @@ using namespace PBD;
using namespace ARDOUR;
using namespace VideoUtils;
ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme, bool range)
ExportVideoDialog::ExportVideoDialog ()
: ArdourDialog (_("Export Video File "))
, export_range (tme)
, outfn_path_label (_("File:"), Gtk::ALIGN_LEFT)
, outfn_browse_button (_("Browse"))
, invid_path_label (_("Video:"), Gtk::ALIGN_LEFT)
@ -90,8 +89,6 @@ ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme, bool range
, debug_checkbox (_("Debug Mode: Print ffmpeg command and output to stdout."))
#endif
{
set_session (s);
set_name ("ExportVideoDialog");
set_modal (true);
set_skip_taskbar_hint (true);
@ -144,53 +141,7 @@ ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme, bool range
insnd_combo.set_name ("PaddedButton");
insnd_combo.append_text (string_compose (_("from the %1 session's start to the session's end"), PROGRAM_NAME));
frameoffset_t av_offset = ARDOUR_UI::instance()->video_timeline->get_offset();
if (av_offset < 0 ) {
insnd_combo.append_text (_("from 00:00:00:00 to the video's end"));
} else {
insnd_combo.append_text (_("from the video's start to the video's end"));
}
if (!export_range.empty()) {
insnd_combo.append_text (_("Selected range")); // TODO show export_range.start() -> export_range.end_frame()
}
if (range) {
insnd_combo.set_active(2);
} else {
insnd_combo.set_active(0);
}
outfn_path_entry.set_width_chars(38);
outfn_path_entry.set_text (_session->session_directory().export_path() + G_DIR_SEPARATOR +"export.avi");
XMLNode* node = _session->extra_xml (X_("Videotimeline"));
if (node) {
bool filenameset = false;
if (node->property(X_("OriginalVideoFile"))) {
std::string filename = node->property(X_("OriginalVideoFile"))->value();
if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
invid_path_entry.set_text (filename);
filenameset = true;
}
}
if (!filenameset
&& node->property(X_("Filename"))
&& node->property(X_("LocalFile"))
&& node->property(X_("LocalFile"))->value() == X_("1")
) {
std::string filename = node->property(X_("Filename"))->value();
if (filename.at(0) != G_DIR_SEPARATOR) {
filename = Glib::build_filename (_session->session_directory().video_path(), filename);
}
if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
invid_path_entry.set_text (filename);
filenameset = true;
}
}
if (!filenameset) {
invid_path_entry.set_text (X_(""));
}
}
l = manage (new Label (_("<b>Settings:</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
l->set_use_markup ();
@ -306,16 +257,6 @@ ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme, bool range
fps_combo.append_text("30");
fps_combo.append_text("59.94");
fps_combo.append_text("60");
float tcfps = _session->timecode_frames_per_second();
if (fabs(tcfps - 23.976) < 0.01) { fps_combo.set_active(0); }
else if (fabs(tcfps - 24.0 ) < 0.01) { fps_combo.set_active(1); }
else if (fabs(tcfps - 24.976) < 0.01) { fps_combo.set_active(2); }
else if (fabs(tcfps - 25.0 ) < 0.01) { fps_combo.set_active(3); }
else if (fabs(tcfps - 29.97 ) < 0.01) { fps_combo.set_active(4); }
else if (fabs(tcfps - 30.0 ) < 0.01) { fps_combo.set_active(5); }
else if (fabs(tcfps - 59.94 ) < 0.01) { fps_combo.set_active(6); }
else if (fabs(tcfps - 60.0 ) < 0.01) { fps_combo.set_active(7); }
else { fps_combo.set_active(5); }
aspect_combo.set_name ("PaddedButton");
aspect_combo.append_text("4:3");
@ -358,6 +299,90 @@ ExportVideoDialog::~ExportVideoDialog ()
if (transcoder) { delete transcoder; transcoder = 0;}
}
void
ExportVideoDialog::apply_state (TimeSelection &tme, bool range)
{
export_range = tme;
outfn_path_entry.set_text (_session->session_directory().export_path() + G_DIR_SEPARATOR +"export.avi");
frameoffset_t av_offset = ARDOUR_UI::instance()->video_timeline->get_offset();
if (av_offset < 0 ) {
insnd_combo.append_text (_("from 00:00:00:00 to the video's end"));
} else {
insnd_combo.append_text (_("from the video's start to the video's end"));
}
if (!export_range.empty()) {
insnd_combo.append_text (_("Selected range")); // TODO show export_range.start() -> export_range.end_frame()
}
if (range) {
insnd_combo.set_active(2);
} else {
insnd_combo.set_active(0);
}
float tcfps = _session->timecode_frames_per_second();
if (fabs(tcfps - 23.976) < 0.01) { fps_combo.set_active(0); }
else if (fabs(tcfps - 24.0 ) < 0.01) { fps_combo.set_active(1); }
else if (fabs(tcfps - 24.976) < 0.01) { fps_combo.set_active(2); }
else if (fabs(tcfps - 25.0 ) < 0.01) { fps_combo.set_active(3); }
else if (fabs(tcfps - 29.97 ) < 0.01) { fps_combo.set_active(4); }
else if (fabs(tcfps - 30.0 ) < 0.01) { fps_combo.set_active(5); }
else if (fabs(tcfps - 59.94 ) < 0.01) { fps_combo.set_active(6); }
else if (fabs(tcfps - 60.0 ) < 0.01) { fps_combo.set_active(7); }
else { fps_combo.set_active(5); }
XMLNode* node = _session->extra_xml (X_("Videotimeline"));
if (node) {
bool filenameset = false;
if (node->property(X_("OriginalVideoFile"))) {
std::string filename = node->property(X_("OriginalVideoFile"))->value();
if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
invid_path_entry.set_text (filename);
filenameset = true;
}
}
if (!filenameset
&& node->property(X_("Filename"))
&& node->property(X_("LocalFile"))
&& node->property(X_("LocalFile"))->value() == X_("1")
)
{
std::string filename = node->property(X_("Filename"))->value();
if (filename.at(0) != G_DIR_SEPARATOR)
{
filename = Glib::build_filename (_session->session_directory().video_path(), filename);
}
if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS))
{
invid_path_entry.set_text (filename);
filenameset = true;
}
}
if (!filenameset) {
invid_path_entry.set_text (X_(""));
}
}
node = _session->extra_xml (X_("Videoexport"));
if (node) {
if (node->property(X_("OriginalVideoFile"))) {
}
}
}
XMLNode&
ExportVideoDialog::get_state ()
{
XMLNode* node = new XMLNode (X_("Videoexport"));
return *node;
}
void
ExportVideoDialog::set_state (const XMLNode &)
{
}
void
ExportVideoDialog::on_show ()
{

View File

@ -41,13 +41,18 @@
class ExportVideoDialog : public ArdourDialog , public PBD::ScopedConnectionList
{
public:
ExportVideoDialog (ARDOUR::Session*, TimeSelection &tme, bool range = false);
ExportVideoDialog ();
~ExportVideoDialog ();
std::string get_exported_filename () { return outfn_path_entry.get_text(); }
void apply_state(TimeSelection &tme, bool range);
XMLNode& get_state ();
void set_state (const XMLNode &);
private:
TimeSelection &export_range;
TimeSelection export_range;
void on_show ();
void abort_clicked ();

View File

@ -303,7 +303,6 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
virtual int get_videotl_bar_height () const = 0;
virtual void set_video_timeline_height (const int h) = 0;
virtual void embed_audio_from_video (std::string, framepos_t n = 0, bool lock_position_to_video = true) = 0;
virtual void export_video (bool range = false) = 0;
virtual RouteTimeAxisView* get_route_view_by_route_id (const PBD::ID& id) const = 0;