Use conf.fatal for fatal configuration errors
[ardour.git] / gtk2_ardour / meterbridge.cc
index e032792024b141b363c08f8daa6bcda867069d73..c40a90280dd52dc4b90f7d3fcb9bc7af1bbdb507 100644 (file)
@@ -1,22 +1,22 @@
 /*
-    Copyright (C) 2012 Paul Davis
-    Author: Robin Gareus
-
-    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) 2013-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2014-2017 Tim Mayberry <mojofunk@gmail.com>
+ * Copyright (C) 2015-2016 Paul Davis <paul@linuxaudiosystems.com>
+ *
* 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.
+ */
 
 #ifdef WAF_BUILD
 #include "gtk2ardour-config.h"
@@ -26,6 +26,7 @@
 #include <sigc++/bind.h>
 
 #include <gtkmm/accelmap.h>
+#include <gtkmm/comboboxtext.h>
 
 #include <glibmm/threads.h>
 
@@ -134,8 +135,9 @@ Meterbridge::Meterbridge ()
        signal_delete_event().connect (sigc::mem_fun (*this, &Meterbridge::hide_window));
        signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
        MeterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Meterbridge::remove_strip, this, _1), gui_context());
-       MeterStrip::MetricChanged.connect (*this, invalidator (*this), boost::bind(&Meterbridge::resync_order, this), gui_context());
+       MeterStrip::MetricChanged.connect (*this, invalidator (*this), boost::bind(&Meterbridge::sync_order_keys, this), gui_context());
        MeterStrip::ConfigurationChanged.connect (*this, invalidator (*this), boost::bind(&Meterbridge::queue_resize, this), gui_context());
+       PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Meterbridge::resync_order, this, _1), gui_context());
 
        /* work around ScrolledWindowViewport alignment mess Part one */
        Gtk::HBox * yspc = manage (new Gtk::HBox());
@@ -408,22 +410,6 @@ Meterbridge::on_scroll()
        metrics_right.set_metric_mode(mm_right, mt_right);
 }
 
-struct PresentationInfoRouteSorter
-{
-       bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
-               if (a->is_master() || a->is_monitor()) {
-                       /* "a" is a special route (master, monitor, etc), and comes
-                        * last in the mixer ordering
-                        */
-                       return false;
-               } else if (b->is_master() || b->is_monitor()) {
-                       /* everything comes before b */
-                       return true;
-               }
-               return a->presentation_info().order() < b->presentation_info().order();
-       }
-};
-
 void
 Meterbridge::set_session (Session* s)
 {
@@ -446,10 +432,8 @@ Meterbridge::set_session (Session* s)
        _show_master = _session->config.get_show_master_on_meterbridge();
        _show_midi = _session->config.get_show_midi_on_meterbridge();
 
-       boost::shared_ptr<RouteList> routes = _session->get_routes();
-
-       RouteList copy (*routes);
-       copy.sort (PresentationInfoRouteSorter());
+       RouteList copy = _session->get_routelist ();
+       copy.sort (Stripable::Sorter (true));
        add_strips (copy);
 
        _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::add_strips, this, _1), gui_context());
@@ -494,19 +478,10 @@ Meterbridge::set_state (const XMLNode& node)
        m_root_y = 1;
 
        if ((geometry = find_named_node (node, "geometry")) != 0) {
-
-               if (!geometry->get_property ("x_size", m_width)) {
-                       geometry->get_property ("x-size", m_width);
-               }
-               if (!geometry->get_property("y_size", m_height)) {
-                       geometry->get_property ("y-size", m_height);
-               }
-               if (!geometry->get_property ("x_pos", m_root_x)) {
-                       geometry->get_property ("x-pos", m_root_x);
-               }
-               if (!geometry->get_property ("y_pos", m_root_y)) {
-                       geometry->get_property ("y-pos", m_root_y);
-               }
+               geometry->get_property ("x-size", m_width);
+               geometry->get_property ("y-size", m_height);
+               geometry->get_property ("x-pos", m_root_x);
+               geometry->get_property ("y-pos", m_root_y);
        }
 
        set_window_pos_and_size ();
@@ -578,7 +553,7 @@ Meterbridge::add_strips (RouteList& routes)
 
                strip = new MeterStrip (_session, route);
                strips.push_back (MeterBridgeStrip(strip));
-               route->active_changed.connect (*this, invalidator (*this), boost::bind (&Meterbridge::resync_order, this), gui_context ());
+               route->active_changed.connect (*this, invalidator (*this), boost::bind (&Meterbridge::sync_order_keys, this), gui_context ());
 
                meterarea.pack_start (*strip, false, false);
                strip->show();
@@ -743,9 +718,11 @@ Meterbridge::sync_order_keys ()
 }
 
 void
-Meterbridge::resync_order()
+Meterbridge::resync_order (PropertyChange what_changed)
 {
-       sync_order_keys();
+       if (what_changed.contains (ARDOUR::Properties::order)) {
+               sync_order_keys();
+       }
 }
 
 void