MCP: Fix issue with strip "select" buttons that stayed stuck on.
[ardour.git] / libs / surfaces / push2 / level_meter.h
1 /*
2     Copyright (C) 2011-2016 Paul Davis
3     Author: Carl Hetherington <cth@carlh.net>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __ardour_push2_level_meter_h__
21 #define __ardour_push2_level_meter_h__
22
23 #include "canvas/container.h"
24 #include "canvas/meter.h"
25
26 namespace ARDOUR {
27         class Session;
28         class PeakMeter;
29 }
30
31 namespace ArdourCanvas {
32         class Box;
33 }
34
35 namespace ArdourSurface
36 {
37
38 class Push2;
39
40 class LevelMeter : public ArdourCanvas::Container, public sigc::trackable
41 {
42   public:
43         LevelMeter (Push2& p2, Item* parent, int len, ArdourCanvas::Meter::Orientation o = ArdourCanvas::Meter::Vertical);
44         virtual ~LevelMeter ();
45
46         virtual void set_meter (ARDOUR::PeakMeter* meter);
47
48         void update_gain_sensitive ();
49
50         float update_meters ();
51         void update_meters_falloff ();
52         void clear_meters (bool reset_highlight = true);
53         void hide_meters ();
54         void setup_meters (int len=0, int width=3, int thin=2);
55         void set_max_audio_meter_count (uint32_t cnt = 0);
56
57         void set_type (ARDOUR::MeterType);
58         ARDOUR::MeterType get_type () { return meter_type; }
59
60   private:
61         Push2& p2;
62         ARDOUR::PeakMeter* _meter;
63         ArdourCanvas::Meter::Orientation _meter_orientation;
64         ArdourCanvas::Box* meter_packer;
65
66         struct MeterInfo {
67                 ArdourCanvas::Meter* meter;
68                 gint16 width;
69                 int    length;
70                 bool   packed;
71                 float  max_peak;
72
73                 MeterInfo() {
74                         meter = 0;
75                         width = 0;
76                         length = 0;
77                         packed = false;
78                         max_peak = -INFINITY;
79                 }
80         };
81
82         guint16                regular_meter_width;
83         int                    meter_length;
84         guint16                thin_meter_width;
85         std::vector<MeterInfo> meters;
86         float                  max_peak;
87         ARDOUR::MeterType      meter_type;
88         ARDOUR::MeterType      visible_meter_type;
89         uint32_t               midi_count;
90         uint32_t               meter_count;
91         uint32_t               max_visible_meters;
92
93         PBD::ScopedConnection _configuration_connection;
94         PBD::ScopedConnection _meter_type_connection;
95         PBD::ScopedConnection _parameter_connection;
96
97         void hide_all_meters ();
98
99         void parameter_changed (std::string);
100         void configuration_changed (ARDOUR::ChanCount in, ARDOUR::ChanCount out);
101         void meter_type_changed (ARDOUR::MeterType);
102 };
103
104 }
105
106 #endif /* __ardour_push2_level_meter_h__ */