Use labs() for long instead of abs()
[ardour.git] / gtk2_ardour / control_slave_ui.cc
index 0223b00003483541fe61d94b935470a8436055e7..306b7c495b007f3ab2a0a4c01c29a87e466c53db 100644 (file)
@@ -1,20 +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) 2016-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 <string>
 
 #include "gtkmm2ext/gtk_ui.h"
 #include "gtkmm2ext/utils.h"
 
-#include "ardour_button.h"
 #include "control_slave_ui.h"
 #include "gui_thread.h"
 
 #include "pbd/i18n.h"
 
 using namespace ARDOUR;
+using namespace ArdourWidgets;
 using namespace Gtk;
 using std::string;
 
@@ -102,7 +103,7 @@ ControlSlaveUI::update_vca_display ()
 
        if (stripable) {
                for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
-                       if (stripable->gain_control()->slaved_to ((*v)->gain_control())) {
+                       if (stripable->slaved_to (*v)) {
                                add_vca_button (*v);
                                any = true;
                        }
@@ -111,6 +112,7 @@ ControlSlaveUI::update_vca_display ()
 
        if (!any) {
                pack_start (initial_button, true, true);
+               initial_button.show ();
        }
 
        show ();
@@ -134,7 +136,7 @@ ControlSlaveUI::vca_menu_toggle (Gtk::CheckMenuItem* menuitem, uint32_t n)
        if (!menuitem->get_active()) {
                sl->unassign (vca);
        } else {
-               sl->assign (vca, false);
+               sl->assign (vca);
        }
 }
 
@@ -190,23 +192,15 @@ ControlSlaveUI::vca_button_release (GdkEventButton* ev, uint32_t n)
 
        for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
 
-               boost::shared_ptr<GainControl> gcs = stripable->gain_control();
-               boost::shared_ptr<GainControl> gcm = (*v)->gain_control();
-
-               if (gcs == gcm) {
-                       /* asked to slave to self. not ok */
-                       continue;
-               }
-
-               if (gcm->slaved_to (gcs)) {
-                       /* master is already slaved to slave */
+               if (stripable->assigned_to (_session->vca_manager_ptr (), *v)) {
+                       /* master(stripable) is directly or indirectly controlled by slave (v) */
                        continue;
                }
 
                items.push_back (CheckMenuElem ((*v)->name()));
                Gtk::CheckMenuItem* item = dynamic_cast<Gtk::CheckMenuItem*> (&items.back());
 
-               if (gcs->slaved_to (gcm)) {
+               if (stripable->slaved_to (*v)) {
                        item->set_active (true);
                        slaved = true;
                }