Fix --template commandline option
[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 "widgets/fastmeter.h"
38 #include "widgets/focus_entry.h"
39 #include "widgets/slider_controller.h"
40
41 #include "enums.h"
42
43 namespace ARDOUR {
44         class Session;
45         class PeakMeter;
46 }
47 namespace Gtk {
48         class Menu;
49 }
50
51 class LevelMeterBase : public ARDOUR::SessionHandlePtr, virtual public sigc::trackable
52 {
53 public:
54         LevelMeterBase (ARDOUR::Session*, PBD::EventLoop::InvalidationRecord* ir,
55                         ArdourWidgets::FastMeter::Orientation o = ArdourWidgets::FastMeter::Vertical);
56         virtual ~LevelMeterBase ();
57
58         virtual void set_meter (ARDOUR::PeakMeter* meter);
59
60         void update_gain_sensitive ();
61
62         float update_meters ();
63         void update_meters_falloff ();
64         void clear_meters (bool reset_highlight = true);
65         void hide_meters ();
66         void setup_meters (int len=0, int width=3, int thin=2);
67         void set_max_audio_meter_count (uint32_t cnt = 0);
68
69         /** Emitted in the GUI thread when a button is pressed over the meter */
70         PBD::Signal1<bool, GdkEventButton *> ButtonPress;
71         PBD::Signal1<bool, GdkEventButton *> ButtonRelease;
72
73 protected:
74         virtual void mtr_pack(Gtk::Widget &w) = 0;
75         virtual void mtr_remove(Gtk::Widget &w) = 0;
76
77 private:
78         PBD::EventLoop::InvalidationRecord* parent_invalidator;
79         ARDOUR::PeakMeter* _meter;
80         ArdourWidgets::FastMeter::Orientation _meter_orientation;
81
82         Width _width;
83
84         struct MeterInfo {
85                 ArdourWidgets::FastMeter* meter;
86                 gint16                    width;
87                 int                       length;
88                 bool                      packed;
89                 float                     max_peak;
90
91                 MeterInfo() {
92                         meter = 0;
93                         width = 0;
94                         length = 0;
95                         packed = false;
96                         max_peak = -INFINITY;
97                 }
98         };
99
100         guint16                regular_meter_width;
101         int                    meter_length;
102         guint16                thin_meter_width;
103         std::vector<MeterInfo> meters;
104         float                  max_peak;
105         ARDOUR::MeterType      visible_meter_type;
106         uint32_t               midi_count;
107         uint32_t               meter_count;
108         uint32_t               max_visible_meters;
109
110         PBD::ScopedConnection _configuration_connection;
111         PBD::ScopedConnection _meter_type_connection;
112         PBD::ScopedConnection _parameter_connection;
113
114         void hide_all_meters ();
115         bool meter_button_press (GdkEventButton *);
116         bool meter_button_release (GdkEventButton *);
117
118         void parameter_changed (std::string);
119         void configuration_changed (ARDOUR::ChanCount in, ARDOUR::ChanCount out);
120         void meter_type_changed (ARDOUR::MeterType);
121
122         bool color_changed;
123         void color_handler ();
124 };
125
126 class LevelMeterHBox : public LevelMeterBase, public Gtk::HBox
127 {
128 public:
129         LevelMeterHBox (ARDOUR::Session*);
130         ~LevelMeterHBox();
131
132 protected:
133         void mtr_pack(Gtk::Widget &w);
134         void mtr_remove(Gtk::Widget &w);
135 };
136
137 class LevelMeterVBox : public LevelMeterBase, public Gtk::VBox
138 {
139 public:
140         LevelMeterVBox (ARDOUR::Session*);
141         ~LevelMeterVBox();
142
143 protected:
144         void mtr_pack(Gtk::Widget &w);
145         void mtr_remove(Gtk::Widget &w);
146 };
147
148 #endif /* __ardour_gtk_track_meter_h__ */
149