fix display-type of editor-mixer level-meter
[ardour.git] / gtk2_ardour / level_meter.h
1 /*
2     Copyright (C) 2002 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_gtk_track_meter_h__
21 #define __ardour_gtk_track_meter_h__
22
23 #include <vector>
24
25 #include <gtkmm/box.h>
26 #include <gtkmm/adjustment.h>
27 #include <gtkmm/frame.h>
28 #include <gtkmm/eventbox.h>
29 #include <gtkmm/button.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/drawingarea.h>
32
33 #include "ardour/types.h"
34 #include "ardour/chan_count.h"
35 #include "ardour/session_handle.h"
36
37 #include <gtkmm2ext/click_box.h>
38 #include <gtkmm2ext/focus_entry.h>
39 #include <gtkmm2ext/slider_controller.h>
40
41 #include "enums.h"
42
43 namespace ARDOUR {
44         class Session;
45         class PeakMeter;
46 }
47 namespace Gtkmm2ext {
48         class FastMeter;
49 }
50 namespace Gtk {
51         class Menu;
52 }
53
54 class LevelMeter : public Gtk::HBox, public ARDOUR::SessionHandlePtr
55 {
56   public:
57         LevelMeter (ARDOUR::Session*);
58         ~LevelMeter ();
59
60         virtual void set_meter (ARDOUR::PeakMeter* meter);
61
62         void update_gain_sensitive ();
63
64         float update_meters ();
65         void update_meters_falloff ();
66         void clear_meters (bool reset_highlight = true);
67         void hide_meters ();
68         void setup_meters (int len=0, int width=3, int thin=2);
69
70         void set_type (ARDOUR::MeterType);
71         ARDOUR::MeterType get_type () { return meter_type; }
72
73         /** Emitted in the GUI thread when a button is pressed over the meter */
74         PBD::Signal1<bool, GdkEventButton *> ButtonPress;
75         PBD::Signal1<void, ARDOUR::MeterType> MeterTypeChanged;
76
77   private:
78         ARDOUR::PeakMeter* _meter;
79
80         Width _width;
81
82         struct MeterInfo {
83             Gtkmm2ext::FastMeter *meter;
84             gint16                width;
85             int                   length;
86             bool                  packed;
87             float                 max_peak;
88
89             MeterInfo() {
90                     meter = 0;
91                     width = 0;
92                     length = 0;
93                     packed = false;
94                     max_peak = -INFINITY;
95             }
96         };
97
98         guint16                regular_meter_width;
99         int                    meter_length;
100         guint16                thin_meter_width;
101         std::vector<MeterInfo> meters;
102         float                  max_peak;
103         ARDOUR::MeterType      meter_type;
104         ARDOUR::MeterType      visible_meter_type;
105
106         PBD::ScopedConnection _configuration_connection;
107         PBD::ScopedConnection _meter_type_connection;
108         PBD::ScopedConnection _parameter_connection;
109
110         void hide_all_meters ();
111         bool meter_button_press (GdkEventButton *);
112         bool meter_button_release (GdkEventButton *);
113
114         void parameter_changed (std::string);
115         void configuration_changed (ARDOUR::ChanCount in, ARDOUR::ChanCount out);
116         void meter_type_changed (ARDOUR::MeterType);
117
118         void on_theme_changed ();
119         bool style_changed;
120         bool color_changed;
121         void color_handler ();
122 };
123
124 #endif /* __ardour_gtk_track_meter_h__ */
125