*** NEW CODING POLICY ***
[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
35 #include <gtkmm2ext/click_box.h>
36 #include <gtkmm2ext/focus_entry.h>
37 #include <gtkmm2ext/slider_controller.h>
38
39 #include "enums.h"
40
41 namespace ARDOUR {
42         class IO;
43         class Session;
44         class Route;
45         class RouteGroup;
46 }
47 namespace Gtkmm2ext {
48         class FastMeter;
49         class BarController;
50 }
51 namespace Gtk {
52         class Menu;
53 }
54
55 class LevelMeter : public Gtk::HBox
56 {
57   public:
58         LevelMeter (ARDOUR::Session&);
59         ~LevelMeter ();
60
61         virtual void set_io (boost::shared_ptr<ARDOUR::IO> io);
62
63         void update_gain_sensitive ();
64
65         float update_meters ();
66         void update_meters_falloff ();
67         void clear_meters ();
68         void hide_meters ();
69         void setup_meters (int len=0, int width=3);
70
71   private:
72
73         //friend class MixerStrip;
74         boost::shared_ptr<ARDOUR::IO> _io;
75         ARDOUR::Session& _session;
76
77         Width _width;
78
79         struct MeterInfo {
80             Gtkmm2ext::FastMeter *meter;
81             gint16          width;
82                 int                             length;   
83             bool            packed;
84             
85             MeterInfo() { 
86                     meter = 0;
87                     width = 0;
88                         length = 0;
89                     packed = false;
90             }
91         };
92
93         guint16 regular_meter_width;
94         static const guint16 thin_meter_width = 2;
95         std::vector<MeterInfo>    meters;
96         float       max_peak;
97         
98         void hide_all_meters ();
99         gint meter_button_release (GdkEventButton*, uint32_t);
100
101         void parameter_changed (const char*);
102
103         void on_theme_changed ();
104         bool style_changed;
105         bool color_changed;
106         void color_handler ();
107 };
108
109 #endif /* __ardour_gtk_track_meter_h__ */
110