show track-number in GUI
[ardour.git] / gtk2_ardour / mixer_strip.cc
index a8ec7d5c79d971dfa12d132770d621f47596223f..005993e23d31cd787c4cdbfbe31c5e3b4dc24ca1 100644 (file)
 #include "ardour/audio_track.h"
 #include "ardour/audioengine.h"
 #include "ardour/internal_send.h"
+#include "ardour/meter.h"
 #include "ardour/midi_track.h"
 #include "ardour/pannable.h"
 #include "ardour/panner.h"
 #include "ardour/panner_shell.h"
+#include "ardour/panner_manager.h"
 #include "ardour/port.h"
 #include "ardour/profile.h"
 #include "ardour/route.h"
@@ -67,6 +69,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace ARDOUR_UI_UTILS;
 using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
@@ -89,7 +92,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
        , rec_solo_table (2, 2)
        , top_button_table (1, 2)
        , middle_button_table (1, 2)
-       , bottom_button_table (1, 2)
+       , bottom_button_table (1, 3)
        , meter_point_button (_("pre"))
        , midi_input_enable_button (0)
        , _comment_button (_("Comments"))
@@ -117,7 +120,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr<Route> rt
        , button_size_group (Gtk::SizeGroup::create (Gtk::SIZE_GROUP_HORIZONTAL))
        , button_table (3, 1)
        , middle_button_table (1, 2)
-       , bottom_button_table (1, 2)
+       , bottom_button_table (1, 3)
        , meter_point_button (_("pre"))
        , midi_input_enable_button (0)
        , _comment_button (_("Comments"))
@@ -130,6 +133,8 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr<Route> rt
 void
 MixerStrip::init ()
 {
+       int button_table_row = 0;
+
        input_selector = 0;
        output_selector = 0;
        group_menu = 0;
@@ -172,7 +177,7 @@ MixerStrip::init ()
        */
        set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
 
-       bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
+       bottom_button_table.attach (meter_point_button, 2, 3, 0, 1);
 
        meter_point_button.signal_button_press_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_press), false);
        meter_point_button.signal_button_release_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_release), false);
@@ -205,15 +210,19 @@ MixerStrip::init ()
 
        top_button_table.set_homogeneous (true);
        top_button_table.set_spacings (2);
-       top_button_table.attach (*monitor_input_button, 0, 1, 0, 1);
-        top_button_table.attach (*monitor_disk_button, 1, 2, 0, 1);
+       if (!ARDOUR::Profile->get_trx()) {
+               top_button_table.attach (*monitor_input_button, 0, 1, 0, 1);
+               top_button_table.attach (*monitor_disk_button, 1, 2, 0, 1);
+       }
        top_button_table.show ();
 
        rec_solo_table.set_homogeneous (true);
        rec_solo_table.set_row_spacings (2);
        rec_solo_table.set_col_spacings (2);
-        rec_solo_table.attach (*solo_isolated_led, 1, 2, 0, 1);
-        rec_solo_table.attach (*solo_safe_led, 1, 2, 1, 2);
+       if (!ARDOUR::Profile->get_trx()) {
+               rec_solo_table.attach (*solo_isolated_led, 1, 2, 0, 1);
+               rec_solo_table.attach (*solo_safe_led, 1, 2, 1, 2);
+       }
         rec_solo_table.show ();
 
        button_table.set_homogeneous (false);
@@ -235,17 +244,24 @@ MixerStrip::init ()
                button_size_group->add_widget (*monitor_input_button);
        }
 
-       button_table.attach (name_button, 0, 1, 0, 1);
-       button_table.attach (input_button_box, 0, 1, 1, 2);
-       button_table.attach (_invert_button_box, 0, 1, 2, 3);
+       if (!ARDOUR::Profile->get_trx()) {
+               button_table.attach (name_button, 0, 1, button_table_row, button_table_row+1);
+               button_table_row++;
+               button_table.attach (input_button_box, 0, 2, button_table_row, button_table_row+1);
+               button_table_row++;
+               button_table.attach (_invert_button_box, 0, 2, button_table_row, button_table_row+1);
+               button_table_row++;
+       }
 
        middle_button_table.set_homogeneous (true);
        middle_button_table.set_spacings (2);
 
        bottom_button_table.set_spacings (2);
-       bottom_button_table.set_homogeneous (true);
-//     bottom_button_table.attach (group_button, 0, 1, 0, 1);
-       bottom_button_table.attach (gpm.gain_automation_state_button, 0, 1, 0, 1);
+       bottom_button_table.set_homogeneous (false);
+       button_table_row = 0;
+       bottom_button_table.attach (group_button, 0, 1, button_table_row, button_table_row+1);
+       bottom_button_table.attach (gpm.gain_automation_state_button, 1, 2, button_table_row, button_table_row+1);
+       button_table_row++;
 
        name_button.set_name ("mixer strip button");
        name_button.set_text (" "); /* non empty text, forces creation of the layout */
@@ -279,17 +295,23 @@ MixerStrip::init ()
        whvbox.pack_start (width_hide_box, true, true);
 
        global_vpacker.set_spacing (2);
-       global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
-       global_vpacker.pack_start (button_table, Gtk::PACK_SHRINK);
-       global_vpacker.pack_start (processor_box, true, true);
+       if (!ARDOUR::Profile->get_trx()) {
+               global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
+               global_vpacker.pack_start (button_table, Gtk::PACK_SHRINK);
+               global_vpacker.pack_start (processor_box, true, true);
+       }
        global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
        global_vpacker.pack_start (top_button_table, Gtk::PACK_SHRINK);
        global_vpacker.pack_start (rec_solo_table, Gtk::PACK_SHRINK);
        global_vpacker.pack_start (middle_button_table, Gtk::PACK_SHRINK);
        global_vpacker.pack_start (gpm, Gtk::PACK_SHRINK);
        global_vpacker.pack_start (bottom_button_table, Gtk::PACK_SHRINK);
-       global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
-       global_vpacker.pack_start (_comment_button, Gtk::PACK_SHRINK);
+       if (!ARDOUR::Profile->get_trx()) {
+               global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
+               global_vpacker.pack_start (_comment_button, Gtk::PACK_SHRINK);
+       } else {
+               global_vpacker.pack_start (name_button, Gtk::PACK_SHRINK);
+       }
 
        global_frame.add (global_vpacker);
        global_frame.set_shadow_type (Gtk::SHADOW_IN);
@@ -358,6 +380,7 @@ MixerStrip::init ()
        parameter_changed (X_("mixer-strip-visibility"));
 
        Config->ParameterChanged.connect (_config_connection, MISSING_INVALIDATOR, boost::bind (&MixerStrip::parameter_changed, this, _1), gui_context());
+       _session->config.ParameterChanged.connect (_config_connection, MISSING_INVALIDATOR, boost::bind (&MixerStrip::parameter_changed, this, _1), gui_context());
 
        gpm.LevelMeterButtonPress.connect_same_thread (_level_meter_connection, boost::bind (&MixerStrip::level_meter_button_press, this, _1));
 }
@@ -495,6 +518,10 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt)
                rec_enable_button->set_sensitive (_session->writable());
                rec_enable_button->show();
 
+               if (ARDOUR::Profile->get_trx()) {
+                       rec_solo_table.attach (*monitor_input_button, 1, 2, 0, 2);
+               }
+
        } else {
 
                /* non-master bus */
@@ -515,7 +542,10 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt)
        _route->output()->changed.connect (*this, invalidator (*this), boost::bind (&MixerStrip::update_output_display, this), gui_context());
        _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context());
 
+       _route->io_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::io_changed_proxy, this), gui_context ());
+
        if (_route->panner_shell()) {
+               update_panner_choices();
                _route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
        }
 
@@ -988,18 +1018,11 @@ MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR
 void
 MixerStrip::update_diskstream_display ()
 {
-       if (is_track()) {
+        if (is_track() && input_selector) {
+                        input_selector->hide_all ();
+        }
 
-               if (input_selector) {
-                       input_selector->hide_all ();
-               }
-
-               route_color_changed ();
-
-       } else {
-
-               show_passthru_color ();
-       }
+        route_color_changed ();
 }
 
 void
@@ -1019,9 +1042,33 @@ MixerStrip::connect_to_pan ()
        p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
        p->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
 
-       panners.panshell_changed ();
+       /* This call reduncant, PannerUI::set_panner() connects to _panshell->Changed itself
+        * However, that only works a panner was previously set.
+        *
+        * PannerUI must remain subscribed to _panshell->Changed() in case
+        * we switch the panner eg. AUX-Send and back
+        * _route->panner_shell()->Changed() vs _panshell->Changed
+        */
+       if (panners._panner == 0) {
+               panners.panshell_changed ();
+       }
+       update_panner_choices();
 }
 
+void
+MixerStrip::update_panner_choices ()
+{
+       ENSURE_GUI_THREAD (*this, &MixerStrip::update_panner_choices)
+       if (!_route->panner_shell()) { return; }
+
+       uint32_t in = _route->output()->n_ports().n_audio();
+       uint32_t out = in;
+       if (_route->panner()) {
+               in = _route->panner()->in().n_audio();
+       }
+
+       panners.set_available_panners(PannerManager::instance().PannerManager::get_available_panners(in, out));
+}
 
 /*
  * Output port labelling
@@ -1272,6 +1319,12 @@ MixerStrip::diskstream_changed ()
        Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_diskstream_display, this));
 }
 
+void
+MixerStrip::io_changed_proxy ()
+{
+       Glib::signal_idle().connect_once (sigc::mem_fun (*this, &MixerStrip::update_panner_choices));
+}
+
 void
 MixerStrip::port_connected_or_disconnected (boost::weak_ptr<Port> wa, boost::weak_ptr<Port> wb)
 {
@@ -1475,6 +1528,7 @@ MixerStrip::build_route_ops_menu ()
        items.push_back (CheckMenuElem (_("Active")));
        Gtk::CheckMenuItem* i = dynamic_cast<Gtk::CheckMenuItem *> (&items.back());
        i->set_active (_route->active());
+       i->set_sensitive(! _session->transport_rolling());
        i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false));
 
        items.push_back (SeparatorElem());
@@ -1549,10 +1603,19 @@ MixerStrip::name_changed ()
 {
        switch (_width) {
        case Wide:
-               name_button.set_text (_route->name());
+               if (_session->config.get_track_name_number()) {
+                       name_button.set_markup(track_number_to_string (_route->track_number (), " ", _route->name ()));
+               } else {
+                       name_button.set_text (_route->name());
+               }
                break;
        case Narrow:
-               name_button.set_text (PBD::short_version (_route->name(), 5));
+               if (_session->config.get_track_name_number()) {
+                       name_button.set_markup(track_number_to_string (_route->track_number (), " ",
+                                               PBD::short_version (_route->name (), 5)));
+               } else {
+                       name_button.set_text (PBD::short_version (_route->name(), 5));
+               }
                break;
        }
 
@@ -1836,22 +1899,21 @@ MixerStrip::show_send (boost::shared_ptr<Send> send)
 
        set_current_delivery (send);
 
+       send->meter()->set_type(_route->shared_peak_meter()->get_type());
        send->set_metering (true);
        _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
 
        gain_meter().set_controls (_route, send->meter(), send->amp());
        gain_meter().setup_meters ();
 
+       uint32_t const in = _current_delivery->pans_required();
+       uint32_t const out = _current_delivery->pan_outs();
+
        panner_ui().set_panner (_current_delivery->panner_shell(), _current_delivery->panner());
+       panner_ui().set_available_panners(PannerManager::instance().PannerManager::get_available_panners(in, out));
        panner_ui().setup_pan ();
-
-       /* make sure the send has audio output */
-
-       if (_current_delivery->output() && _current_delivery->output()->n_ports().n_audio() > 0) {
-               panners.show_all ();
-       } else {
-               panners.hide_all ();
-       }
+       panner_ui().set_send_drawing_mode (true);
+       panner_ui().show_all ();
 
        input_button.set_sensitive (false);
        group_button.set_sensitive (false);
@@ -1884,7 +1946,9 @@ MixerStrip::revert_to_default_display ()
        gain_meter().setup_meters ();
 
        panner_ui().set_panner (_route->main_outs()->panner_shell(), _route->main_outs()->panner());
+       update_panner_choices();
        panner_ui().setup_pan ();
+       panner_ui().set_send_drawing_mode (false);
 
        if (has_audio_outputs ()) {
                panners.show_all ();
@@ -2025,6 +2089,9 @@ MixerStrip::parameter_changed (string p)
                */
                _visibility.set_state (Config->get_mixer_strip_visibility ());
        }
+       else if (p == "track-name-number") {
+               name_changed ();
+       }
 }
 
 /** Called to decide whether the solo isolate / solo lock button visibility should
@@ -2105,6 +2172,9 @@ MixerStrip::ab_plugins ()
 bool
 MixerStrip::level_meter_button_press (GdkEventButton* ev)
 {
+       if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
+               return false;
+       }
        if (ev->button == 3) {
                popup_level_meter_menu (ev);
                return true;
@@ -2125,8 +2195,8 @@ MixerStrip::popup_level_meter_menu (GdkEventButton* ev)
 
        _suspend_menu_callbacks = true;
        add_level_meter_item_point (items, group, _("Input"), MeterInput);
-       add_level_meter_item_point (items, group, _("Pre-fader"), MeterPreFader);
-       add_level_meter_item_point (items, group, _("Post-fader"), MeterPostFader);
+       add_level_meter_item_point (items, group, _("Pre Fader"), MeterPreFader);
+       add_level_meter_item_point (items, group, _("Post Fader"), MeterPostFader);
        add_level_meter_item_point (items, group, _("Output"), MeterOutput);
        add_level_meter_item_point (items, group, _("Custom"), MeterCustom);
 
@@ -2141,6 +2211,7 @@ MixerStrip::popup_level_meter_menu (GdkEventButton* ev)
        add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterIEC2EBU), MeterIEC2EBU);
        add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterK20), MeterK20);
        add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterK14), MeterK14);
+       add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterK12), MeterK12);
        add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterVU),  MeterVU);
 
        int _strip_type;