Fix thinkos in cubasish theme
[ardour.git] / gtk2_ardour / mixer_strip.h
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 "route_ui.h"
58 #include "gain_meter.h"
59 #include "panner_ui.h"
60 #include "enums.h"
61 #include "processor_box.h"
62 #include "visibility_group.h"
63
64 namespace ARDOUR {
65         class Route;
66         class Send;
67         class Processor;
68         class Session;
69         class PortInsert;
70         class Bundle;
71         class Plugin;
72 }
73 namespace Gtk {
74         class Window;
75         class Style;
76 }
77
78 class Mixer_UI;
79 class MotionController;
80 class RouteGroupMenu;
81 class ArdourWindow;
82
83 class MixerStrip : public AxisView, public RouteUI, public Gtk::EventBox
84 {
85 public:
86         MixerStrip (Mixer_UI&, ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>, bool in_mixer = true);
87         MixerStrip (Mixer_UI&, ARDOUR::Session*, bool in_mixer = true);
88         ~MixerStrip ();
89
90         std::string name()  const;
91         Gdk::Color color () const;
92         bool marked_for_display () const;
93         bool set_marked_for_display (bool);
94
95         boost::shared_ptr<ARDOUR::Stripable> stripable() const { return RouteUI::stripable(); }
96
97         void set_width_enum (Width, void* owner);
98         Width get_width_enum () const { return _width; }
99         void* width_owner () const { return _width_owner; }
100
101         GainMeter&      gain_meter()      { return gpm; }
102         PannerUI&       panner_ui()       { return panners; }
103         PluginSelector* plugin_selector();
104
105         void fast_update ();
106         void set_embedded (bool);
107
108         void set_route (boost::shared_ptr<ARDOUR::Route>);
109         void set_button_names ();
110         void show_send (boost::shared_ptr<ARDOUR::Send>);
111         void revert_to_default_display ();
112
113         /** @return the delivery that is being edited using our fader; it will be the
114          *  last send passed to \ref show_send() , or our route's main out delivery.
115          */
116         boost::shared_ptr<ARDOUR::Delivery> current_delivery () const {
117                 return _current_delivery;
118         }
119
120         bool mixer_owned () const {
121                 return _mixer_owned;
122         }
123
124         /* used for screenshots */
125         void hide_master_spacer (bool);
126
127         void hide_things ();
128
129         sigc::signal<void> WidthChanged;
130
131         /** The delivery that we are handling the level for with our fader has changed */
132         PBD::Signal1<void, boost::weak_ptr<ARDOUR::Delivery> > DeliveryChanged;
133
134         static PBD::Signal1<void,MixerStrip*> CatchDeletion;
135
136         std::string state_id() const;
137
138         void parameter_changed (std::string);
139         void route_active_changed ();
140
141         void copy_processors ();
142         void cut_processors ();
143         void paste_processors ();
144         void select_all_processors ();
145         void deselect_all_processors ();
146         bool delete_processors ();  //note: returns false if nothing was deleted
147         void toggle_processors ();
148         void ab_plugins ();
149
150         void set_selected (bool yn);
151
152         static MixerStrip* entered_mixer_strip() { return _entered_mixer_strip; }
153
154 protected:
155         friend class Mixer_UI;
156         void set_packed (bool yn);
157         bool packed () { return _packed; }
158
159         void set_stuff_from_route ();
160
161 private:
162         Mixer_UI& _mixer;
163
164         void init ();
165
166         bool  _embedded;
167         bool  _packed;
168         bool  _mixer_owned;
169         Width _width;
170         void*  _width_owner;
171
172         ArdourWidgets::ArdourButton hide_button;
173         ArdourWidgets::ArdourButton width_button;
174         ArdourWidgets::ArdourButton number_label;
175         Gtk::HBox                   width_hide_box;
176         Gtk::EventBox               spacer;
177
178         void hide_clicked();
179         bool width_button_pressed (GdkEventButton *);
180
181         Gtk::Frame          global_frame;
182         Gtk::VBox           global_vpacker;
183
184         ProcessorBox processor_box;
185         GainMeter    gpm;
186         PannerUI     panners;
187
188         Glib::RefPtr<Gtk::SizeGroup> button_size_group;
189
190         Gtk::Table rec_mon_table;
191         Gtk::Table solo_iso_table;
192         Gtk::Table mute_solo_table;
193         Gtk::Table bottom_button_table;
194
195         void vca_assign (boost::shared_ptr<ARDOUR::VCA>);
196         void vca_unassign (boost::shared_ptr<ARDOUR::VCA>);
197
198         void meter_changed ();
199         void monitor_changed ();
200         void monitor_section_added_or_removed ();
201
202         ArdourWidgets::ArdourButton input_button;
203         ArdourWidgets::ArdourButton output_button;
204
205         ArdourWidgets::ArdourButton* monitor_section_button;
206
207         void input_button_resized (Gtk::Allocation&);
208         void output_button_resized (Gtk::Allocation&);
209         void comment_button_resized (Gtk::Allocation&);
210
211         ArdourWidgets::ArdourButton* midi_input_enable_button;
212         Gtk::HBox input_button_box;
213
214         std::string longest_label;
215
216         void midi_input_status_changed ();
217         bool input_active_button_press (GdkEventButton*);
218         bool input_active_button_release (GdkEventButton*);
219
220         void help_count_plugins (boost::weak_ptr<ARDOUR::Processor>);
221         uint32_t _plugin_insert_cnt;
222
223         gint    mark_update_safe ();
224         guint32 mode_switch_in_progress;
225
226         ArdourWidgets::ArdourButton name_button;
227         ArdourWidgets::ArdourButton _comment_button;
228         ArdourWidgets::ArdourKnob   trim_control;
229
230         void trim_start_touch ();
231         void trim_end_touch ();
232
233         void setup_comment_button ();
234
235         ArdourWidgets::ArdourButton group_button;
236         RouteGroupMenu*             group_menu;
237
238         gint input_press (GdkEventButton *);
239         gint input_release (GdkEventButton *);
240
241         gint output_press (GdkEventButton *);
242         gint output_release (GdkEventButton *);
243
244         Gtk::Menu input_menu;
245         std::list<boost::shared_ptr<ARDOUR::Bundle> > input_menu_bundles;
246         void maybe_add_bundle_to_input_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &);
247
248         Gtk::Menu output_menu;
249         std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
250         void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &,
251                                               ARDOUR::DataType type = ARDOUR::DataType::NIL);
252
253         void bundle_input_chosen (boost::shared_ptr<ARDOUR::Bundle>);
254         void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>);
255
256         void diskstream_changed ();
257         void io_changed_proxy ();
258
259         Gtk::Menu *send_action_menu;
260         void build_send_action_menu ();
261
262         PBD::ScopedConnection panstate_connection;
263         PBD::ScopedConnection panstyle_connection;
264         void connect_to_pan ();
265         void update_panner_choices ();
266         void update_trim_control ();
267
268         void update_diskstream_display ();
269         void update_input_display ();
270         void update_output_display ();
271
272         void set_automated_controls_sensitivity (bool yn);
273
274         Gtk::Menu* route_ops_menu;
275         void build_route_ops_menu ();
276         gboolean name_button_button_press (GdkEventButton*);
277         gboolean number_button_button_press (GdkEventButton*);
278         void list_route_operations ();
279
280         bool select_route_group (GdkEventButton *);
281         void route_group_changed ();
282
283         Gtk::Style *passthru_style;
284
285         void route_color_changed ();
286         void show_passthru_color ();
287
288         void route_property_changed (const PBD::PropertyChange&);
289         void name_button_resized (Gtk::Allocation&);
290         void name_changed ();
291         void update_speed_display ();
292         void map_frozen ();
293         void hide_processor_editor (boost::weak_ptr<ARDOUR::Processor> processor);
294         void hide_redirect_editors ();
295
296         bool ignore_speed_adjustment;
297
298         static MixerStrip* _entered_mixer_strip;
299
300         virtual void bus_send_display_changed (boost::shared_ptr<ARDOUR::Route>);
301
302         void set_current_delivery (boost::shared_ptr<ARDOUR::Delivery>);
303
304         void drop_send ();
305         PBD::ScopedConnection send_gone_connection;
306
307         void reset_strip_style ();
308
309         ARDOUR::DataType guess_main_type(bool for_input, bool favor_connected = true) const;
310
311         void update_io_button (bool input_button);
312         void port_connected_or_disconnected (boost::weak_ptr<ARDOUR::Port>, boost::weak_ptr<ARDOUR::Port>);
313
314         bool mixer_strip_enter_event ( GdkEventCrossing * );
315         bool mixer_strip_leave_event ( GdkEventCrossing * );
316
317         /** A VisibilityGroup to manage the visibility of some of our controls.
318          *  We fill it with the controls that are being managed, using the same names
319          *  as those used with _mixer_strip_visibility in RCOptionEditor.  Then
320          *  this VisibilityGroup is configured by changes to the RC variable
321          *  mixer-element-visibility, which happen when the user makes changes in
322          *  the RC option editor.
323          */
324         VisibilityGroup _visibility;
325         boost::optional<bool> override_solo_visibility () const;
326
327         PBD::ScopedConnectionList _config_connection;
328
329         void add_input_port (ARDOUR::DataType);
330         void add_output_port (ARDOUR::DataType);
331
332         bool _suspend_menu_callbacks;
333         bool level_meter_button_press (GdkEventButton *);
334         void popup_level_meter_menu (GdkEventButton *);
335         void add_level_meter_item_point (Gtk::Menu_Helpers::MenuList &, Gtk::RadioMenuItem::Group &, std::string const &, ARDOUR::MeterPoint);
336         void add_level_meter_item_type (Gtk::Menu_Helpers::MenuList &, Gtk::RadioMenuItem::Group &, std::string const &, ARDOUR::MeterType);
337         void set_meter_point (ARDOUR::MeterPoint);
338         void set_meter_type (ARDOUR::MeterType);
339         PBD::ScopedConnection _level_meter_connection;
340
341         std::string meter_point_string (ARDOUR::MeterPoint);
342
343         void update_track_number_visibility ();
344
345         ControlSlaveUI control_slave_ui;
346 };
347
348 #endif /* __ardour_mixer_strip__ */