diff --git a/gtk2_ardour/application_bar.cc b/gtk2_ardour/application_bar.cc index 123f9e5a0c..b799a76b92 100644 --- a/gtk2_ardour/application_bar.cc +++ b/gtk2_ardour/application_bar.cc @@ -107,6 +107,8 @@ static const gchar *_record_mode_strings[] = { 0 }; +#define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale())) + ApplicationBar::ApplicationBar () : _have_layout (false) , _basic_ui (0) @@ -126,13 +128,27 @@ ApplicationBar::on_parent_changed (Gtk::Widget*) _transport_ctrl.setup (ARDOUR_UI::instance ()); _transport_ctrl.map_actions (); + /* sync_button */ + Glib::RefPtr act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync")); + _sync_button.set_related_action (act); + _sync_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ApplicationBar::sync_button_clicked), false); + _sync_button.set_sizing_text (S_("LogestSync|M-Clk")); + + /* sub-layout for Sync | Shuttle (grow) */ + HBox* ssbox = manage (new HBox); + ssbox->set_spacing (PX_SCALE(2)); + ssbox->pack_start (_sync_button, false, false, 0); + ssbox->pack_start (_shuttle_box, true, true, 0); + ssbox->pack_start (*_shuttle_box.vari_button(), false, false, 0); + ssbox->pack_start (*_shuttle_box.info_button(), false, false, 0); + int vpadding = 1; int hpadding = 2; int col = 0; #define TCOL col, col + 1 _table.attach (_transport_ctrl, TCOL, 0, 1 , SHRINK, SHRINK, 0, 0); -// _table.attach (*ssbox, TCOL, 1, 2 , FILL, SHRINK, 0, 0); + _table.attach (*ssbox, TCOL, 1, 2 , FILL, SHRINK, 0, 0); ++col; @@ -140,8 +156,21 @@ ApplicationBar::on_parent_changed (Gtk::Widget*) _table.set_spacings (0); _table.set_row_spacings (4); _table.set_border_width (1); + _table.show_all(); //TODO: update visibility somewhere else pack_start(_table, false, false); + + /*sizing */ + Glib::RefPtr button_height_size_group = ARDOUR_UI::instance()->button_height_size_group; + button_height_size_group->add_widget (_transport_ctrl.size_button ()); + button_height_size_group->add_widget (_sync_button); + + /* theming */ + _sync_button.set_name ("transport active option button"); + + set_transport_sensitivity (false); } +#undef PX_SCALE +#undef TCOL void ApplicationBar::set_session (Session *s) @@ -149,10 +178,154 @@ ApplicationBar::set_session (Session *s) SessionHandlePtr::set_session (s); _transport_ctrl.set_session (s); + _shuttle_box.set_session (s); if (_basic_ui) { delete _basic_ui; } + map_transport_state (); + + if (!_session) { + _blink_connection.disconnect (); + + return; + } + _basic_ui = new BasicUI (*s); + + _session->AuditionActive.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ApplicationBar::auditioning_changed, this, _1), gui_context()); + _session->TransportStateChange.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ApplicationBar::map_transport_state, this), gui_context()); + + _blink_connection = Timers::blink_connect (sigc::mem_fun(*this, &ApplicationBar::blink_handler)); +} + +void +ApplicationBar::set_transport_sensitivity (bool yn) +{ + ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn); + _shuttle_box.set_sensitive (yn); +} + + +void +ApplicationBar::_auditioning_changed (bool onoff) +{ +// auditioning_alert_button.set_active (onoff); +// auditioning_alert_button.set_sensitive (onoff); +// if (!onoff) { +// auditioning_alert_button.set_visual_state (Gtkmm2ext::NoVisualState); +// } + set_transport_sensitivity (!onoff); +} + +void +ApplicationBar::auditioning_changed (bool onoff) +{ + UI::instance()->call_slot (MISSING_INVALIDATOR, std::bind (&ApplicationBar::_auditioning_changed, this, onoff)); +} + + +void +ApplicationBar::parameter_changed (std::string p) +{ + if (p == "external-sync") { + + if (!_session->config.get_external_sync()) { + _sync_button.set_text (S_("SyncSource|Int.")); + } else { + } + + } else if (p == "sync-source") { + if (_session) { + if (!_session->config.get_external_sync()) { + _sync_button.set_text (S_("SyncSource|Int.")); + } else { + _sync_button.set_text (TransportMasterManager::instance().current()->display_name()); + } + } else { + /* changing sync source without a session is unlikely/impossible , except during startup */ + _sync_button.set_text (TransportMasterManager::instance().current()->display_name()); + } + if (_session->config.get_video_pullup() == 0.0f || TransportMasterManager::instance().current()->type() != Engine) { + UI::instance()->set_tip (_sync_button, _("Enable/Disable external positional sync")); + } else { + UI::instance()->set_tip (_sync_button, _("External sync is not possible: video pull up/down is set")); + } + } +} + + +bool +ApplicationBar::sync_button_clicked (GdkEventButton* ev) +{ + if (ev->button != 3) { + /* this handler is just for button-3 clicks */ + return false; + } + + Glib::RefPtr tact = ActionManager::get_toggle_action ("Window", "toggle-transport-masters"); + tact->set_active(); + return true; +} + +void +ApplicationBar::sync_blink (bool onoff) +{ + if (_session == 0 || !_session->config.get_external_sync()) { + /* internal sync */ + _sync_button.set_active (false); + return; + } + + if (!_session->transport_locked()) { + /* not locked, so blink on and off according to the onoff argument */ + + if (onoff) { + _sync_button.set_active (true); + } else { + _sync_button.set_active (false); + } + } else { + /* locked */ + _sync_button.set_active (true); + } +} + +void +ApplicationBar::blink_handler (bool blink_on) +{ + sync_blink (blink_on); + +#if 0 + if (UIConfiguration::instance().get_no_strobe() || !UIConfiguration::instance().get_blink_alert_indicators()) { + blink_on = true; + } + error_blink (blink_on); + solo_blink (blink_on); + audition_blink (blink_on); + feedback_blink (blink_on); +#endif +} + +void +ApplicationBar::map_transport_state () +{ + _shuttle_box.map_transport_state (); + +/* if (!_session) { + record_mode_selector.set_sensitive (false); + return; + } + + float sp = _session->transport_speed(); + + if (sp != 0.0f) { + record_mode_selector.set_sensitive (!_session->actively_recording ()); + } else { + record_mode_selector.set_sensitive (true); + update_disk_space (); + } + +*/ } diff --git a/gtk2_ardour/application_bar.h b/gtk2_ardour/application_bar.h index 2c8a976dcb..cc3148339b 100644 --- a/gtk2_ardour/application_bar.h +++ b/gtk2_ardour/application_bar.h @@ -61,8 +61,25 @@ public: private: void on_parent_changed (Gtk::Widget*); - bool _have_layout; - BasicUI* _basic_ui; - Gtk::Table _table; - TransportControlUI _transport_ctrl; + bool sync_button_clicked (GdkEventButton*); + void parameter_changed (std::string); + + void map_transport_state (); + void set_transport_sensitivity (bool); + + void auditioning_changed (bool); + void _auditioning_changed (bool); + + /* blinking alerts */ + void sync_blink (bool); + void blink_handler (bool); + + bool _have_layout; + BasicUI* _basic_ui; + Gtk::Table _table; + TransportControlUI _transport_ctrl; + ShuttleControl _shuttle_box; + ArdourWidgets::ArdourButton _sync_button; + + sigc::connection _blink_connection; }; diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 0bad2561c1..842f011a2f 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -392,6 +392,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) _exit (EXIT_SUCCESS); } + button_height_size_group = SizeGroup::create (Gtk::SIZE_GROUP_VERTICAL); if (theArdourUI == 0) { theArdourUI = this; @@ -971,9 +972,6 @@ ARDOUR_UI::set_transport_controllable_state (const XMLNode& node) if (node.get_property ("rec", str)) { rec_controllable->set_id (str); } - if (node.get_property ("shuttle", str)) { - shuttle_box.controllable()->set_id (str); - } } XMLNode& @@ -988,7 +986,6 @@ ARDOUR_UI::get_transport_controllable_state () node->set_property (X_("auto-loop"), auto_loop_controllable->id()); node->set_property (X_("play-selection"), play_selection_controllable->id()); node->set_property (X_("rec"), rec_controllable->id()); - node->set_property (X_("shuttle"), shuttle_box.controllable()->id()); return *node; } @@ -2171,8 +2168,6 @@ ARDOUR_UI::map_transport_state () return; } - shuttle_box.map_transport_state (); - float sp = _session->transport_speed(); if (sp != 0.0f) { @@ -2189,15 +2184,10 @@ ARDOUR_UI::map_transport_state () void ARDOUR_UI::blink_handler (bool blink_on) { - sync_blink (blink_on); - if (UIConfiguration::instance().get_no_strobe() || !UIConfiguration::instance().get_blink_alert_indicators()) { blink_on = true; } error_blink (blink_on); - solo_blink (blink_on); - audition_blink (blink_on); - feedback_blink (blink_on); } void diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index a4b9c55ab1..94a7b02018 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -305,6 +306,8 @@ public: void xrun_handler (samplepos_t); void create_xrun_marker (samplepos_t); + Glib::RefPtr button_height_size_group; + GUIObjectState* gui_object_state; MainClock* primary_clock; @@ -561,7 +564,6 @@ private: Gtk::Label io_latency_label; Gtk::Label io_latency_value; - ShuttleControl shuttle_box; MiniTimeline mini_timeline; TimeInfoBox* time_info_box; @@ -571,7 +573,6 @@ private: ArdourWidgets::ArdourButton auto_return_button; ArdourWidgets::ArdourButton follow_edits_button; - ArdourWidgets::ArdourButton sync_button; ArdourWidgets::ArdourButton auditioning_alert_button; ArdourWidgets::ArdourButton solo_alert_button; @@ -595,7 +596,6 @@ private: void cancel_solo (); void solo_blink (bool); - void sync_blink (bool); void audition_blink (bool); void feedback_blink (bool); void error_blink (bool); @@ -675,7 +675,6 @@ private: void edit_metadata (); void import_metadata (); - void set_transport_sensitivity (bool); void set_punch_sensitivity (); //stuff for ProTools-style numpad @@ -871,7 +870,6 @@ private: int ambiguous_file (std::string file, std::vector hits); bool click_button_clicked (GdkEventButton *); - bool sync_button_clicked (GdkEventButton *); VisibilityGroup _status_bar_visibility; diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index de469053fc..83880af382 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -323,12 +323,6 @@ ARDOUR_UI::setup_transport () RefPtr act; /* setup actions */ - act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync")); - sync_button.set_related_action (act); - sync_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::sync_button_clicked), false); - - sync_button.set_sizing_text (S_("LogestSync|M-Clk")); - /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */ act = ActionManager::get_action (X_("Main"), X_("cancel-solo")); solo_alert_button.set_related_action (act); @@ -441,8 +435,6 @@ ARDOUR_UI::setup_transport () monitor_mono_button.set_elements (ArdourButton::Element(ArdourButton::Body|ArdourButton::Text)); monitor_mute_button.set_elements (ArdourButton::Element(ArdourButton::Body|ArdourButton::Text)); - sync_button.set_name ("transport active option button"); - /* and widget text */ auto_return_button.set_text(_("Auto Return")); follow_edits_button.set_text(_("Follow Range")); @@ -546,14 +538,12 @@ ARDOUR_UI::setup_transport () monitor_box->pack_start (monitor_mute_button, true, true); /* clock button size groups */ - Glib::RefPtr button_height_size_group = SizeGroup::create (Gtk::SIZE_GROUP_VERTICAL); button_height_size_group->add_widget (follow_edits_button); button_height_size_group->add_widget (*primary_clock->left_btn()); button_height_size_group->add_widget (*primary_clock->right_btn()); button_height_size_group->add_widget (*secondary_clock->left_btn()); button_height_size_group->add_widget (*secondary_clock->right_btn()); - button_height_size_group->add_widget (sync_button); button_height_size_group->add_widget (auto_return_button); //tab selections @@ -583,22 +573,13 @@ ARDOUR_UI::setup_transport () clock2_size_group->add_widget (*secondary_clock->left_btn()); clock2_size_group->add_widget (*secondary_clock->right_btn()); - /* sub-layout for Sync | Shuttle (grow) */ - HBox* ssbox = manage (new HBox); - ssbox->set_spacing (PX_SCALE(2)); - ssbox->pack_start (sync_button, false, false, 0); - ssbox->pack_start (shuttle_box, true, true, 0); - ssbox->pack_start (*shuttle_box.vari_button(), false, false, 0); - ssbox->pack_start (*shuttle_box.info_button(), false, false, 0); - /* and the main table layout */ int vpadding = 1; int hpadding = 2; int col = 0; #define TCOL col, col + 1 - transport_table.attach (*application_bar, TCOL, 0, 1 , SHRINK, SHRINK, 0, 0); - transport_table.attach (*ssbox, TCOL, 1, 2 , FILL, SHRINK, 0, 0); + transport_table.attach (*application_bar, TCOL, 0, 2 , EXPAND|FILL, EXPAND|FILL, 3, 0); ++col; transport_table.attach (*(manage (new ArdourVSpacer ())), TCOL, 0, 2 , SHRINK, EXPAND|FILL, 3, 0); @@ -710,13 +691,10 @@ ARDOUR_UI::setup_transport () feedback_alert_button.set_visual_state (Gtkmm2ext::NoVisualState); auditioning_alert_button.set_sensitive (false); auditioning_alert_button.set_visual_state (Gtkmm2ext::NoVisualState); - - set_transport_sensitivity (false); } #undef PX_SCALE #undef TCOL - void ARDOUR_UI::latency_switch_changed () { @@ -773,7 +751,6 @@ ARDOUR_UI::_auditioning_changed (bool onoff) if (!onoff) { auditioning_alert_button.set_visual_state (Gtkmm2ext::NoVisualState); } - set_transport_sensitivity (!onoff); } void @@ -835,29 +812,6 @@ ARDOUR_UI::solo_blink (bool onoff) } } -void -ARDOUR_UI::sync_blink (bool onoff) -{ - if (_session == 0 || !_session->config.get_external_sync()) { - /* internal sync */ - sync_button.set_active (false); - return; - } - - if (!_session->transport_locked()) { - /* not locked, so blink on and off according to the onoff argument */ - - if (onoff) { - sync_button.set_active (true); - } else { - sync_button.set_active (false); - } - } else { - /* locked */ - sync_button.set_active (true); - } -} - void ARDOUR_UI::audition_blink (bool onoff) { @@ -925,12 +879,6 @@ ARDOUR_UI::error_blink (bool onoff) break; } } -void -ARDOUR_UI::set_transport_sensitivity (bool yn) -{ - ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn); - shuttle_box.set_sensitive (yn); -} void ARDOUR_UI::set_punch_sensitivity () @@ -1005,19 +953,6 @@ ARDOUR_UI::click_button_clicked (GdkEventButton* ev) return true; } -bool -ARDOUR_UI::sync_button_clicked (GdkEventButton* ev) -{ - if (ev->button != 3) { - /* this handler is just for button-3 clicks */ - return false; - } - - Glib::RefPtr tact = ActionManager::get_toggle_action ("Window", "toggle-transport-masters"); - tact->set_active(); - return true; -} - void ARDOUR_UI::toggle_follow_edits () { diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 8839804fb3..83cec242a9 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -157,7 +157,6 @@ ARDOUR_UI::set_session (Session *s) AutomationWatch::instance().set_session (s); - shuttle_box.set_session (s); mini_timeline.set_session (s); time_info_box->set_session (s); diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index 9be798cb88..05b51cac21 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -323,7 +323,6 @@ ARDOUR_UI::parameter_changed (std::string p) ActionManager::map_some_state ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync)); if (!_session->config.get_external_sync()) { - sync_button.set_text (S_("SyncSource|Int.")); ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true); ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true); ActionManager::get_action ("Transport", "ToggleFollowEdits")->set_sensitive (true); @@ -339,19 +338,6 @@ ARDOUR_UI::parameter_changed (std::string p) } else if (p == "sync-source") { - /* app parameter (RC config) */ - - if (_session) { - if (!_session->config.get_external_sync()) { - sync_button.set_text (S_("SyncSource|Int.")); - } else { - sync_button.set_text (TransportMasterManager::instance().current()->display_name()); - } - } else { - /* changing sync source without a session is unlikely/impossible , except during startup */ - sync_button.set_text (TransportMasterManager::instance().current()->display_name()); - } - } else if (p == "follow-edits") { ActionManager::map_some_state ("Transport", "ToggleFollowEdits", &UIConfiguration::get_follow_edits); @@ -566,14 +552,10 @@ ARDOUR_UI::synchronize_sync_source_and_video_pullup () { Glib::RefPtr act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync")); - if (!act) { + if (!act || !_session) { return; } - if (!_session) { - goto just_label; - } - if (_session->config.get_video_pullup() == 0.0f) { /* with no video pull up/down, any sync source is OK */ act->set_sensitive (true); @@ -585,17 +567,4 @@ ARDOUR_UI::synchronize_sync_source_and_video_pullup () act->set_sensitive (true); } } - - /* XXX should really be able to set the video pull up - action to insensitive/sensitive, but there is no action. - FIXME - */ - - just_label: - if (act->get_sensitive ()) { - set_tip (sync_button, _("Enable/Disable external positional sync")); - } else { - set_tip (sync_button, _("Sync to JACK is not possible: video pull up/down is set")); - } - }