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