Monitor new signal to rebuild sendlist
[ardour.git] / gtk2_ardour / foldback_strip.h
1 /*
2     Copyright (C) 2018-2019 Len Ovens
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 #ifndef __ardour_foldback_strip__
20 #define __ardour_foldback_strip__
21
22 #include <vector>
23
24 #include <cmath>
25
26 #include <gtkmm/adjustment.h>
27 #include <gtkmm/button.h>
28 #include <gtkmm/box.h>
29 #include <gtkmm/eventbox.h>
30 #include <gtkmm/frame.h>
31 #include <gtkmm/label.h>
32 #include <gtkmm/menu.h>
33 #include <gtkmm/sizegroup.h>
34 #include <gtkmm/textview.h>
35 #include <gtkmm/togglebutton.h>
36
37 #include "pbd/stateful.h"
38
39 #include "ardour/types.h"
40 #include "ardour/ardour.h"
41 #include "ardour/processor.h"
42
43 #include "pbd/fastlog.h"
44
45 #include "widgets/ardour_button.h"
46 #include "widgets/ardour_knob.h"
47
48 #include "axis_view.h"
49 #include "route_ui.h"
50 #include "panner_ui.h"
51 #include "enums.h"
52 #include "processor_box.h"
53 //#include "visibility_group.h"
54 #include "processor_selection.h"
55
56 namespace ARDOUR {
57         class Route;
58         class Send;
59         class Processor;
60         class Session;
61         class PortInsert;
62         class Bundle;
63         class Plugin;
64 }
65 namespace Gtk {
66         class Window;
67         class Style;
68 }
69
70 class Mixer_UI;
71 class MotionController;
72 class RouteGroupMenu;
73 class ArdourWindow;
74
75 class FoldbackSend : public Gtk::VBox
76 {
77 public:
78         FoldbackSend (boost::shared_ptr<ARDOUR::Send>, \
79                 boost::shared_ptr<ARDOUR::Route> sr, boost::shared_ptr<ARDOUR::Route> fr);
80         ~FoldbackSend ();
81
82 private:
83         ArdourWidgets::ArdourButton _button;
84         boost::shared_ptr<ARDOUR::Send> _send;
85         boost::shared_ptr<ARDOUR::Route> _send_route;
86         boost::shared_ptr<ARDOUR::Route> _foldback_route;
87         boost::shared_ptr<ARDOUR::Processor> _send_proc;
88         boost::shared_ptr<ARDOUR::Delivery> _send_del;
89
90         void led_clicked(GdkEventButton *);
91         void send_state_changed ();
92         void level_adjusted ();
93         void level_changed ();
94         void set_tooltip ();
95         ArdourWidgets::ArdourKnob   pan_control;
96         Gtk::Adjustment _adjustment;
97         ArdourWidgets::HSliderController _slider;
98         bool _ignore_ui_adjustment;
99         Gtkmm2ext::PersistentTooltip _slider_persistant_tooltip;
100
101         PBD::ScopedConnectionList _connections;
102
103
104
105 };
106
107 class FoldbackStrip : public AxisView, public RouteUI, public Gtk::EventBox
108 {
109 public:
110         FoldbackStrip (Mixer_UI&, ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>);
111         ~FoldbackStrip ();
112
113         std::string name()  const;
114         Gdk::Color color () const;
115
116         boost::shared_ptr<ARDOUR::Stripable> stripable() const { return RouteUI::stripable(); }
117
118         void* width_owner () const { return _width_owner; }
119
120         PannerUI&       panner_ui()       { return panners; }
121         PluginSelector* plugin_selector();
122
123         void fast_update ();
124         void set_embedded (bool);
125
126         void set_route (boost::shared_ptr<ARDOUR::Route>);
127         void set_button_names ();
128         void revert_to_default_display ();
129
130         /** @return the delivery that is being edited using our fader; it will be the
131          *  last send passed to ::show_send, or our route's main out delivery.
132          */
133         boost::shared_ptr<ARDOUR::Delivery> current_delivery () const {
134                 return _current_delivery;
135         }
136
137         bool mixer_owned () const {
138                 return _mixer_owned;
139         }
140
141         /** The delivery that we are handling the level for with our fader has changed */
142         PBD::Signal1<void, boost::weak_ptr<ARDOUR::Delivery> > DeliveryChanged;
143
144         static PBD::Signal1<void,FoldbackStrip*> CatchDeletion;
145
146         std::string state_id() const;
147
148 //      void parameter_changed (std::string);
149         void route_active_changed ();
150
151         void copy_processors ();
152         void cut_processors ();
153         void paste_processors ();
154         void select_all_processors ();
155         void deselect_all_processors ();
156         bool delete_processors ();  //note: returns false if nothing was deleted
157         void toggle_processors ();
158         void ab_plugins ();
159
160         void set_selected (bool yn);
161
162         static FoldbackStrip* entered_foldback_strip() { return _entered_foldback_strip; }
163
164 protected:
165         friend class Mixer_UI;
166         void set_packed (bool yn);
167         bool packed () { return _packed; }
168
169         void set_stuff_from_route ();
170
171 private:
172         Mixer_UI& _mixer;
173         void init ();
174
175         bool  _embedded;
176         bool  _packed;
177         bool  _mixer_owned;
178         Width _width;
179         void*  _width_owner;
180         ARDOUR::Session* _session;
181
182         Gtk::EventBox           spacer;
183         Gtk::VBox                       send_display;
184         Gtk::ScrolledWindow     send_scroller;
185
186         Gtk::Frame          global_frame;
187         Gtk::VBox           global_vpacker;
188
189         ProcessorBox* insert_box;
190         ProcessorSelection _pr_selection;
191         PannerUI     panners;
192
193         Gtk::Table mute_solo_table;
194         Gtk::Table bottom_button_table;
195
196         ArdourWidgets::ArdourButton output_button;
197
198         Gtk::HBox show_sends_box;
199
200         std::string longest_label;
201
202         void help_count_plugins (boost::weak_ptr<ARDOUR::Processor>);
203         uint32_t _plugin_insert_cnt;
204
205         gint    mark_update_safe ();
206         guint32 mode_switch_in_progress;
207
208         ArdourWidgets::ArdourButton name_button;
209         ArdourWidgets::ArdourButton _select_button;
210         ArdourWidgets::ArdourButton _comment_button;
211         ArdourWidgets::ArdourKnob*   fb_level_control;
212
213         void setup_comment_button ();
214
215         gint output_press (GdkEventButton *);
216         gint output_release (GdkEventButton *);
217
218         Gtk::Menu output_menu;
219         std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
220         void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &,
221                                               ARDOUR::DataType type = ARDOUR::DataType::NIL);
222
223         void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>);
224
225         void io_changed_proxy ();
226
227         Gtk::Menu *send_action_menu;
228         void build_send_action_menu ();
229
230         PBD::ScopedConnection panstate_connection;
231         PBD::ScopedConnection panstyle_connection;
232         void connect_to_pan ();
233         void update_panner_choices ();
234         void update_fb_level_control ();
235
236         void update_output_display ();
237         void update_send_box ();
238         void processors_changed (ARDOUR::RouteProcessorChange);
239         void clear_send_box ();
240
241         void set_automated_controls_sensitivity (bool yn);
242
243         Gtk::Menu* route_ops_menu;
244         void build_route_ops_menu ();
245         gboolean name_button_button_press (GdkEventButton*);
246         void list_route_operations ();
247
248         Gtk::Menu* route_select_menu;
249         void build_route_select_menu ();
250         gboolean select_button_button_press (GdkEventButton*);
251         void list_fb_routes ();
252
253         void build_sends_menu ();
254         void remove_current_fb ();
255
256         Gtk::Style *passthru_style;
257
258         void show_passthru_color ();
259
260         void route_property_changed (const PBD::PropertyChange&);
261         void name_changed ();
262         void update_speed_display ();
263         void map_frozen ();
264         void hide_processor_editor (boost::weak_ptr<ARDOUR::Processor> processor);
265         void hide_redirect_editors ();
266
267         bool ignore_speed_adjustment;
268
269         static FoldbackStrip* _entered_foldback_strip;
270
271         void engine_running();
272         void engine_stopped();
273
274 //      virtual void bus_send_display_changed (boost::shared_ptr<ARDOUR::Route>);
275
276         void set_current_delivery (boost::shared_ptr<ARDOUR::Delivery>);
277
278         void drop_send ();
279         PBD::ScopedConnection send_gone_connection;
280
281         void reset_strip_style ();
282
283         ARDOUR::DataType guess_main_type(bool for_input, bool favor_connected = true) const;
284
285         void update_io_button ();
286         void port_connected_or_disconnected (boost::weak_ptr<ARDOUR::Port>, boost::weak_ptr<ARDOUR::Port>);
287
288         bool mixer_strip_enter_event ( GdkEventCrossing * );
289         bool mixer_strip_leave_event ( GdkEventCrossing * );
290
291         void add_output_port (ARDOUR::DataType);
292
293         bool _suspend_menu_callbacks;
294         PBD::ScopedConnectionList _connections;
295
296 };
297
298 #endif /* __ardour_foldback_strip__ */