From c562ec13ef78f7056abb5fed7cc99129fc03aef5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 24 Apr 2024 22:21:21 -0600 Subject: [PATCH] Revert "split EngineDialog into a widget and a dialog" This reverts commit f74ffd5a9202adda4b34e9c8733a0503a0dfeeeb. --- gtk2_ardour/ardour_dialog.cc | 6 - gtk2_ardour/ardour_dialog.h | 5 +- gtk2_ardour/ardour_ui.h | 4 +- gtk2_ardour/ardour_ui_startup.cc | 12 +- gtk2_ardour/engine_dialog.cc | 190 +++++++++++++------------------ gtk2_ardour/engine_dialog.h | 33 +----- gtk2_ardour/session_dialog.h | 2 +- gtk2_ardour/startup_fsm.cc | 2 +- gtk2_ardour/startup_fsm.h | 6 +- 9 files changed, 95 insertions(+), 165 deletions(-) diff --git a/gtk2_ardour/ardour_dialog.cc b/gtk2_ardour/ardour_dialog.cc index a1d7cc6154..273d37fcea 100644 --- a/gtk2_ardour/ardour_dialog.cc +++ b/gtk2_ardour/ardour_dialog.cc @@ -191,9 +191,3 @@ 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 88b60cbe00..e3bf268176 100644 --- a/gtk2_ardour/ardour_dialog.h +++ b/gtk2_ardour/ardour_dialog.h @@ -51,13 +51,10 @@ public: void on_show (); virtual void on_response (int); void set_ui_sensitive (bool); - bool ui_sensitive () const { return _sensitive; } void disallow_idle (); - void pop_splash (); - void add_widget_action (Gtk::Widget&); - protected: + void pop_splash (); void close_self (); bool _sensitive; diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index a3fdedd481..96f4cbda61 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 EngineControlDialog; +class EngineControl; 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 1ad03b2427..efa3f01849 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. */ - EngineControlDialog* amd; + EngineControl* 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 */ - EngineControlDialog* amd; + EngineControl* 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 dad80d946a..f5b45ce8c2 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -80,68 +80,9 @@ static const unsigned int latency_tab = 1; /* zero-based, page zero is the main static const char* results_markup = X_("%1"); -EngineControlDialog::EngineControlDialog () - : ArdourDialog (_("Audio/MIDI Setup")) -{ - 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 ("") + : ArdourDialog (_("Audio/MIDI Setup")) + , engine_status ("") , settings_table (4, 4) , latency_expander (_("Advanced Settings")) , monitor_expander (_("Hardware Monitoring")) @@ -185,7 +126,6 @@ EngineControl::EngineControl () , queue_device_changed (false) , _have_control (true) , block_signals (0) - , parent (nullptr) { using namespace Notebook_Helpers; vector backend_names; @@ -193,6 +133,11 @@ 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 (); @@ -332,6 +277,11 @@ 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)); @@ -504,6 +454,7 @@ 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 (); @@ -512,6 +463,19 @@ 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) { @@ -536,17 +500,15 @@ 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 (*parent, ARDOUR::AudioEngine::instance ()->get_last_backend_error ()); + ArdourMessageDialog msg (*this, 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 (*parent, _("Could not configure Audio/MIDI engine with given settings.")); + ArdourMessageDialog msg (*this, _("Could not configure Audio/MIDI engine with given settings.")); msg.run (); } return rv == 0; @@ -1121,8 +1083,8 @@ EngineControl::backend_changed () maybe_display_saved_state (); } - if (parent && !UIConfiguration::instance().get_allow_to_resize_engine_dialog ()) { - parent->resize (1, 1); // shrink window + if (!UIConfiguration::instance().get_allow_to_resize_engine_dialog ()) { + resize (1, 1); // shrink window } } @@ -2718,7 +2680,7 @@ EngineControl::get_output_device_name () const void EngineControl::control_app_button_clicked () { - if (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -2731,10 +2693,25 @@ 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 (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -2755,15 +2732,13 @@ EngineControl::start_stop_button_clicked () rv = start_engine () ? RESPONSE_OK : RESPONSE_ACCEPT; } - if (parent) { - parent->response (rv); - } + response (rv); } void EngineControl::update_devices_button_clicked () { - if (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -2785,7 +2760,7 @@ EngineControl::update_devices_button_clicked () void EngineControl::try_autostart_button_clicked () { - if (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -2796,7 +2771,7 @@ EngineControl::try_autostart_button_clicked () void EngineControl::use_buffered_io_button_clicked () { - if (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -2977,10 +2952,6 @@ 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); @@ -2991,19 +2962,17 @@ EngineControl::populate_action_area (int page_num) if (page_num == 0) { if (_have_control) { - parent->add_widget_action (start_stop_button); + get_action_area ()->add (start_stop_button); } else { - parent->add_widget_action (connect_disconnect_button); + get_action_area ()->add (connect_disconnect_button); } } else if (page_num == latency_tab) { - 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 (); + 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 (); } else if (page_num == midi_tab) { - parent->add_widget_action (midi_back_button); + get_action_area ()->add (midi_back_button); midi_back_button.show (); } } @@ -3179,7 +3148,7 @@ EngineControl::end_latency_detection () void EngineControl::latency_button_clicked () { - if (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -3193,7 +3162,7 @@ EngineControl::latency_button_clicked () void EngineControl::latency_back_button_clicked () { - if (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -3212,7 +3181,7 @@ EngineControl::latency_back_button_clicked () void EngineControl::use_latency_button_clicked () { - if (!parent || parent->ui_sensitive()) { + if (!_sensitive) { return; } @@ -3258,9 +3227,7 @@ EngineControl::use_latency_button_clicked () * from a running instance. */ notebook.set_current_page (0); - if (parent) { - parent->response (RESPONSE_OK); - } + response (RESPONSE_OK); return; } @@ -3269,6 +3236,17 @@ 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 () { @@ -3341,13 +3319,13 @@ EngineControl::connect_disconnect_click () stop_engine (); } else { if (!ARDOUR_UI::instance ()->the_session ()) { - parent->pop_splash (); - parent->hide (); + pop_splash (); + hide (); ARDOUR::GUIIdle (); } start_engine (); if (!ARDOUR_UI::instance ()->the_session ()) { - parent->response (RESPONSE_OK); + ArdourDialog::response (RESPONSE_OK); } } } @@ -3377,19 +3355,3 @@ 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 0a760fc0d7..b8ba0a2c4a 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -45,7 +45,7 @@ #include "ardour_dialog.h" -class EngineControl : public PBD::ScopedConnectionList, virtual public sigc::trackable +class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { public: EngineControl (); @@ -58,12 +58,6 @@ 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; @@ -353,6 +347,8 @@ 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&); @@ -386,6 +382,8 @@ 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 (); @@ -398,27 +396,6 @@ 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 11211c5389..6f9c66e469 100644 --- a/gtk2_ardour/session_dialog.h +++ b/gtk2_ardour/session_dialog.h @@ -47,7 +47,7 @@ #include "ardour_dialog.h" -class EngineControlDialog; +class EngineControl; class SessionDialog : public ArdourDialog { diff --git a/gtk2_ardour/startup_fsm.cc b/gtk2_ardour/startup_fsm.cc index 9cb408bacc..b724d6c6cf 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 (EngineControlDialog& amd) +StartupFSM::StartupFSM (EngineControl& 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 278ee27378..48f7e832a0 100644 --- a/gtk2_ardour/startup_fsm.h +++ b/gtk2_ardour/startup_fsm.h @@ -27,7 +27,7 @@ class ArdourDialog; class NewUserWizard; -class EngineControlDialog; +class EngineControl; class SessionDialog; class PluginScanDialog; @@ -59,7 +59,7 @@ class StartupFSM : public sigc::trackable WaitingForPlugins }; - StartupFSM (EngineControlDialog&); + StartupFSM (EngineControl&); ~StartupFSM (); void start (); @@ -121,7 +121,7 @@ class StartupFSM : public sigc::trackable * created and destroyed within the scope of startup. */ - EngineControlDialog& audiomidi_dialog; + EngineControl& audiomidi_dialog; NewUserWizard* new_user_dialog; SessionDialog* session_dialog; ArdourDialog* pre_release_dialog;