X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmeterbridge.cc;h=d46a4076510100e32ed24b96b85ca48b24202854;hb=6b1b72a247bf04c81292fc41af4f69c9b7f90379;hp=4d2a0c7b3b0e8c4861455944e3ae6ea80443ac49;hpb=25a6296f865620d5013cd634e693f7179e7edc84;p=ardour.git diff --git a/gtk2_ardour/meterbridge.cc b/gtk2_ardour/meterbridge.cc index 4d2a0c7b3b..d46a407651 100644 --- a/gtk2_ardour/meterbridge.cc +++ b/gtk2_ardour/meterbridge.cc @@ -26,6 +26,7 @@ #include #include +#include #include @@ -51,12 +52,13 @@ #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; using namespace PBD; using namespace Gtk; using namespace Glib; @@ -78,24 +80,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)) @@ -116,14 +100,26 @@ Meterbridge::Meterbridge () set_wmclass (X_("ardour_mixer"), PROGRAM_NAME); +#ifdef __APPLE__ + set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG); +#else + if (UIConfiguration::instance().get_all_floating_windows_are_dialogs()) { + set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG); + } else { + set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY); + } +#endif + 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); @@ -138,7 +134,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()); @@ -187,8 +182,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 () @@ -270,7 +265,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 @@ -340,33 +335,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 +355,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 +389,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,12 +431,9 @@ 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; - boost::shared_ptr routes = _session->get_routes(); - - RouteList copy(*routes); - copy.sort(sorter); - add_strips(copy); + 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()); _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::update_title, this), gui_context()); @@ -465,7 +443,7 @@ Meterbridge::set_session (Session* s) if (_visible) { show_window(); - ActionManager::check_toggleaction ("/Common/toggle-meterbridge"); + present (); } start_updating (); } @@ -491,7 +469,6 @@ Meterbridge::session_going_away () int Meterbridge::set_state (const XMLNode& node) { - const XMLProperty* prop; XMLNode* geometry; m_width = default_width; @@ -500,44 +477,15 @@ Meterbridge::set_state (const XMLNode& node) m_root_y = 1; if ((geometry = find_named_node (node, "geometry")) != 0) { - - XMLProperty* prop; - - if ((prop = geometry->property("x_size")) == 0) { - prop = geometry->property ("x-size"); - } - if (prop) { - m_width = atoi(prop->value()); - } - if ((prop = geometry->property("y_size")) == 0) { - prop = geometry->property ("y-size"); - } - if (prop) { - m_height = atoi(prop->value()); - } - - if ((prop = geometry->property ("x_pos")) == 0) { - prop = geometry->property ("x-pos"); - } - if (prop) { - m_root_x = atoi (prop->value()); - - } - if ((prop = geometry->property ("y_pos")) == 0) { - prop = geometry->property ("y-pos"); - } - if (prop) { - m_root_y = atoi (prop->value()); - } + 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 (); - if ((prop = node.property ("show-meterbridge"))) { - if (string_is_affirmative (prop->value())) { - _visible = true; - } - } + node.get_property ("show-meterbridge", _visible); return 0; } @@ -545,7 +493,6 @@ Meterbridge::set_state (const XMLNode& node) XMLNode& Meterbridge::get_state (void) { - char buf[32]; XMLNode* node = new XMLNode ("Meterbridge"); if (is_realized() && _visible) { @@ -553,17 +500,13 @@ Meterbridge::get_state (void) } XMLNode* geometry = new XMLNode ("geometry"); - snprintf(buf, sizeof(buf), "%d", m_width); - geometry->add_property(X_("x_size"), string(buf)); - snprintf(buf, sizeof(buf), "%d", m_height); - geometry->add_property(X_("y_size"), string(buf)); - snprintf(buf, sizeof(buf), "%d", m_root_x); - geometry->add_property(X_("x_pos"), string(buf)); - snprintf(buf, sizeof(buf), "%d", m_root_y); - geometry->add_property(X_("y_pos"), string(buf)); + geometry->set_property(X_("x-size"), m_width); + geometry->set_property(X_("y-size"), m_height); + geometry->set_property(X_("x-pos"), m_root_x); + geometry->set_property(X_("y-pos"), m_root_y); node->add_child_nocopy (*geometry); - node->add_property ("show-meterbridge", _visible ? "yes" : "no"); + node->set_property ("show-meterbridge", _visible); return *node; } @@ -571,7 +514,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 +755,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