From a65149b2462ea0e73c4686d7ed7bbc42bf6a1632 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 10 Nov 2009 04:30:08 +0000 Subject: [PATCH] lots of tweaks relating to GUI sync management git-svn-id: svn://localhost/ardour2/branches/3.0@6051 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour3_ui_dark.rc.in | 24 +++- gtk2_ardour/ardour_ui.h | 5 +- gtk2_ardour/ardour_ui2.cc | 42 ++++--- gtk2_ardour/ardour_ui_ed.cc | 5 +- gtk2_ardour/ardour_ui_options.cc | 10 +- gtk2_ardour/option_editor.h | 4 + gtk2_ardour/rc_option_editor.cc | 8 +- gtk2_ardour/session_option_editor.cc | 161 +++++++++++++++------------ gtk2_ardour/session_option_editor.h | 1 + libs/ardour/rc_configuration.cc | 2 - libs/ardour/session_midi.cc | 2 - 11 files changed, 161 insertions(+), 103 deletions(-) diff --git a/gtk2_ardour/ardour3_ui_dark.rc.in b/gtk2_ardour/ardour3_ui_dark.rc.in index 01f0085fba..a0643cd7bb 100644 --- a/gtk2_ardour/ardour3_ui_dark.rc.in +++ b/gtk2_ardour/ardour3_ui_dark.rc.in @@ -1112,6 +1112,24 @@ style "green_flashing_alert" = "very_small_text" bg[ACTIVE] = { 0.52, 1.0, 0} } +style "sync_alert" +{ + # + # this is used when the sync button is indicating that sync is + # active, and alternates with another style if sync is active + # but we are not locked + # + bg[ACTIVE] = { 0.52, 1.0, 0} + bg[PRELIGHT] = { 0.52, 1.0, 0} + bg[SELECTED] = { 0.52, 1.0, 0} + bg[NORMAL] = { 0.52, 1.0, 0} + + fg[NORMAL] = { 0, 0, 0 } + fg[PRELIGHT] = { 0, 0, 0 } + fg[SELECTED] = { 0, 0, 0 } + fg[ACTIVE] = { 0, 0, 0 } +} + style "selected_io_selector_port_list" = "medium_bold_text" { @@ -1362,6 +1380,10 @@ widget "*EditGroupButton" style:highest "very_small_button" widget "*EditGroupButtonLabel" style:highest "very_small_button" widget "*TransportButton" style:highest "transport_rec_button" widget "*TransportButton-active" style:highest "transport_button_active" +widget "*TransportSyncButton" style:highest "transport_button" +widget "*TransportSyncButton*" style:highest "transport_button" +widget "*TransportSyncButton-active" style:highest "sync_alert" +widget "*TransportSyncButton-active*" style:highest "sync_alert" widget "*ShuttleButton" style:highest "transport_button" widget "*ShuttleButton*" style:highest "transport_button" widget "*ShuttleDisplay" style:highest "transport_button" @@ -1528,8 +1550,6 @@ widget "*BypassButton" style:highest "red_when_active" widget "*BypassButton*" style:highest "red_when_active" widget "*TransportSoloAlert" style:highest "flashing_alert" widget "*TransportSoloAlert.*" style:highest "flashing_alert" -widget "*TransportSyncAlert" style:highest "flashing_alert" -widget "*TransportSyncAlert.*" style:highest "flashing_alert" widget "*SendAlert" style:highest "green_flashing_alert" widget "*SendAlert.*" style:highest "green_flashing_alert" widget "*TransportAuditioningAlert" style:highest "flashing_alert" diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 6a8d790915..97a64c5330 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -385,9 +385,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI BindableButton play_selection_button; BindableButton rec_button; - Gtk::ToggleButton sync_button; - - void sync_button_clicked (); + void toggle_external_sync (); void toggle_time_master (); void toggle_video_sync (); @@ -427,6 +425,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI Gtkmm2ext::StatefulToggleButton auto_input_button; Gtkmm2ext::StatefulToggleButton click_button; Gtkmm2ext::StatefulToggleButton time_master_button; + Gtkmm2ext::StatefulToggleButton sync_button; Gtk::ToggleButton auditioning_alert_button; Gtk::ToggleButton solo_alert_button; diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 7f7d46150c..60477c894f 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -127,6 +127,19 @@ ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtrconnect_proxy (play_selection_button); act = ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster")); act->connect_proxy (time_master_button); + act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync")); + act->connect_proxy (sync_button); ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead")); ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback")); @@ -239,12 +255,13 @@ ARDOUR_UI::setup_transport () ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start")); ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end")); ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click")); - ARDOUR_UI::instance()->tooltips().set_tip (sync_button, _("Positional sync source")); + ARDOUR_UI::instance()->tooltips().set_tip (sync_button, _("Enable/Disable external positional sync")); ARDOUR_UI::instance()->tooltips().set_tip (time_master_button, _("Does Ardour control the time?")); ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control")); ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display")); ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed")); + shuttle_box.set_flags (CAN_FOCUS); shuttle_box.add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK); shuttle_box.set_size_request (100, 15); @@ -331,9 +348,7 @@ ARDOUR_UI::setup_transport () sdframe->set_shadow_type (SHADOW_IN); sdframe->add (speed_display_box); - sync_button.set_name ("TransportSyncAlert"); - sync_button.signal_clicked().connect (mem_fun (*this, &ARDOUR_UI::sync_button_clicked)); - // XXX HOW TO USE set_popdown_strings() with this when we don't know the real strings till later? + /* translators: Egternal is "External" with a descender character */ set_size_request_to_display_given_text (sync_button, X_("Egternal"), 4, 10); shbox->pack_start (*sdframe, false, false); @@ -488,17 +503,22 @@ void ARDOUR_UI::sync_blink (bool onoff) { if (session == 0 || !session->config.get_external_sync()) { + /* internal sync */ + sync_button.set_visual_state (0); return; } if (!session->transport_locked()) { + /* not locked, so blink on and off according to the onoff argument */ + if (onoff) { - sync_button.set_state (STATE_ACTIVE); + sync_button.set_visual_state (1); // "-active" } else { - sync_button.set_state (STATE_NORMAL); + sync_button.set_visual_state (0); // normal } } else { - sync_button.set_state (STATE_NORMAL); + /* locked */ + sync_button.set_visual_state (1); // "-active" } } @@ -862,14 +882,6 @@ ARDOUR_UI::editor_realized () reset_dpi (); } -void -ARDOUR_UI::sync_button_clicked () -{ - if (session) { - session->config.set_external_sync (sync_button.get_active()); - } -} - void ARDOUR_UI::maximise_editing_space () { diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 3da5104f8b..ee93919ece 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -364,9 +364,12 @@ ARDOUR_UI::install_actions () ActionManager::session_sensitive_actions.push_back (act); ActionManager::transport_sensitive_actions.push_back (act); - ActionManager::register_toggle_action (transport_actions, X_("ToggleVideoSync"), _("Sync startup to video"), mem_fun(*this, &ARDOUR_UI::toggle_video_sync)); + act = ActionManager::register_toggle_action (transport_actions, X_("ToggleVideoSync"), _("Sync startup to video"), mem_fun(*this, &ARDOUR_UI::toggle_video_sync)); + ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_toggle_action (transport_actions, X_("ToggleTimeMaster"), _("Time Master"), mem_fun(*this, &ARDOUR_UI::toggle_time_master)); ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_toggle_action (transport_actions, X_("ToggleExternalSync"), _(""), mem_fun(*this, &ARDOUR_UI::toggle_external_sync)); + ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_action (common_actions, X_("ToggleRecordEnableTrack1"), _("Toggle Record Enable Track1"), bind (mem_fun(*this, &ARDOUR_UI::toggle_record_enable), 0U)); ActionManager::session_sensitive_actions.push_back (act); diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index 8f16b9578a..c00097d417 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -47,6 +47,12 @@ using namespace ARDOUR; using namespace PBD; using namespace sigc; +void +ARDOUR_UI::toggle_external_sync() +{ + ActionManager::toggle_config_state_foo ("Transport", "ToggleExternalSync", mem_fun (session->config, &SessionConfiguration::set_external_sync), mem_fun (session->config, &SessionConfiguration::get_external_sync)); +} + void ARDOUR_UI::toggle_time_master () { @@ -296,7 +302,9 @@ ARDOUR_UI::parameter_changed (std::string p) ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), p)); if (p == "external-sync") { - + + ActionManager::map_some_state ("Transport", "ToggleExternalSync", mem_fun (session->config, &SessionConfiguration::get_external_sync)); + if (!session->config.get_external_sync()) { sync_button.set_label (_("Internal")); ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true); diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h index 3a5281af0c..fb6663e3f9 100644 --- a/gtk2_ardour/option_editor.h +++ b/gtk2_ardour/option_editor.h @@ -243,6 +243,10 @@ public: } } + void set_sensitive (bool yn) { + _combo->set_sensitive (yn); + } + private: sigc::slot _get; diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index c20fbef2a6..1ce53e80aa 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -55,25 +55,25 @@ public: t->set_spacings (12); int n = 0; - Label* l = manage (new Label (_("MTC:"))); + Label* l = manage (new Label (_("Receive MTC via:"))); l->set_alignment (1, 0.5); t->attach (*l, 0, 1, n, n + 1, EXPAND | FILL, FILL); t->attach (_mtc_combo, 1, 2, n, n + 1, EXPAND | FILL, EXPAND | FILL); ++n; - l = manage (new Label (_("MIDI clock:"))); + l = manage (new Label (_("Receive MIDI clock via:"))); l->set_alignment (1, 0.5); t->attach (*l, 0, 1, n, n + 1, FILL, FILL); t->attach (_midi_clock_combo, 1, 2, n, n + 1, FILL, FILL); ++n; - l = manage (new Label (_("MMC:"))); + l = manage (new Label (_("Receive MMC via:"))); l->set_alignment (1, 0.5); t->attach (*l, 0, 1, n, n + 1, FILL, FILL); t->attach (_mmc_combo, 1, 2, n, n + 1, FILL, FILL); ++n; - l = manage (new Label (_("MIDI parameter control:"))); + l = manage (new Label (_("Receive MIDI parameter control via:"))); l->set_alignment (1, 0.5); t->attach (*l, 0, 1, n, n + 1, FILL, FILL); t->attach (_mpc_combo, 1, 2, n, n + 1, FILL, FILL); diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc index 49dbcdff15..f8f060684f 100644 --- a/gtk2_ardour/session_option_editor.cc +++ b/gtk2_ardour/session_option_editor.cc @@ -141,6 +141,82 @@ SessionOptionEditor::SessionOptionEditor (Session* s) : OptionEditor (&(s->config), _("Session Preferences")) , _session_config (&(s->config)) { + /* SYNC */ + + ComboOption* spf = new ComboOption ( + "subframes-per-frame", + _("Subframes per frame"), + mem_fun (*_session_config, &SessionConfiguration::get_subframes_per_frame), + mem_fun (*_session_config, &SessionConfiguration::set_subframes_per_frame) + ); + + spf->add (80, _("80")); + spf->add (100, _("100")); + + add_option (_("Sync"), spf); + + ComboOption* ssrc = new ComboOption ( + "sync-source", + _("External sync source"), + mem_fun (*_session_config, &SessionConfiguration::get_sync_source), + mem_fun (*_session_config, &SessionConfiguration::set_sync_source) + ); + + s->MTC_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc)); + s->MIDIClock_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc)); + s->config.ParameterChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::follow_sync_state), s, ssrc)); + + populate_sync_options (s, ssrc); + follow_sync_state (string ("external-sync"), s, ssrc); + + add_option (_("Sync"), ssrc); + + ComboOption* smf = new ComboOption ( + "timecode-format", + _("Timecode frames-per-second"), + mem_fun (*_session_config, &SessionConfiguration::get_timecode_format), + mem_fun (*_session_config, &SessionConfiguration::set_timecode_format) + ); + + smf->add (timecode_23976, _("23.976")); + smf->add (timecode_24, _("24")); + smf->add (timecode_24976, _("24.976")); + smf->add (timecode_25, _("25")); + smf->add (timecode_2997, _("29.97")); + smf->add (timecode_2997drop, _("29.97 drop")); + smf->add (timecode_30, _("30")); + smf->add (timecode_30drop, _("30 drop")); + smf->add (timecode_5994, _("59.94")); + smf->add (timecode_60, _("60")); + + add_option (_("Sync"), smf); + + add_option (_("Sync"), new BoolOption ( + "timecode-source-is-synced", + _("Timecode source is synced"), + mem_fun (*_session_config, &SessionConfiguration::get_timecode_source_is_synced), + mem_fun (*_session_config, &SessionConfiguration::set_timecode_source_is_synced) + )); + + ComboOption* vpu = new ComboOption ( + "video-pullup", + _("Pull-up / pull-down"), + mem_fun (*_session_config, &SessionConfiguration::get_video_pullup), + mem_fun (*_session_config, &SessionConfiguration::set_video_pullup) + ); + + vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%")); + vpu->add (4.1667, _("4.1667")); + vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%")); + vpu->add (0.1, _("0.1")); + vpu->add (0, _("none")); + vpu->add (-0.1, _("-0.1")); + vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%")); + vpu->add (-4.1667, _("-4.1667")); + vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%")); + + add_option (_("Sync"), vpu); + /* FADES */ ComboOption* cfm = new ComboOption ( @@ -208,79 +284,6 @@ SessionOptionEditor::SessionOptionEditor (Session* s) mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades) )); - /* SYNC */ - - ComboOption* spf = new ComboOption ( - "subframes-per-frame", - _("Subframes per frame"), - mem_fun (*_session_config, &SessionConfiguration::get_subframes_per_frame), - mem_fun (*_session_config, &SessionConfiguration::set_subframes_per_frame) - ); - - spf->add (80, _("80")); - spf->add (100, _("100")); - - add_option (_("Sync"), spf); - - ComboOption* ssrc = new ComboOption ( - "sync-source", - _("External sync source"), - mem_fun (*_session_config, &SessionConfiguration::get_sync_source), - mem_fun (*_session_config, &SessionConfiguration::set_sync_source) - ); - - s->MTC_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc)); - s->MIDIClock_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc)); - populate_sync_options (s, ssrc); - - add_option (_("Sync"), ssrc); - - ComboOption* smf = new ComboOption ( - "timecode-format", - _("Timecode frames-per-second"), - mem_fun (*_session_config, &SessionConfiguration::get_timecode_format), - mem_fun (*_session_config, &SessionConfiguration::set_timecode_format) - ); - - smf->add (timecode_23976, _("23.976")); - smf->add (timecode_24, _("24")); - smf->add (timecode_24976, _("24.976")); - smf->add (timecode_25, _("25")); - smf->add (timecode_2997, _("29.97")); - smf->add (timecode_2997drop, _("29.97 drop")); - smf->add (timecode_30, _("30")); - smf->add (timecode_30drop, _("30 drop")); - smf->add (timecode_5994, _("59.94")); - smf->add (timecode_60, _("60")); - - add_option (_("Sync"), smf); - - add_option (_("Sync"), new BoolOption ( - "timecode-source-is-synced", - _("Timecode source is synced"), - mem_fun (*_session_config, &SessionConfiguration::get_timecode_source_is_synced), - mem_fun (*_session_config, &SessionConfiguration::set_timecode_source_is_synced) - )); - - ComboOption* vpu = new ComboOption ( - "video-pullup", - _("Pull-up / pull-down"), - mem_fun (*_session_config, &SessionConfiguration::get_video_pullup), - mem_fun (*_session_config, &SessionConfiguration::set_video_pullup) - ); - - vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%")); - vpu->add (4.1667, _("4.1667")); - vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%")); - vpu->add (0.1, _("0.1")); - vpu->add (0, _("none")); - vpu->add (-0.1, _("-0.1")); - vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%")); - vpu->add (-4.1667, _("-4.1667")); - vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%")); - - add_option (_("Sync"), vpu); - /* MISC */ add_option (_("Misc"), new OptionEditorHeading (_("Audio file format"))); @@ -360,3 +363,15 @@ SessionOptionEditor::populate_sync_options (Session* s, Option* opt) } } +void +SessionOptionEditor::follow_sync_state (std::string p, Session* s, Option* opt) +{ + ComboOption* sync_opt = dynamic_cast* > (opt); + if (p == "external-sync") { + if (s->config.get_external_sync()) { + sync_opt->set_sensitive (false); + } else { + sync_opt->set_sensitive (true); + } + } +} diff --git a/gtk2_ardour/session_option_editor.h b/gtk2_ardour/session_option_editor.h index a2dc750cd2..76d69bd4b5 100644 --- a/gtk2_ardour/session_option_editor.h +++ b/gtk2_ardour/session_option_editor.h @@ -13,4 +13,5 @@ public: private: ARDOUR::SessionConfiguration* _session_config; void populate_sync_options (ARDOUR::Session*, Option*); + void follow_sync_state (std::string, ARDOUR::Session*, Option*); }; diff --git a/libs/ardour/rc_configuration.cc b/libs/ardour/rc_configuration.cc index b34a6fd1ee..f613ae1ecc 100644 --- a/libs/ardour/rc_configuration.cc +++ b/libs/ardour/rc_configuration.cc @@ -203,8 +203,6 @@ RCConfiguration::get_state () MIDI::Manager::PortMap::const_iterator i; const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports(); - cerr << "Saving " << ports.size() << " MIDI ports\n"; - for (i = ports.begin(); i != ports.end(); ++i) { root->add_child_nocopy(i->second->get_state()); } diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 34d9b470f5..1fe360e397 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -141,8 +141,6 @@ Session::set_mtc_port (string port_tag) ms->rebind (*port); } - cerr << "!!SPT to " << port_tag << endl; - Config->set_mtc_port_name (port_tag); out: