ardour
gain_meter.h
Go to the documentation of this file.
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_gain_meter_h__
21 #define __ardour_gtk_gain_meter_h__
22 
23 #include <vector>
24 #include <map>
25 
26 #include <gtkmm/box.h>
27 #include <gtkmm/adjustment.h>
28 #include <gtkmm/frame.h>
29 #include <gtkmm/eventbox.h>
30 #include <gtkmm/button.h>
31 #include <gtkmm/table.h>
32 #include <gtkmm/drawingarea.h>
33 #include <gdkmm/colormap.h>
34 
35 #include "pbd/signals.h"
36 
37 #include "ardour/chan_count.h"
38 #include "ardour/types.h"
39 #include "ardour/session_handle.h"
40 
41 #include "ardour_button.h"
42 
43 #include "gtkmm2ext/click_box.h"
44 #include "gtkmm2ext/focus_entry.h"
46 
47 #include "enums.h"
48 #include "level_meter.h"
49 
50 namespace ARDOUR {
51  class IO;
52  class Session;
53  class Route;
54  class RouteGroup;
55  class PeakMeter;
56  class Amp;
57  class Automatable;
58 }
59 namespace Gtkmm2ext {
60  class FastMeter;
61 }
62 namespace Gtk {
63  class Menu;
64 }
65 
66 class GainMeterBase : virtual public sigc::trackable, ARDOUR::SessionHandlePtr
67 {
68  public:
69  GainMeterBase (ARDOUR::Session*, bool horizontal, int, int);
70  virtual ~GainMeterBase ();
71 
75 
76  void update_gain_sensitive ();
77  void update_meters ();
78 
79  const ARDOUR::ChanCount meter_channels () const;
80 
81  void effective_gain_display ();
82  void set_width (Width, int len=0);
83  void set_meter_strip_name (const char * name);
84  void set_fader_name (const char * name);
85 
86  virtual void setup_meters (int len=0);
87  virtual void set_type (ARDOUR::MeterType);
88 
90 
93 
97  PBD::Signal1<bool, GdkEventButton *> LevelMeterButtonPress;
98 
99  protected:
100 
101  friend class MixerStrip;
102  friend class MeterStrip;
103  friend class RouteTimeAxisView;
107  std::vector<sigc::connection> connections;
109 
112 
114  Gtk::Adjustment gain_adjustment;
117 // Gtk::Button peak_display;
118  Gtk::DrawingArea meter_metric_area;
119  Gtk::DrawingArea meter_ticks1_area;
120  Gtk::DrawingArea meter_ticks2_area;
122 
123  sigc::connection gain_watching;
124 
127 
128  Gtk::Menu gain_astate_menu;
129  Gtk::Menu gain_astyle_menu;
130 
131  gint gain_automation_style_button_event (GdkEventButton *);
132  gint gain_automation_state_button_event (GdkEventButton *);
133  gint pan_automation_style_button_event (GdkEventButton *);
134  gint pan_automation_state_button_event (GdkEventButton *);
135 
138 
139  void setup_gain_adjustment ();
140 
141  std::string astate_string (ARDOUR::AutoState);
143  std::string _astate_string (ARDOUR::AutoState, bool);
144 
145  std::string astyle_string (ARDOUR::AutoStyle);
147  std::string _astyle_string (ARDOUR::AutoStyle, bool);
148 
150 
151  void show_gain ();
152  void gain_activated ();
153  bool gain_focused (GdkEventFocus*);
154 
155  float max_peak;
156 
157  void gain_adjusted ();
158  void gain_changed ();
159 
160  void meter_point_clicked ();
161  void gain_unit_changed ();
162 
163  virtual void hide_all_meters ();
164 
165  gint meter_button_press (GdkEventButton*, uint32_t);
166 
167  bool peak_button_release (GdkEventButton*);
168  bool gain_key_press (GdkEventKey*);
169 
170  Gtk::Menu* meter_menu;
171  void popup_meter_menu (GdkEventButton*);
172 
173  void amp_stop_touch ();
174  void amp_start_touch ();
175 
178  gint meter_release (GdkEventButton*);
179  gint meter_press (GdkEventButton*);
182 
183  void parameter_changed (const char*);
184 
185  void reset_peak_display ();
188 
189  void redraw_metrics ();
190  void on_theme_changed ();
191  void color_handler(bool);
194 
195 private:
196 
197  bool level_meter_button_press (GdkEventButton *);
199 };
200 
201 class GainMeter : public GainMeterBase, public Gtk::VBox
202 {
203  public:
204  GainMeter (ARDOUR::Session*, int);
205  virtual ~GainMeter ();
206 
210 
211  int get_gm_width ();
212  void setup_meters (int len=0);
214  void route_active_changed ();
215 
216  protected:
217  void hide_all_meters ();
218 
219  gint meter_metrics_expose (GdkEventExpose *);
220  gint meter_ticks1_expose (GdkEventExpose *);
221  gint meter_ticks2_expose (GdkEventExpose *);
222  void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
223 
224  private:
225 
228 
229  Gtk::HBox gain_display_box;
230  Gtk::HBox fader_box;
231  Gtk::VBox* fader_vbox;
232  Gtk::HBox hbox;
233  Gtk::HBox meter_hbox;
234  Gtk::Alignment fader_alignment;
235  Gtk::Alignment meter_alignment;
236  std::vector<ARDOUR::DataType> _types;
237 };
238 
239 #endif /* __ardour_gtk_gain_meter_h__ */
240 
Gtk::HBox gain_display_box
Definition: gain_meter.h:229
Gtk::Menu gain_astyle_menu
Definition: gain_meter.h:129
LevelMeterHBox * level_meter
Definition: gain_meter.h:121
ARDOUR::MeterPoint old_meter_point
Definition: gain_meter.h:181
Gtkmm2ext::FocusEntry peak_display
Definition: gain_meter.h:116
std::string _astate_string(ARDOUR::AutoState, bool)
Definition: gain_meter.cc:789
const ARDOUR::ChanCount meter_channels() const
Definition: gain_meter.cc:884
std::string short_astyle_string(ARDOUR::AutoStyle)
Definition: gain_meter.cc:818
ArdourButton gain_automation_state_button
Definition: gain_meter.h:126
bool next_release_selects
Definition: gain_meter.h:111
void gain_adjusted()
Definition: gain_meter.cc:521
virtual ~GainMeter()
Definition: gain_meter.cc:1006
boost::shared_ptr< ARDOUR::Route > _route
Definition: gain_meter.h:104
void update_gain_sensitive()
Definition: gain_meter.cc:589
ARDOUR::ChanCount _previous_amp_output_streams
Definition: gain_meter.h:193
ArdourButton gain_automation_style_button
Definition: gain_meter.h:125
void popup_meter_menu(GdkEventButton *)
Definition: gain_meter.cc:423
void gain_automation_style_changed()
Definition: gain_meter.cc:836
gint meter_ticks2_expose(GdkEventExpose *)
Definition: gain_meter.cc:1094
bool wait_for_release
Definition: gain_meter.h:180
virtual void set_type(ARDOUR::MeterType)
Definition: gain_meter.cc:334
Definition: ardour_ui.h:130
void amp_stop_touch()
Definition: gain_meter.cc:736
gint meter_button_press(GdkEventButton *, uint32_t)
virtual ~GainMeterBase()
Definition: gain_meter.cc:178
void set_fader_name(const char *name)
Definition: gain_meter.cc:583
Gtk::HBox hbox
Definition: gain_meter.h:232
std::string _astyle_string(ARDOUR::AutoStyle, bool)
Definition: gain_meter.cc:824
std::vector< ARDOUR::DataType > _types
Definition: gain_meter.h:236
Gtkmm2ext::FocusEntry gain_display
Definition: gain_meter.h:115
GainMeter(ARDOUR::Session *, int)
Definition: gain_meter.cc:941
std::string astate_string(ARDOUR::AutoState)
Definition: gain_meter.cc:777
virtual void setup_meters(int len=0)
Definition: gain_meter.cc:302
AutoStyle
Definition: types.h:155
void reset_group_peak_display(ARDOUR::RouteGroup *)
Definition: gain_meter.cc:415
void color_handler(bool)
Definition: gain_meter.cc:909
GainMeterBase(ARDOUR::Session *, bool horizontal, int, int)
Definition: gain_meter.cc:85
void meter_type_changed(ARDOUR::MeterType)
Definition: gain_meter.cc:1187
gint meter_press(GdkEventButton *)
Definition: gain_meter.cc:625
void on_style_changed(const Glib::RefPtr< Gtk::Style > &)
Definition: gain_meter.cc:1104
gint gain_automation_style_button_event(GdkEventButton *)
Definition: gain_meter.cc:760
PBD::ScopedConnection _level_meter_connection
Definition: gain_meter.h:198
void effective_gain_display()
Definition: gain_meter.cc:545
boost::shared_ptr< ARDOUR::Amp > _amp
Definition: gain_meter.h:106
void gain_automation_state_changed()
Definition: gain_meter.cc:849
Gtk::Alignment meter_alignment
Definition: gain_meter.h:235
gint meter_release(GdkEventButton *)
Definition: gain_meter.cc:688
Gtk::DrawingArea meter_ticks2_area
Definition: gain_meter.h:120
Gtk::DrawingArea meter_metric_area
Definition: gain_meter.h:118
std::string astyle_string(ARDOUR::AutoStyle)
Definition: gain_meter.cc:812
bool level_meter_button_press(GdkEventButton *)
Definition: gain_meter.cc:1121
void set_meter_point(ARDOUR::Route &, ARDOUR::MeterPoint)
Definition: gain_meter.cc:704
sigc::connection gain_watching
Definition: gain_meter.h:123
MeterType
Definition: types.h:182
Definition: amp.h:29
Gtk::DrawingArea meter_ticks1_area
Definition: gain_meter.h:119
boost::shared_ptr< PBD::Controllable > get_controllable()
Definition: gain_meter.cc:1111
virtual void set_controls(boost::shared_ptr< ARDOUR::Route > route, boost::shared_ptr< ARDOUR::PeakMeter > meter, boost::shared_ptr< ARDOUR::Amp > amp)
Definition: gain_meter.cc:1009
void gain_activated()
Definition: gain_meter.cc:455
gint gain_automation_state_button_event(GdkEventButton *)
Definition: gain_meter.cc:742
void set_meter_strip_name(const char *name)
Definition: gain_meter.cc:572
void setup_gain_adjustment()
Definition: gain_meter.cc:254
void meter_configuration_changed(ARDOUR::ChanCount)
Definition: gain_meter.cc:1127
void gain_changed()
Definition: gain_meter.cc:566
void route_active_changed()
Definition: gain_meter.cc:1179
Gtk::HBox meter_hbox
Definition: gain_meter.h:233
Gtk::Menu * meter_menu
Definition: gain_meter.h:170
Gtk::Adjustment gain_adjustment
Definition: gain_meter.h:114
void parameter_changed(const char *)
Gtk::Menu gain_astate_menu
Definition: gain_meter.h:128
bool ignore_toggle
Definition: gain_meter.h:110
LevelMeterHBox & get_level_meter() const
Definition: gain_meter.h:91
void set_type(ARDOUR::MeterType)
Definition: gain_meter.cc:362
Gtk::Alignment fader_alignment
Definition: gain_meter.h:234
float max_peak
Definition: gain_meter.h:155
Gtk::VBox * fader_vbox
Definition: gain_meter.h:231
void show_gain()
Definition: gain_meter.cc:498
PBD::Signal1< bool, GdkEventButton * > LevelMeterButtonPress
Definition: gain_meter.h:97
ARDOUR::DataType _data_type
Definition: gain_meter.h:192
void hide_all_meters()
Definition: gain_meter.cc:296
const char * name
bool peak_button_release(GdkEventButton *)
Definition: gain_meter.cc:379
void setup_meters(int len=0)
Definition: gain_meter.cc:340
void reset_peak_display()
Definition: gain_meter.cc:397
Gtkmm2ext::SliderController & get_gain_slider() const
Definition: gain_meter.h:92
Gtk::HBox fader_box
Definition: gain_meter.h:230
Width
Definition: enums.h:25
void redraw_metrics()
Definition: gain_meter.cc:932
bool gain_key_press(GdkEventKey *)
Definition: gain_meter.cc:368
void update_meters()
Definition: gain_meter.cc:890
void set_route_group_meter_point(ARDOUR::Route &, ARDOUR::MeterPoint)
Definition: gain_meter.cc:710
void amp_start_touch()
Definition: gain_meter.cc:730
virtual void hide_all_meters()
Definition: gain_meter.cc:290
Gtkmm2ext::SliderController * gain_slider
Definition: gain_meter.h:113
PBD::ScopedConnectionList model_connections
Definition: gain_meter.h:108
bool gain_focused(GdkEventFocus *)
Definition: gain_meter.cc:444
std::vector< sigc::connection > connections
Definition: gain_meter.h:107
void meter_point_clicked()
Definition: gain_meter.cc:722
void on_theme_changed()
Definition: gain_meter.cc:927
void set_width(Width, int len=0)
Definition: gain_meter.cc:915
MeterPoint
Definition: types.h:174
void reset_route_peak_display(ARDOUR::Route *)
Definition: gain_meter.cc:407
int get_gm_width()
Definition: gain_meter.cc:1055
std::string short_astate_string(ARDOUR::AutoState)
Definition: gain_meter.cc:783
virtual void set_controls(boost::shared_ptr< ARDOUR::Route > route, boost::shared_ptr< ARDOUR::PeakMeter > meter, boost::shared_ptr< ARDOUR::Amp > amp)
Definition: gain_meter.cc:185
gint meter_metrics_expose(GdkEventExpose *)
Definition: gain_meter.cc:1074
gint meter_ticks1_expose(GdkEventExpose *)
Definition: gain_meter.cc:1084
void gain_unit_changed()
gint pan_automation_state_button_event(GdkEventButton *)
boost::shared_ptr< ARDOUR::PeakMeter > _meter
Definition: gain_meter.h:105
gint pan_automation_style_button_event(GdkEventButton *)
AutoState
Definition: types.h:145