summaryrefslogtreecommitdiff
path: root/gtk2_ardour/gain_meter.h
blob: 1dfc088248b200448687e7e0e907e9854b10e913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
    Copyright (C) 2002 Paul Davis

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    $Id$
*/

#ifndef __ardour_gtk_gain_meter_h__
#define __ardour_gtk_gain_meter_h__

#include <vector>
#include <map>

#include <gtkmm/box.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/frame.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/button.h>
#include <gtkmm/table.h>
#include <gtkmm/drawingarea.h>

#include <ardour/types.h>

#include <gtkmm2ext/click_box.h>
#include <gtkmm2ext/slider_controller.h>

#include "enums.h"

namespace ARDOUR {
	class IO;
	class Session;
	class Route;
	class RouteGroup;
}
namespace Gtkmm2ext {
	class FastMeter;
	class BarController;
}
namespace Gtk {
	class Menu;
}

class GainMeter : public Gtk::VBox
{
  public:
	GainMeter (boost::shared_ptr<ARDOUR::IO>, ARDOUR::Session&);
	~GainMeter ();

	void update_gain_sensitive ();

	void update_meters ();
	void update_meters_falloff ();

	void effective_gain_display ();

	void set_width (Width);
	void setup_meters ();

	void set_meter_strip_name (const char * name);
	void set_fader_name (const char * name);

  private:

	friend class MixerStrip;
	boost::shared_ptr<ARDOUR::IO> _io;
	ARDOUR::Session& _session;

	bool ignore_toggle;

	Gtkmm2ext::VSliderController *gain_slider;
	Gtk::Adjustment              gain_adjustment;
	Gtk::Frame                   gain_display_frame;
	Gtkmm2ext::ClickBox           gain_display;
	Gtk::Frame                   peak_display_frame;
	Gtk::EventBox                peak_display;
	Gtk::Label                   peak_display_label;
	Gtk::HBox                    gain_display_box;
	Gtk::HBox                    fader_box;
	Gtk::DrawingArea             meter_metric_area;

	sigc::connection gain_watching;

	Gtk::Button gain_automation_style_button;
	Gtk::ToggleButton gain_automation_state_button;

	Gtk::Menu gain_astate_menu;
	Gtk::Menu gain_astyle_menu;

	gint gain_automation_style_button_event (GdkEventButton *);
	gint gain_automation_state_button_event (GdkEventButton *);
	gint pan_automation_style_button_event (GdkEventButton *);
	gint pan_automation_state_button_event (GdkEventButton *);

	void gain_automation_state_changed();
	void gain_automation_style_changed();

	std::string astate_string (ARDOUR::AutoState);
	std::string short_astate_string (ARDOUR::AutoState);
	std::string _astate_string (ARDOUR::AutoState, bool);

	std::string astyle_string (ARDOUR::AutoStyle);
	std::string short_astyle_string (ARDOUR::AutoStyle);
	std::string _astyle_string (ARDOUR::AutoStyle, bool);

	Width                       _width;

	static std::map<std::string,Glib::RefPtr<Gdk::Pixmap> > metric_pixmaps;
	static Glib::RefPtr<Gdk::Pixmap> render_metrics (Gtk::Widget&);

	gint meter_metrics_expose (GdkEventExpose *);

	static void _gain_printer (char buf[32], Gtk::Adjustment&, void *);
	void gain_printer (char buf[32], Gtk::Adjustment&);
	
	struct MeterInfo {
	    Gtkmm2ext::FastMeter *meter;
	    gint16          width;   
	    bool            packed;
	    
	    MeterInfo() { 
		    meter = 0;
		    width = 0;
		    packed = false;
	    }
	};

	static const guint16 regular_meter_width = 5;
	static const guint16 thin_meter_width = 2;
	vector<MeterInfo>    meters;
	float       max_peak;
	
	Gtk::VBox*   fader_vbox;
	Gtk::HBox   hbox;
	Gtk::HBox   meter_packer;

	void gain_adjusted ();
	void gain_changed (void *);
	
	void meter_point_clicked ();
	void gain_unit_changed ();
	
	void hide_all_meters ();

	gint meter_button_press (GdkEventButton*, uint32_t);
	gint meter_button_release (GdkEventButton*, uint32_t);

	gint peak_button_release (GdkEventButton*);
	
	Gtk::Menu* meter_menu;
	void popup_meter_menu (GdkEventButton*);

	gint start_gain_touch (GdkEventButton*);
	gint end_gain_touch (GdkEventButton*);

	void set_mix_group_meter_point (ARDOUR::Route&, ARDOUR::MeterPoint);
	void set_meter_point (ARDOUR::Route&, ARDOUR::MeterPoint);
	gint meter_release (GdkEventButton*);
	gint meter_press (GdkEventButton*);
	bool wait_for_release;
	ARDOUR::MeterPoint old_meter_point;

	void meter_hold_changed();

	void reset_peak_display ();
	void reset_group_peak_display (ARDOUR::RouteGroup*);

	static sigc::signal<void> ResetAllPeakDisplays;
	static sigc::signal<void,ARDOUR::RouteGroup*> ResetGroupPeakDisplays;

	static Glib::RefPtr<Gdk::Pixbuf> slider;
	static Glib::RefPtr<Gdk::Pixbuf> rail;
	static int setup_slider_pix ();
};

#endif /* __ardour_gtk_gain_meter_h__ */