Fix formatting samplecnt_t (aka int64_t aka long long int)
[ardour.git] / gtk2_ardour / vca_time_axis.cc
index 39ce9c0aa0c345fb40c66b5b77285939ce1cf14c..5ff95138948be5e2851b27bb485d5ea4b229f1c0 100644 (file)
@@ -1,21 +1,21 @@
 /*
-    Copyright (C) 2016 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.org>
+ *
* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <gtkmm/menu.h>
 
 #include "ardour/vca.h"
 
 #include "gtkmm2ext/doi.h"
-#include <gtkmm2ext/utils.h>
+#include "gtkmm2ext/utils.h"
+#include "widgets/tooltips.h"
 
 #include "gui_thread.h"
 #include "public_editor.h"
-#include "tooltips.h"
+#include "mixer_ui.h"
 #include "ui_config.h"
 #include "vca_time_axis.h"
 
 #include "pbd/i18n.h"
 
 using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace PBD;
@@ -50,6 +51,10 @@ VCATimeAxisView::VCATimeAxisView (PublicEditor& ed, Session* s, ArdourCanvas::Ca
        , gain_meter (s, true, 75, 14) // XXX stupid magic numbers, match sizes in RouteTimeAxisView
        , automation_action_menu (0)
 {
+
+       controls_base_selected_name = X_("ControlMasterBaseSelected");
+       controls_base_unselected_name = X_("ControlMasterBaseUnselected");
+
        solo_button.set_name ("solo button");
        set_tooltip (solo_button, _("Solo slaves"));
        solo_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::solo_release), false);
@@ -78,11 +83,26 @@ VCATimeAxisView::VCATimeAxisView (PublicEditor& ed, Session* s, ArdourCanvas::Ca
        drop_button.set_tweaks(ArdourButton::TrackHeader);
        automation_button.set_tweaks(ArdourButton::TrackHeader);
 
-       controls_table.attach (mute_button, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       controls_table.attach (solo_button, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       controls_table.attach (automation_button, 2, 3, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       controls_table.attach (drop_button, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       controls_table.attach (gain_meter.get_gain_slider(), 0, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 1, 0);
+       if (ARDOUR::Profile->get_mixbus()) {
+               controls_button_size_group->add_widget(mute_button);
+
+               Gtk::Fixed *blank = manage(new Gtk::Fixed());
+               controls_button_size_group->add_widget(*blank);
+               controls_table.attach (*blank, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               blank->show();
+
+               controls_table.attach (mute_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (solo_button, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (automation_button, 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (drop_button, 2, 3, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (gain_meter.get_gain_slider(), 3, 5, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 1, 0);
+       } else {
+               controls_table.attach (mute_button, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (solo_button, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (automation_button, 2, 3, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (drop_button, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (gain_meter.get_gain_slider(), 0, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 1, 0);
+       }
 
        mute_button.show ();
        solo_button.show ();
@@ -90,8 +110,10 @@ VCATimeAxisView::VCATimeAxisView (PublicEditor& ed, Session* s, ArdourCanvas::Ca
        automation_button.show ();
        gain_meter.get_gain_slider().show ();
 
-       controls_ebox.set_name ("ControlMasterBaseUnselected");
-       time_axis_frame.set_name ("ControlMasterBaseUnselected");
+       controls_ebox.set_name (controls_base_unselected_name);
+       time_axis_frame.set_name (controls_base_unselected_name);
+
+       s->MonitorBusAddedOrRemoved.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::set_button_names, this), gui_context());
 
        s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
        Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
@@ -100,6 +122,8 @@ VCATimeAxisView::VCATimeAxisView (PublicEditor& ed, Session* s, ArdourCanvas::Ca
 
 VCATimeAxisView::~VCATimeAxisView ()
 {
+       delete automation_action_menu;
+       CatchDeletion (this);
 }
 
 void
@@ -115,7 +139,7 @@ VCATimeAxisView::parameter_changed (std::string const & p)
 {
        if (p == "track-name-number") {
                update_track_number_visibility();
-       } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
+       } else if (p == "solo-control-is-listen-control" || p == "listen-position") {
                set_button_names ();
        }
 }
@@ -195,6 +219,13 @@ VCATimeAxisView::update_vca_name ()
        name_label.set_text (_vca->full_name());
 }
 
+bool
+VCATimeAxisView::name_entry_changed (std::string const& str)
+{
+       _vca->set_name (str);
+       return true;
+}
+
 void
 VCATimeAxisView::update_mute_display ()
 {
@@ -319,13 +350,23 @@ VCATimeAxisView::stripable () const
 Gdk::Color
 VCATimeAxisView::color () const
 {
-       return gdk_color_from_rgb (_vca->presentation_info().color ());
+       return ARDOUR_UI_UTILS::gdk_color_from_rgb (_vca->presentation_info().color ());
 }
 
 void
 VCATimeAxisView::set_height (uint32_t h, TrackHeightMode m)
 {
        TimeAxisView::set_height (h, m);
+       if (height >= preset_height (HeightNormal)) {
+               drop_button.show ();
+               automation_button.show ();
+               gain_meter.get_gain_slider().show ();
+       } else {
+               drop_button.hide ();
+               automation_button.hide ();
+               gain_meter.get_gain_slider().hide ();
+       }
+
        set_gui_property ("height", h);
        _vca->gui_changed ("track_height", (void*) 0); /* EMIT SIGNAL */
 }
@@ -401,6 +442,32 @@ VCATimeAxisView::create_automation_child (const Evoral::Parameter& param, bool s
        }
 }
 
+void
+VCATimeAxisView::build_display_menu ()
+{
+       using namespace Menu_Helpers;
+       /* prepare it */
+       TimeAxisView::build_display_menu ();
+
+       MenuList& items = display_menu->items();
+       items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &VCATimeAxisView::choose_color)));
+       if (_size_menu) {
+               detach_menu (*_size_menu);
+       }
+       build_size_menu ();
+       items.push_back (MenuElem (_("Height"), *_size_menu));
+       items.push_back (SeparatorElem());
+
+       build_automation_action_menu (true);
+       items.push_back (MenuElem (_("Automation"), *automation_action_menu));
+
+       items.push_back (SeparatorElem());
+       items.push_back (MenuElem (_("Drop All Slaves"), sigc::mem_fun (*this, &VCATimeAxisView::drop_all_slaves)));
+       items.push_back (SeparatorElem());
+       items.push_back (MenuElem (_("Remove"), sigc::mem_fun(_editor, &PublicEditor::remove_tracks)));
+}
+
+
 void
 VCATimeAxisView::build_automation_action_menu (bool for_selection)
 {
@@ -482,3 +549,18 @@ VCATimeAxisView::hide_all_automation (bool apply_to_selection)
        no_redraw = false;
        request_redraw ();
 }
+
+void
+VCATimeAxisView::drop_all_slaves ()
+{
+       _vca->Drop (); /* EMIT SIGNAL */
+
+       if (Mixer_UI::instance()->showing_spill_for (_vca)) {
+               Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
+       }
+}
+
+void
+VCATimeAxisView::choose_color () {
+       _color_picker.popup (_vca);
+}