diff --git a/gtk2_ardour/ardour_dialog.cc b/gtk2_ardour/ardour_dialog.cc index 273d37fcea..a1d7cc6154 100644 --- a/gtk2_ardour/ardour_dialog.cc +++ b/gtk2_ardour/ardour_dialog.cc @@ -191,3 +191,9 @@ ArdourDialog::set_ui_sensitive (bool yn) { _sensitive = yn; } + +void +ArdourDialog::add_widget_action (Gtk::Widget& w) +{ + get_action_area()->add (w); +} diff --git a/gtk2_ardour/ardour_dialog.h b/gtk2_ardour/ardour_dialog.h index e3bf268176..88b60cbe00 100644 --- a/gtk2_ardour/ardour_dialog.h +++ b/gtk2_ardour/ardour_dialog.h @@ -51,10 +51,13 @@ public: void on_show (); virtual void on_response (int); void set_ui_sensitive (bool); + bool ui_sensitive () const { return _sensitive; } void disallow_idle (); -protected: void pop_splash (); + void add_widget_action (Gtk::Widget&); + +protected: void close_self (); bool _sensitive; diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 96f4cbda61..a3fdedd481 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -132,7 +132,7 @@ class AddVideoDialog; class BigClockWindow; class BigTransportWindow; class BundleManager; -class EngineControl; +class EngineControlDialog; class ExportVideoDialog; class KeyEditor; class LocationUIWindow; @@ -785,7 +785,7 @@ private: WM::Proxy about; WM::Proxy location_ui; WM::Proxy route_params; - WM::Proxy audio_midi_setup; + WM::Proxy audio_midi_setup; WM::Proxy export_video_dialog; WM::Proxy lua_script_window; WM::Proxy idleometer; diff --git a/gtk2_ardour/ardour_ui_startup.cc b/gtk2_ardour/ardour_ui_startup.cc index efa3f01849..1ad03b2427 100644 --- a/gtk2_ardour/ardour_ui_startup.cc +++ b/gtk2_ardour/ardour_ui_startup.cc @@ -205,8 +205,8 @@ audio will be resampled, which reduces quality.\n"), desired, PROGRAM_NAME, actu switch (dialog.run()) { case RESPONSE_YES: ARDOUR::AudioEngine::instance ()->stop (); - (dynamic_cast (audio_midi_setup.get (true)))->run (); - (dynamic_cast (audio_midi_setup.get (true)))->hide (); + (dynamic_cast (audio_midi_setup.get (true)))->run (); + (dynamic_cast (audio_midi_setup.get (true)))->hide (); return AudioEngine::instance()->running () ? -1 : 1; case RESPONSE_ACCEPT: return 0; @@ -580,10 +580,10 @@ ARDOUR_UI::starting () * audio backend end up. */ - EngineControl* amd; + EngineControlDialog* amd; try { - amd = dynamic_cast (audio_midi_setup.get (true)); + amd = dynamic_cast (audio_midi_setup.get (true)); } catch (...) { std::cerr << "audio-midi engine setup failed."<< std::endl; return -1; @@ -922,10 +922,10 @@ ARDOUR_UI::load_from_application_api (const std::string& path) /* do this again */ - EngineControl* amd; + EngineControlDialog* amd; try { - amd = dynamic_cast (audio_midi_setup.get (true)); + amd = dynamic_cast (audio_midi_setup.get (true)); } catch (...) { std::cerr << "audio-midi engine setup failed."<< std::endl; return; diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index f5b45ce8c2..dad80d946a 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -80,9 +80,68 @@ static const unsigned int latency_tab = 1; /* zero-based, page zero is the main static const char* results_markup = X_("%1"); -EngineControl::EngineControl () +EngineControlDialog::EngineControlDialog () : ArdourDialog (_("Audio/MIDI Setup")) - , engine_status ("") +{ + engine_control.set_parent (*this); + + if (UIConfiguration::instance().get_allow_to_resize_engine_dialog ()) { + set_resizable (false); + } + set_name (X_("AudioMIDISetup")); + + /* packup the notebook */ + + get_vbox ()->set_border_width (12); + get_vbox ()->pack_start (engine_control.contents()); +} + +void +EngineControlDialog::on_response (int r) +{ + /* Do not run ArdourDialog::on_response() which will hide us. Leave + * that to whoever invoked us, if they wish to hide us after "start". + * + * StartupFSM does hide us after response(); Window > Audio/MIDI Setup + * does not. + */ + if (r == RESPONSE_OK) { + pop_splash (); + } + Gtk::Dialog::on_response (r); +} + + + +void +EngineControlDialog::on_show () +{ + ArdourDialog::on_show (); + engine_control.on_show (); +} + +void +EngineControlDialog::on_map () +{ + if (!ARDOUR_UI::instance ()->the_session () && !PublicEditor::_instance) { + set_type_hint (Gdk::WINDOW_TYPE_HINT_NORMAL); + } else if (UIConfiguration::instance ().get_all_floating_windows_are_dialogs ()) { + set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG); + } else { + set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY); + } + ArdourDialog::on_map (); +} + +bool +EngineControlDialog::on_delete_event (GdkEventAny* ev) +{ + engine_control.on_delete_event (ev); + return ArdourDialog::on_delete_event (ev); +} + +EngineControl::EngineControl () + : engine_status ("") , settings_table (4, 4) , latency_expander (_("Advanced Settings")) , monitor_expander (_("Hardware Monitoring")) @@ -126,6 +185,7 @@ EngineControl::EngineControl () , queue_device_changed (false) , _have_control (true) , block_signals (0) + , parent (nullptr) { using namespace Notebook_Helpers; vector backend_names; @@ -133,11 +193,6 @@ EngineControl::EngineControl () AttachOptions xopt = AttachOptions (FILL | EXPAND); int row; - if (UIConfiguration::instance().get_allow_to_resize_engine_dialog ()) { - set_resizable (false); - } - set_name (X_("AudioMIDISetup")); - /* the backend combo is the one thing that is ALWAYS visible */ vector backends = ARDOUR::AudioEngine::instance ()->available_backends (); @@ -277,11 +332,6 @@ EngineControl::EngineControl () notebook.set_name ("SettingsNotebook"); - /* packup the notebook */ - - get_vbox ()->set_border_width (12); - get_vbox ()->pack_start (notebook); - /* Setup buttons and signals */ lm_button_audio.signal_clicked.connect (sigc::mem_fun (*this, &EngineControl::calibrate_audio_latency)); @@ -454,7 +504,6 @@ EngineControl::SignalBlocker::~SignalBlocker () void EngineControl::on_show () { - ArdourDialog::on_show (); if (!ARDOUR::AudioEngine::instance ()->current_backend () || !ARDOUR::AudioEngine::instance ()->running ()) { // re-check _have_control (jackd running) see #6041 backend_changed (); @@ -463,19 +512,6 @@ EngineControl::on_show () start_stop_button.grab_focus (); } -void -EngineControl::on_map () -{ - if (!ARDOUR_UI::instance ()->the_session () && !PublicEditor::_instance) { - set_type_hint (Gdk::WINDOW_TYPE_HINT_NORMAL); - } else if (UIConfiguration::instance ().get_all_floating_windows_are_dialogs ()) { - set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG); - } else { - set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY); - } - ArdourDialog::on_map (); -} - void EngineControl::config_parameter_changed (std::string const& p) { @@ -500,15 +536,17 @@ EngineControl::config_parameter_changed (std::string const& p) bool EngineControl::start_engine () { + assert (parent); + int rv = push_state_to_backend (true); if (rv < 0) { /* error message from backend */ - ArdourMessageDialog msg (*this, ARDOUR::AudioEngine::instance ()->get_last_backend_error ()); + ArdourMessageDialog msg (*parent, ARDOUR::AudioEngine::instance ()->get_last_backend_error ()); msg.run (); } else if (rv > 0) { /* error from push_state_to_backend() */ // TODO: get error message from push_state_to_backend - ArdourMessageDialog msg (*this, _("Could not configure Audio/MIDI engine with given settings.")); + ArdourMessageDialog msg (*parent, _("Could not configure Audio/MIDI engine with given settings.")); msg.run (); } return rv == 0; @@ -1083,8 +1121,8 @@ EngineControl::backend_changed () maybe_display_saved_state (); } - if (!UIConfiguration::instance().get_allow_to_resize_engine_dialog ()) { - resize (1, 1); // shrink window + if (parent && !UIConfiguration::instance().get_allow_to_resize_engine_dialog ()) { + parent->resize (1, 1); // shrink window } } @@ -2680,7 +2718,7 @@ EngineControl::get_output_device_name () const void EngineControl::control_app_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -2693,25 +2731,10 @@ EngineControl::control_app_button_clicked () backend->launch_control_app (); } -void -EngineControl::on_response (int r) -{ - /* Do not run ArdourDialog::on_response() which will hide us. Leave - * that to whoever invoked us, if they wish to hide us after "start". - * - * StartupFSM does hide us after response(); Window > Audio/MIDI Setup - * does not. - */ - if (r == RESPONSE_OK) { - pop_splash (); - } - Gtk::Dialog::on_response (r); -} - void EngineControl::start_stop_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -2732,13 +2755,15 @@ EngineControl::start_stop_button_clicked () rv = start_engine () ? RESPONSE_OK : RESPONSE_ACCEPT; } - response (rv); + if (parent) { + parent->response (rv); + } } void EngineControl::update_devices_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -2760,7 +2785,7 @@ EngineControl::update_devices_button_clicked () void EngineControl::try_autostart_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -2771,7 +2796,7 @@ EngineControl::try_autostart_button_clicked () void EngineControl::use_buffered_io_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -2952,6 +2977,10 @@ unparent_widget (Gtk::Widget& w) void EngineControl::populate_action_area (int page_num) { + if (!parent) { + return; + } + /* re-populate action area */ unparent_widget (start_stop_button); unparent_widget (connect_disconnect_button); @@ -2962,17 +2991,19 @@ EngineControl::populate_action_area (int page_num) if (page_num == 0) { if (_have_control) { - get_action_area ()->add (start_stop_button); + parent->add_widget_action (start_stop_button); } else { - get_action_area ()->add (connect_disconnect_button); + parent->add_widget_action (connect_disconnect_button); } } else if (page_num == latency_tab) { - get_action_area ()->add (lm_measure_button); - get_action_area ()->add (lm_use_button); - get_action_area ()->add (lm_back_button); - get_action_area ()->show_all (); + parent->add_widget_action (lm_measure_button); + parent->add_widget_action (lm_use_button); + parent->add_widget_action (lm_back_button); + lm_measure_button.show(); + lm_use_button.show (); + lm_back_button.show (); } else if (page_num == midi_tab) { - get_action_area ()->add (midi_back_button); + parent->add_widget_action (midi_back_button); midi_back_button.show (); } } @@ -3148,7 +3179,7 @@ EngineControl::end_latency_detection () void EngineControl::latency_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -3162,7 +3193,7 @@ EngineControl::latency_button_clicked () void EngineControl::latency_back_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -3181,7 +3212,7 @@ EngineControl::latency_back_button_clicked () void EngineControl::use_latency_button_clicked () { - if (!_sensitive) { + if (!parent || parent->ui_sensitive()) { return; } @@ -3227,7 +3258,9 @@ EngineControl::use_latency_button_clicked () * from a running instance. */ notebook.set_current_page (0); - response (RESPONSE_OK); + if (parent) { + parent->response (RESPONSE_OK); + } return; } @@ -3236,17 +3269,6 @@ EngineControl::use_latency_button_clicked () } } -bool -EngineControl::on_delete_event (GdkEventAny* ev) -{ - if (lm_running || notebook.get_current_page () == 2) { - /* currently measuring latency - be sure to clean up */ - end_latency_detection (); - } - - return ArdourDialog::on_delete_event (ev); -} - void EngineControl::engine_running () { @@ -3319,13 +3341,13 @@ EngineControl::connect_disconnect_click () stop_engine (); } else { if (!ARDOUR_UI::instance ()->the_session ()) { - pop_splash (); - hide (); + parent->pop_splash (); + parent->hide (); ARDOUR::GUIIdle (); } start_engine (); if (!ARDOUR_UI::instance ()->the_session ()) { - ArdourDialog::response (RESPONSE_OK); + parent->response (RESPONSE_OK); } } } @@ -3355,3 +3377,19 @@ EngineControl::configure_midi_devices () { notebook.set_current_page (midi_tab); } + +void +EngineControl::set_parent (ArdourDialog& d) +{ + parent = &d; +} + +bool +EngineControl::on_delete_event (GdkEventAny*) +{ + if (lm_running || notebook.get_current_page () == 2) { + /* currently measuring latency - be sure to clean up */ + end_latency_detection (); + } + return false; +} diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index b8ba0a2c4a..0a760fc0d7 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -45,7 +45,7 @@ #include "ardour_dialog.h" -class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList +class EngineControl : public PBD::ScopedConnectionList, virtual public sigc::trackable { public: EngineControl (); @@ -58,6 +58,12 @@ public: void set_desired_sample_rate (uint32_t); + Gtk::Widget& contents() { return notebook; } + void on_show (); + bool on_delete_event (GdkEventAny*); + + void set_parent (ArdourDialog&); + private: Gtk::Notebook notebook; @@ -347,8 +353,6 @@ private: sigc::connection latency_timeout; sigc::connection lm_back_button_signal; - void on_show (); - void on_map (); void on_monitor_expand (); void on_latency_expand (); void config_parameter_changed (std::string const&); @@ -382,8 +386,6 @@ private: /* main dialog events */ void on_switch_page (GtkNotebookPage*, guint page_num); - bool on_delete_event (GdkEventAny*); - void on_response (int); void connect_disconnect_click (); void calibrate_audio_latency (); @@ -396,6 +398,27 @@ private: PBD::ScopedConnection running_connection; PBD::ScopedConnectionList stopped_connection; PBD::ScopedConnection devicelist_connection; + + ArdourDialog* parent; +}; + +class EngineControlDialog : public ArdourDialog +{ + public: + EngineControlDialog (); + + XMLNode& get_state () const { return engine_control.get_state (); } + bool set_state (XMLNode const & node) { return engine_control.set_state (node); } + + void set_desired_sample_rate (uint32_t hz) { engine_control.set_desired_sample_rate (hz); } + + private: + EngineControl engine_control; + + void on_show (); + void on_map (); + void on_response (int); + bool on_delete_event (GdkEventAny*); }; #endif /* __gtk2_ardour_engine_dialog_h__ */ diff --git a/gtk2_ardour/session_dialog.h b/gtk2_ardour/session_dialog.h index 6f9c66e469..11211c5389 100644 --- a/gtk2_ardour/session_dialog.h +++ b/gtk2_ardour/session_dialog.h @@ -47,7 +47,7 @@ #include "ardour_dialog.h" -class EngineControl; +class EngineControlDialog; class SessionDialog : public ArdourDialog { diff --git a/gtk2_ardour/startup_fsm.cc b/gtk2_ardour/startup_fsm.cc index b724d6c6cf..9cb408bacc 100644 --- a/gtk2_ardour/startup_fsm.cc +++ b/gtk2_ardour/startup_fsm.cc @@ -68,7 +68,7 @@ using namespace PBD; using std::string; using std::vector; -StartupFSM::StartupFSM (EngineControl& amd) +StartupFSM::StartupFSM (EngineControlDialog& amd) : session_domain (Config->get_preferred_time_domain()) , session_existing_sample_rate (0) , session_engine_hints ("EngineHints") diff --git a/gtk2_ardour/startup_fsm.h b/gtk2_ardour/startup_fsm.h index 48f7e832a0..278ee27378 100644 --- a/gtk2_ardour/startup_fsm.h +++ b/gtk2_ardour/startup_fsm.h @@ -27,7 +27,7 @@ class ArdourDialog; class NewUserWizard; -class EngineControl; +class EngineControlDialog; class SessionDialog; class PluginScanDialog; @@ -59,7 +59,7 @@ class StartupFSM : public sigc::trackable WaitingForPlugins }; - StartupFSM (EngineControl&); + StartupFSM (EngineControlDialog&); ~StartupFSM (); void start (); @@ -121,7 +121,7 @@ class StartupFSM : public sigc::trackable * created and destroyed within the scope of startup. */ - EngineControl& audiomidi_dialog; + EngineControlDialog& audiomidi_dialog; NewUserWizard* new_user_dialog; SessionDialog* session_dialog; ArdourDialog* pre_release_dialog;