incomplete work on mixer window treeview port
[ardour.git] / gtk2_ardour / gain_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     $Id$
19 */
20
21 #ifndef __ardour_gtk_gain_meter_h__
22 #define __ardour_gtk_gain_meter_h__
23
24 #include <vector>
25
26 #include <ardour/types.h>
27
28 #include <gtkmm.h>
29 #include <gtkmm2ext/slider_controller.h>
30 #include <gtkmm2ext/click_box.h>
31
32 #include "enums.h"
33
34 namespace ARDOUR {
35         class IO;
36         class Session;
37         class Route;
38         class RouteGroup;
39 }
40 namespace Gtkmm2ext {
41         class FastMeter;
42         class BarController;
43         class Pix;
44 }
45
46 class GainMeter : public Gtk::VBox
47 {
48   public:
49         GainMeter (ARDOUR::IO&, ARDOUR::Session&);
50         ~GainMeter ();
51
52         void update_gain_sensitive ();
53
54         void update_meters ();
55         void update_meters_falloff ();
56
57         void effective_gain_display ();
58
59         void set_width (Width);
60         void setup_meters ();
61
62         void set_meter_strip_name (string name);
63         void set_fader_name (string name);
64
65   private:
66         ARDOUR::IO& _io;
67         ARDOUR::Session& _session;
68
69         bool ignore_toggle;
70
71         Gtkmm2ext::VSliderController *gain_slider;
72         Gtk::Adjustment              gain_adjustment;
73         Gtk::Frame                   gain_display_frame;
74         Gtkmm2ext::ClickBox           gain_display;
75         Gtk::Frame                   peak_display_frame;
76         Gtk::EventBox                peak_display;
77         Gtk::Label                   peak_display_label;
78         Gtk::Button                  gain_unit_button;
79         Gtk::Label                   gain_unit_label;
80         Gtk::HBox                    gain_display_box;
81         Gtk::HBox                    fader_box;
82         Gtk::DrawingArea             meter_metric_area;
83         Gtk::Button                  meter_point_button;
84         Gtk::Label                   meter_point_label;
85         Gtk::Table                   top_table;
86         Width                       _width;
87
88         gint meter_metrics_expose (GdkEventExpose *);
89
90         static void _gain_printer (char buf[32], Gtk::Adjustment&, void *);
91         void gain_printer (char buf[32], Gtk::Adjustment&);
92         
93         struct MeterInfo {
94             Gtkmm2ext::FastMeter *meter;
95             gint16          width;   
96             bool            packed;
97             
98             MeterInfo() { 
99                     meter = 0;
100                     width = 0;
101                     packed = false;
102             }
103         };
104
105         static const guint16 regular_meter_width = 5;
106         static const guint16 thin_meter_width = 2;
107         vector<MeterInfo>    meters;
108         float       max_peak;
109         
110
111         Gtk::HBox   hbox;
112         Gtk::HBox   meter_packer;
113
114         void gain_adjusted ();
115         void gain_changed (void *);
116         
117         void meter_point_clicked ();
118         void meter_changed (void *);
119         void gain_unit_changed ();
120         
121         void hide_all_meters ();
122
123         gint meter_button_press (GdkEventButton*, uint32_t);
124         gint meter_button_release (GdkEventButton*, uint32_t);
125
126         gint peak_button_release (GdkEventButton*);
127         
128         Gtk::Menu* meter_menu;
129         void popup_meter_menu (GdkEventButton*);
130
131         gint start_gain_touch (GdkEventButton*);
132         gint end_gain_touch (GdkEventButton*);
133
134         gint entry_focus_event (GdkEventFocus* ev);
135
136         void set_mix_group_meter_point (ARDOUR::Route&, ARDOUR::MeterPoint);
137         void set_meter_point (ARDOUR::Route&, ARDOUR::MeterPoint);
138         gint meter_release (GdkEventButton*);
139         gint meter_press (GdkEventButton*);
140         bool wait_for_release;
141         ARDOUR::MeterPoint old_meter_point;
142
143         void meter_hold_changed();
144
145         void reset_peak_display ();
146         void reset_group_peak_display (ARDOUR::RouteGroup*);
147
148         static sigc::signal<void> ResetAllPeakDisplays;
149         static sigc::signal<void,ARDOUR::RouteGroup*> ResetGroupPeakDisplays;
150
151         static Gtkmm2ext::Pix* slider_pix;
152         static int setup_slider_pix ();
153 };
154
155 #endif /* __ardour_gtk_gain_meter_h__ */
156