1 /*
2  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3  * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2006-2011 David Robillard <d@drobilla.net>
5  * Copyright (C) 2006 Nick Mainsbridge <mainsbridge@gmail.com>
6  * Copyright (C) 2007-2011 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
8  * Copyright (C) 2014-2017 Ben Loftis <ben@harrisonconsoles.com>
9  * Copyright (C) 2016-2017 Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef __ardour_mixer_strip__
27 #define __ardour_mixer_strip__
28 
29 #include <vector>
30 
31 #include <cmath>
32 
33 #include <gtkmm/adjustment.h>
34 #include <gtkmm/button.h>
35 #include <gtkmm/box.h>
36 #include <gtkmm/eventbox.h>
37 #include <gtkmm/frame.h>
38 #include <gtkmm/label.h>
39 #include <gtkmm/menu.h>
40 #include <gtkmm/sizegroup.h>
41 #include <gtkmm/textview.h>
42 #include <gtkmm/togglebutton.h>
43 
44 #include "pbd/stateful.h"
45 
46 #include "ardour/types.h"
47 #include "ardour/ardour.h"
48 #include "ardour/processor.h"
49 
50 #include "pbd/fastlog.h"
51 
52 #include "widgets/ardour_button.h"
53 #include "widgets/ardour_knob.h"
54 
55 #include "axis_view.h"
56 #include "control_slave_ui.h"
57 #include "io_button.h"
58 #include "route_ui.h"
59 #include "gain_meter.h"
60 #include "panner_ui.h"
61 #include "enums.h"
62 #include "processor_box.h"
63 #include "visibility_group.h"
64 
65 namespace ARDOUR {
66 	class Route;
67 	class Send;
68 	class Processor;
69 	class Session;
70 	class PortInsert;
71 	class Bundle;
72 	class Plugin;
73 }
74 namespace Gtk {
75 	class Window;
76 	class Style;
77 }
78 
79 class Mixer_UI;
80 class MotionController;
81 class RouteGroupMenu;
82 class ArdourWindow;
83 class AutomationController;
84 
85 class MixerStrip : public AxisView, public RouteUI, public Gtk::EventBox
86 {
87 public:
88 	MixerStrip (Mixer_UI&, ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>, bool in_mixer = true);
89 	MixerStrip (Mixer_UI&, ARDOUR::Session*, bool in_mixer = true);
90 	~MixerStrip ();
91 
92 	std::string name()  const;
93 	Gdk::Color color () const;
94 	bool marked_for_display () const;
95 	bool set_marked_for_display (bool);
96 
stripable()97 	boost::shared_ptr<ARDOUR::Stripable> stripable() const { return RouteUI::stripable(); }
98 
99 	void set_width_enum (Width, void* owner);
get_width_enum()100 	Width get_width_enum () const { return _width; }
width_owner()101 	void* width_owner () const { return _width_owner; }
102 
gain_meter()103 	GainMeter&      gain_meter()      { return gpm; }
panner_ui()104 	PannerUI&       panner_ui()       { return panners; }
105 	PluginSelector* plugin_selector();
106 
107 	void fast_update ();
108 	void set_embedded (bool);
109 
110 	void set_route (boost::shared_ptr<ARDOUR::Route>);
111 	void set_button_names ();
112 	void show_send (boost::shared_ptr<ARDOUR::Send>);
113 	void revert_to_default_display ();
114 
115 	/** @return the delivery that is being edited using our fader; it will be the
116 	 *  last send passed to \ref show_send() , or our route's main out delivery.
117 	 */
current_delivery()118 	boost::shared_ptr<ARDOUR::Delivery> current_delivery () const {
119 		return _current_delivery;
120 	}
121 
mixer_owned()122 	bool mixer_owned () const {
123 		return _mixer_owned;
124 	}
125 
126 	/* used for screenshots */
127 	void hide_master_spacer (bool);
128 
129 	void hide_things ();
130 
131 	sigc::signal<void> WidthChanged;
132 
133 	/** The delivery that we are handling the level for with our fader has changed */
134 	PBD::Signal1<void, boost::weak_ptr<ARDOUR::Delivery> > DeliveryChanged;
135 
136 	static PBD::Signal1<void,MixerStrip*> CatchDeletion;
137 
138 	std::string state_id() const;
139 
140 	void parameter_changed (std::string);
141 	void route_active_changed ();
142 
143 	void copy_processors ();
144 	void cut_processors ();
145 	void paste_processors ();
146 	void select_all_processors ();
147 	void deselect_all_processors ();
148 	bool delete_processors ();  //note: returns false if nothing was deleted
149 	void toggle_processors ();
150 	void ab_plugins ();
151 
152 	void set_selected (bool yn);
153 
entered_mixer_strip()154 	static MixerStrip* entered_mixer_strip() { return _entered_mixer_strip; }
155 
156 protected:
157 	friend class Mixer_UI;
158 	void set_packed (bool yn);
packed()159 	bool packed () { return _packed; }
160 
161 	void set_stuff_from_route ();
162 
163 private:
164 	Mixer_UI& _mixer;
165 
166 	void init ();
167 
168 	bool  _embedded;
169 	bool  _packed;
170 	bool  _mixer_owned;
171 	Width _width;
172 	void*  _width_owner;
173 
174 	ArdourWidgets::ArdourButton hide_button;
175 	ArdourWidgets::ArdourButton width_button;
176 	ArdourWidgets::ArdourButton number_label;
177 	Gtk::HBox                   width_hide_box;
178 	Gtk::EventBox               spacer;
179 
180 	void hide_clicked();
181 	bool width_button_pressed (GdkEventButton *);
182 
183 	Gtk::Frame          global_frame;
184 	Gtk::VBox           global_vpacker;
185 
186 	ProcessorBox processor_box;
187 	GainMeter    gpm;
188 	PannerUI     panners;
189 
190 	Glib::RefPtr<Gtk::SizeGroup> button_size_group;
191 
192 	Gtk::Table rec_mon_table;
193 	Gtk::Table solo_iso_table;
194 	Gtk::Table mute_solo_table;
195 	Gtk::Table master_volume_table;
196 	Gtk::Table bottom_button_table;
197 
198 	void vca_assign (boost::shared_ptr<ARDOUR::VCA>);
199 	void vca_unassign (boost::shared_ptr<ARDOUR::VCA>);
200 
201 	void meter_changed ();
202 	void monitor_changed ();
203 	void monitor_section_added_or_removed ();
204 
205 	IOButton input_button;
206 	IOButton output_button;
207 
208 	ArdourWidgets::ArdourButton* monitor_section_button;
209 
210 	void comment_button_resized (Gtk::Allocation&);
211 
212 	ArdourWidgets::ArdourButton* midi_input_enable_button;
213 	Gtk::HBox input_button_box;
214 
215 	std::string longest_label;
216 
217 	void midi_input_status_changed ();
218 	bool input_active_button_press (GdkEventButton*);
219 	bool input_active_button_release (GdkEventButton*);
220 
221 	void help_count_plugins (boost::weak_ptr<ARDOUR::Processor>);
222 	uint32_t _plugin_insert_cnt;
223 
224 	gint    mark_update_safe ();
225 	guint32 mode_switch_in_progress;
226 
227 	ArdourWidgets::ArdourButton name_button;
228 	ArdourWidgets::ArdourButton _comment_button;
229 	ArdourWidgets::ArdourKnob   trim_control;
230 
231 	Gtk::Menu* _master_volume_menu;
232 	ArdourWidgets::ArdourButton* _loudess_analysis_button;
233 	boost::shared_ptr<AutomationController> _volume_controller;
234 
235 	void trim_start_touch ();
236 	void trim_end_touch ();
237 
238 	void setup_comment_button ();
239 
240 	void loudess_analysis_button_clicked ();
241 	bool volume_controller_button_pressed (GdkEventButton*);
242 
243 	ArdourWidgets::ArdourButton group_button;
244 	RouteGroupMenu*             group_menu;
245 
246 	void io_changed_proxy ();
247 
248 	Gtk::Menu *send_action_menu;
249 	void build_send_action_menu ();
250 
251 	PBD::ScopedConnection panstate_connection;
252 	PBD::ScopedConnection panstyle_connection;
253 	void connect_to_pan ();
254 	void update_panner_choices ();
255 	void update_trim_control ();
256 
257 	void update_diskstream_display ();
258 	void update_input_display ();
259 	void update_output_display ();
260 
261 	void set_automated_controls_sensitivity (bool yn);
262 
263 	Gtk::Menu* route_ops_menu;
264 	void build_route_ops_menu ();
265 	gboolean name_button_button_press (GdkEventButton*);
266 	gboolean number_button_button_press (GdkEventButton*);
267 	void list_route_operations ();
268 
269 	bool select_route_group (GdkEventButton *);
270 	void route_group_changed ();
271 
272 	Gtk::Style *passthru_style;
273 
274 	void route_color_changed ();
275 	void show_passthru_color ();
276 
277 	void route_property_changed (const PBD::PropertyChange&);
278 	void name_button_resized (Gtk::Allocation&);
279 	void name_changed ();
280 	void update_speed_display ();
281 	void map_frozen ();
282 	void hide_processor_editor (boost::weak_ptr<ARDOUR::Processor> processor);
283 	void hide_redirect_editors ();
284 
285 	bool ignore_speed_adjustment;
286 
287 	static MixerStrip* _entered_mixer_strip;
288 
289 	virtual void bus_send_display_changed (boost::shared_ptr<ARDOUR::Route>);
290 
291 	void set_current_delivery (boost::shared_ptr<ARDOUR::Delivery>);
292 
293 	void drop_send ();
294 	PBD::ScopedConnection send_gone_connection;
295 
296 	void reset_strip_style ();
297 	void update_sensitivity ();
298 
299 	bool mixer_strip_enter_event ( GdkEventCrossing * );
300 	bool mixer_strip_leave_event ( GdkEventCrossing * );
301 
302 	/** A VisibilityGroup to manage the visibility of some of our controls.
303 	 *  We fill it with the controls that are being managed, using the same names
304 	 *  as those used with _mixer_strip_visibility in RCOptionEditor.  Then
305 	 *  this VisibilityGroup is configured by changes to the RC variable
306 	 *  mixer-element-visibility, which happen when the user makes changes in
307 	 *  the RC option editor.
308 	 */
309 	VisibilityGroup _visibility;
310 	boost::optional<bool> override_solo_visibility () const;
311 	boost::optional<bool> override_rec_mon_visibility () const;
312 
313 	PBD::ScopedConnectionList _config_connection;
314 
315 	void add_input_port (ARDOUR::DataType);
316 	void add_output_port (ARDOUR::DataType);
317 
318 	bool _suspend_menu_callbacks;
319 	bool level_meter_button_press (GdkEventButton *);
320 	void popup_level_meter_menu (GdkEventButton *);
321 	void add_level_meter_item_point (Gtk::Menu_Helpers::MenuList &, Gtk::RadioMenuItem::Group &, std::string const &, ARDOUR::MeterPoint);
322 	void add_level_meter_item_type (Gtk::Menu_Helpers::MenuList &, Gtk::RadioMenuItem::Group &, std::string const &, ARDOUR::MeterType);
323 	void set_meter_point (ARDOUR::MeterPoint);
324 	void set_meter_type (ARDOUR::MeterType);
325 	PBD::ScopedConnection _level_meter_connection;
326 
327 	std::string meter_point_string (ARDOUR::MeterPoint);
328 
329 	void update_track_number_visibility ();
330 
331 	ControlSlaveUI control_slave_ui;
332 };
333 
334 #endif /* __ardour_mixer_strip__ */
335