remove old a-Hi/Low pass
[ardour.git] / gtk2_ardour / meterbridge.cc
index 8eee194a39baf7efb7bc49188eedf552b9c66b63..02350c92bf114345012bfc95a092c4b30a1b5219 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "ardour/audio_track.h"
 #include "ardour/midi_track.h"
-#include "ardour/route_sorters.h"
 
 #include "meterbridge.h"
 
 #include "route_sorter.h"
 #include "actions.h"
 #include "gui_thread.h"
-#include "global_signals.h"
 #include "meter_patterns.h"
 #include "timers.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace ARDOUR_UI_UTILS;
@@ -104,11 +102,13 @@ Meterbridge::Meterbridge ()
        Gdk::Geometry geom;
        geom.max_width = 1<<16;
        geom.max_height = max_height;
+       geom.min_width = 40;
+       geom.min_height = -1;
        geom.height_inc = 16;
        geom.width_inc = 1;
-       set_geometry_hints(*((Gtk::Window*) this), geom, Gdk::HINT_MAX_SIZE | Gdk::HINT_RESIZE_INC);
+       assert(max_height % 16 == 0);
+       set_geometry_hints(*((Gtk::Window*) this), geom, Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_RESIZE_INC);
 
-       set_keep_above (true);
        set_border_width (0);
 
        metrics_vpacker_left.pack_start (metrics_left, true, true);
@@ -123,7 +123,6 @@ 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));
-       Route::SyncOrderKeys.connect (*this, invalidator (*this), boost::bind (&Meterbridge::sync_order_keys, this), gui_context());
        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::ConfigurationChanged.connect (*this, invalidator (*this), boost::bind(&Meterbridge::queue_resize, this), gui_context());
@@ -172,8 +171,8 @@ Meterbridge::Meterbridge ()
        viewport->set_border_width(0);
 
        UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &Meterbridge::on_theme_changed));
-       ColorsChanged.connect (sigc::mem_fun (*this, &Meterbridge::on_theme_changed));
-       DPIReset.connect (sigc::mem_fun (*this, &Meterbridge::on_theme_changed));
+       UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &Meterbridge::on_theme_changed));
+       UIConfiguration::instance().DPIReset.connect (sigc::mem_fun (*this, &Meterbridge::on_theme_changed));
 }
 
 Meterbridge::~Meterbridge ()
@@ -255,7 +254,7 @@ Meterbridge::on_key_press_event (GdkEventKey* ev)
        if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) {
                return true;
        }
-       return forward_key_press (ev);
+       return relay_key_press (ev, this);
 }
 
 bool
@@ -325,33 +324,18 @@ Meterbridge::on_size_request (Gtk::Requisition* r)
        Gtk::Requisition mr = meterarea.size_request();
 
        geom.max_width = mr.width + metrics_left.get_width() + metrics_right.get_width();
+       geom.max_width = std::max(50, geom.max_width);
        geom.max_height = max_height;
 
-#ifndef GTKOSX
-       /* on OSX this leads to a constant live-loop: show/hide scrollbar
-        * on Linux, the window is resized IFF the scrollbar was not visible
-        */
-       const Gtk::Scrollbar * hsc = scroller.get_hscrollbar();
-       Glib::RefPtr<Gdk::Screen> screen = get_screen ();
-       Gdk::Rectangle monitor_rect;
-       screen->get_monitor_geometry (0, monitor_rect);
-       const int scr_w = monitor_rect.get_width() - 44;
-
-       if (cur_max_width < geom.max_width
-                       && cur_max_width < scr_w
-                       && !(scroller.get_hscrollbar_visible() && hsc)) {
-               int h = r->height;
-               *r = Gtk::Requisition();
-               r->width = geom.max_width;
-               r->height = h;
-       }
-#endif
-
        if (cur_max_width != geom.max_width) {
                cur_max_width = geom.max_width;
+               /* height resizes are 'heavy' since the metric areas and meter-patterns
+                * are re-generated. limit to 16px steps. */
                geom.height_inc = 16;
                geom.width_inc = 1;
-               set_geometry_hints(*((Gtk::Window*) this), geom, Gdk::HINT_MAX_SIZE | Gdk::HINT_RESIZE_INC);
+               geom.min_width = 40;
+               geom.min_height = -1;
+               set_geometry_hints(*((Gtk::Window*) this), geom, Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_RESIZE_INC);
        }
 }
 
@@ -360,6 +344,7 @@ Meterbridge::on_size_allocate (Gtk::Allocation& a)
 {
        const Gtk::Scrollbar * hsc = scroller.get_hscrollbar();
 
+       /* switch left/right edge patterns depending on horizontal scroll-position */
        if (scroller.get_hscrollbar_visible() && hsc) {
                if (!scroll_connection.connected()) {
                        scroll_connection = scroller.get_hscrollbar()->get_adjustment()->signal_value_changed().connect(sigc::mem_fun (*this, &Meterbridge::on_scroll));
@@ -413,6 +398,22 @@ 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)
 {
@@ -435,12 +436,11 @@ Meterbridge::set_session (Session* s)
        _show_master = _session->config.get_show_master_on_meterbridge();
        _show_midi = _session->config.get_show_midi_on_meterbridge();
 
-       ARDOUR::SignalOrderRouteSorter sorter;
        boost::shared_ptr<RouteList> routes = _session->get_routes();
 
-       RouteList copy(*routes);
-       copy.sort(sorter);
-       add_strips(copy);
+       RouteList copy (*routes);
+       copy.sort (PresentationInfoRouteSorter());
+       add_strips (copy);
 
        _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::add_strips, this, _1), gui_context());
        _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::update_title, this), gui_context());
@@ -450,7 +450,7 @@ Meterbridge::set_session (Session* s)
 
        if (_visible) {
                show_window();
-               ActionManager::check_toggleaction ("<Actions>/Common/toggle-meterbridge");
+               present ();
        }
        start_updating ();
 }
@@ -476,7 +476,7 @@ Meterbridge::session_going_away ()
 int
 Meterbridge::set_state (const XMLNode& node)
 {
-       const XMLProperty* prop;
+       XMLProperty const * prop;
        XMLNode* geometry;
 
        m_width = default_width;
@@ -486,7 +486,7 @@ Meterbridge::set_state (const XMLNode& node)
 
        if ((geometry = find_named_node (node, "geometry")) != 0) {
 
-               XMLProperty* prop;
+               XMLProperty const * prop;
 
                if ((prop = geometry->property("x_size")) == 0) {
                        prop = geometry->property ("x-size");