X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmeterbridge.cc;h=08604b062021964ff91f40c14f1d1254bf7eba19;hb=c5252599bc958b3adba0b59223ce86ed227504b1;hp=4d2a0c7b3b0e8c4861455944e3ae6ea80443ac49;hpb=8648a8a13b04549362f14a0738947d997ef1abc7;p=ardour.git diff --git a/gtk2_ardour/meterbridge.cc b/gtk2_ardour/meterbridge.cc index 4d2a0c7b3b..08604b0620 100644 --- a/gtk2_ardour/meterbridge.cc +++ b/gtk2_ardour/meterbridge.cc @@ -40,6 +40,7 @@ #include "ardour/audio_track.h" #include "ardour/midi_track.h" +#include "ardour/route_sorters.h" #include "meterbridge.h" @@ -53,10 +54,12 @@ #include "gui_thread.h" #include "global_signals.h" #include "meter_patterns.h" +#include "timers.h" #include "i18n.h" using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; using namespace PBD; using namespace Gtk; using namespace Glib; @@ -78,24 +81,6 @@ Meterbridge::instance () return _instance; } -/* copy from gtk2_ardour/mixer_ui.cc -- TODO consolidate - * used by Meterbridge::set_session() below - */ -struct SignalOrderRouteSorter { - bool operator() (boost::shared_ptr a, boost::shared_ptr 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->order_key () < b->order_key (); - } -}; - Meterbridge::Meterbridge () : Window (Gtk::WINDOW_TOPLEVEL) , VisibilityTracker (*((Gtk::Window*) this)) @@ -119,9 +104,12 @@ 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); @@ -340,33 +328,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 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); } } @@ -375,6 +348,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)); @@ -408,7 +382,7 @@ Meterbridge::on_scroll() ARDOUR::MeterType mt_right = _mt_right; for (unsigned int i = 0; i < _metrics.size(); ++i) { - int sx, dx, dy; + int sx, dx = 0, dy = 0; int mm = _metrics[i]->get_metric_mode(); sx = (mm & 2) ? _metrics[i]->get_width() : 0; @@ -450,7 +424,7 @@ Meterbridge::set_session (Session* s) _show_master = _session->config.get_show_master_on_meterbridge(); _show_midi = _session->config.get_show_midi_on_meterbridge(); - SignalOrderRouteSorter sorter; + ARDOUR::SignalOrderRouteSorter sorter; boost::shared_ptr routes = _session->get_routes(); RouteList copy(*routes); @@ -571,7 +545,7 @@ Meterbridge::get_state (void) gint Meterbridge::start_updating () { - fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &Meterbridge::fast_update_strips)); + fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Meterbridge::fast_update_strips)); return 0; } @@ -812,6 +786,12 @@ Meterbridge::parameter_changed (std::string const & p) else if (p == "meterbridge-label-height") { scroller.queue_resize(); } + else if (p == "show-monitor-on-meterbridge") { + scroller.queue_resize(); + } + else if (p == "track-name-number") { + scroller.queue_resize(); + } } void