Reenable the correct sort column and type when redisplaying regions
[ardour.git] / gtk2_ardour / meter_patterns.cc
index 675e567df69071d70a31421f5555515bd5ca4824..e91b2579a84ae05c3a828fc2f071cad806246b51 100644 (file)
@@ -1,34 +1,38 @@
 /*
-    Copyright (C) 2013 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-2016 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.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.
+ */
+
+#include <gtkmm/drawingarea.h>
 
 #include <gtkmm2ext/cairo_widget.h>
 #include <gtkmm2ext/gtk_ui.h>
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/rgb_macros.h>
 
+#include "ardour/logmeter.h"
 #include <ardour/rc_configuration.h>
-#include "ardour_ui.h"
+
 #include "utils.h"
-#include "logmeter.h"
 #include "meter_patterns.h"
+#include "ui_config.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace ARDOUR_UI_UTILS;
@@ -79,10 +83,10 @@ ArdourMeter::meter_type_string (ARDOUR::MeterType mt)
 {
        switch (mt) {
                case MeterPeak:
-                       return _("Peak");
+                       return _("Peak (+6dBFS)");
                        break;
                case MeterPeak0dB:
-                       return _("Peak 0dB");
+                       return _("Peak (0dBFS)");
                        break;
                case MeterKrms:
                        return _("RMS + Peak");
@@ -100,13 +104,13 @@ ArdourMeter::meter_type_string (ARDOUR::MeterType mt)
                        return _("IEC2/EBU");
                        break;
                case MeterK20:
-                       return _("K20");
+                       return _("K20/RMS");
                        break;
                case MeterK14:
-                       return _("K14");
+                       return _("K14/RMS");
                        break;
                case MeterK12:
-                       return _("K12");
+                       return _("K12/RMS");
                        break;
                case MeterVU:
                        return _("VU");
@@ -245,18 +249,18 @@ static void set_bg_color (Gtk::Widget& w, cairo_t* cr, MeterType type) {
        double r,g,b,a;
        switch(type) {
                case MeterVU:
-                       ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->color ("meterstrip vu bg"), r, g, b, a);
+                       Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("meterstrip vu bg"), r, g, b, a);
                        break;
                case MeterIEC1DIN:
                case MeterIEC1NOR:
                case MeterIEC2BBC:
                case MeterIEC2EBU:
-                       ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->color ("meterstrip ppm bg"), r, g, b, a);
+                       Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("meterstrip ppm bg"), r, g, b, a);
                        break;
                case MeterK12:
                case MeterK14:
                case MeterK20:
-                       ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->color ("meterstrip dpm bg"), r, g, b, a);
+                       Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("meterstrip dpm bg"), r, g, b, a);
                        break;
                default:
                        {
@@ -274,16 +278,16 @@ static void set_fg_color(Gtk::Widget&, MeterType type, Gdk::Color * c) {
        double r,g,b,a;
        switch(type) {
                case MeterVU:
-                       ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->color ("meterstrip vu fg"), r, g, b, a);
+                       Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("meterstrip vu fg"), r, g, b, a);
                        break;
                case MeterIEC1DIN:
                case MeterIEC1NOR:
                case MeterIEC2BBC:
                case MeterIEC2EBU:
-                       ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->color ("meterstrip ppm fg"), r, g, b, a);
+                       Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("meterstrip ppm fg"), r, g, b, a);
                        break;
                default:
-                       ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->color ("meterstrip dpm fg"), r, g, b, a);
+                       Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("meterstrip dpm fg"), r, g, b, a);
                        break;
        }
        c->set_rgb_p (r, g, b);
@@ -304,7 +308,7 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
 
        float box_l=0;
        float box_w=0;
-#define PX_SCALE(pxmin, dflt) rint(std::max((double)pxmin, (double)dflt * ARDOUR_UI::ui_scale))
+#define PX_SCALE(pxmin, dflt) rint(std::max((double)pxmin, (double)dflt * UIConfiguration::instance().get_ui_scale()))
        if (tickleft) {
                if (w.get_name().substr(0, 3) == "Bar") {
                        box_w = PX_SCALE(2, 2);
@@ -343,7 +347,7 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
        cairo_fill (cr);
 
        height = min(max_pattern_metric_size, height);
-       uint32_t peakcolor = ARDOUR_UI::config()->color ("meterbridge peaklabel");
+       uint32_t peakcolor = UIConfiguration::instance().color ("meterbridge peaklabel");
 
        for (vector<DataType>::const_iterator i = types.begin(); i != types.end(); ++i) {
 
@@ -512,13 +516,13 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
                                        points.insert (std::pair<float,float>(  3, 1.0));
                                        points.insert (std::pair<float,float>(  4, 0.5));
                                        points.insert (std::pair<float,float>(  5, 0.5));
-                                       // no break
+                                       /* fallthrough */
                                case MeterPeak0dB:
                                        points.insert (std::pair<float,float>(-60, 0.5));
                                        points.insert (std::pair<float,float>(-50, 1.0));
                                        points.insert (std::pair<float,float>(-40, 1.0));
                                        points.insert (std::pair<float,float>(-30, 1.0));
-                                       if (ARDOUR_UI::config()->get_meter_line_up_level() == MeteringLineUp24) {
+                                       if (UIConfiguration::instance().get_meter_line_up_level() == MeteringLineUp24) {
                                                points.insert (std::pair<float,float>(-24, 1.0));
                                        } else {
                                                points.insert (std::pair<float,float>(-25, 1.0));
@@ -636,12 +640,12 @@ meter_render_metrics (Gtk::Widget& w, MeterType type, vector<DataType> types)
        Pango::AttrFontDesc* font_attr;
        Pango::FontDescription font;
 
-       font = Pango::FontDescription (ARDOUR_UI::config()->get_SmallMonospaceFont());
+       font = Pango::FontDescription (UIConfiguration::instance().get_SmallMonospaceFont());
 #ifdef __APPLE__
        const double fixfontsize = 1.0;
 #else
        // counter-act global font-scaling.
-       const double fixfontsize = std::min(1.0, 0.9 / sqrtf(ARDOUR_UI::ui_scale));
+       const double fixfontsize = std::min(1.0, 0.9 / sqrtf(UIConfiguration::instance().get_ui_scale()));
 #endif
 
        font.set_weight (Pango::WEIGHT_NORMAL);
@@ -677,7 +681,7 @@ meter_render_metrics (Gtk::Widget& w, MeterType type, vector<DataType> types)
        cairo_set_line_width (cr, 1.0);
 
        height = min(max_pattern_metric_size, height);
-       uint32_t peakcolor = ARDOUR_UI::config()->color ("meterbridge peaklabel");
+       uint32_t peakcolor = UIConfiguration::instance().color ("meterbridge peaklabel");
        Gdk::Color c; // default text color
 
        for (vector<DataType>::const_iterator i = types.begin(); i != types.end(); ++i) {
@@ -747,18 +751,20 @@ meter_render_metrics (Gtk::Widget& w, MeterType type, vector<DataType> types)
                                        points.insert (std::pair<float,string>( -5.0f, "+15"));
                                        points.insert (std::pair<float,string>(  0.0f, "+20"));
                                        break;
-                               default:
                                case MeterPeak:
+                                       /* fallthrough */
                                case MeterKrms:
+                                       /* fallthrough */
+                               default:
                                        points.insert (std::pair<float,string>(  3.0f, "+3"));
-                                       // no break
+                                       /* fallthrough */
                                case MeterPeak0dB:
                                        points.insert (std::pair<float,string>(-50.0f, "-50"));
                                        points.insert (std::pair<float,string>(-40.0f, "-40"));
                                        points.insert (std::pair<float,string>(-30.0f, "-30"));
                                        points.insert (std::pair<float,string>(-20.0f, "-20"));
                                        if (types.size() == 1) {
-                                               if (ARDOUR_UI::config()->get_meter_line_up_level() == MeteringLineUp24) {
+                                               if (UIConfiguration::instance().get_meter_line_up_level() == MeteringLineUp24) {
                                                        points.insert (std::pair<float,string>(-24.0f, "-24"));
                                                } else {
                                                        points.insert (std::pair<float,string>(-25.0f, "-25"));
@@ -887,6 +893,7 @@ meter_render_metrics (Gtk::Widget& w, MeterType type, vector<DataType> types)
                                                points.insert (std::pair<float,string>( 72, "72"));
                                                points.insert (std::pair<float,string>(112, "112"));
                                                points.insert (std::pair<float,string>(127, "127"));
+                                               break;
                                        case 4:
                                                /* labels that don't overlay with 0dBFS*/
                                                points.insert (std::pair<float,string>(  0, "0"));
@@ -1008,6 +1015,11 @@ meter_render_metrics (Gtk::Widget& w, MeterType type, vector<DataType> types)
                                layout->set_text("mid");
                                layout->get_pixel_size(tw, th);
                                break;
+                       default: // DataType::NIL;
+                               layout->set_text("");
+                               tw = th = 0;
+                               assert (0); // not reached
+                               break;
                }
                if (!background) {
                        c = w.get_style()->get_fg (Gtk::STATE_ACTIVE);
@@ -1144,5 +1156,5 @@ ArdourMeter::meter_clear_pattern_cache(int which) {
                        ++j;
                }
        }
-       RedrawMetrics();
+       RedrawMetrics(); /* EMIT SIGNAL */
 }