Add strip GUI first try for foldback bus
[ardour.git] / gtk2_ardour / foldback_strip.h
1 /*
2     Copyright (C) 2000-2006 Paul Davis
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> // test
34 #include <gtkmm/sizegroup.h>
35 #include <gtkmm/table.h>
36 #include <gtkmm/textview.h>
37 #include <gtkmm/togglebutton.h>
38
39 #include "pbd/stateful.h"
40
41 #include "ardour/types.h"
42 #include "ardour/ardour.h"
43 #include "ardour/processor.h"
44
45 #include "pbd/fastlog.h"
46
47 #include "widgets/ardour_button.h"
48 #include "widgets/ardour_knob.h"
49
50 #include "axis_view.h"
51 #include "route_ui.h"
52 #include "panner_ui.h"
53 #include "enums.h"
54 namespace ARDOUR {
55         class Route;
56         class Send;
57         class Processor;
58         class Session;
59         class PortInsert;
60         class Bundle;
61         class Plugin;
62 }
63 namespace Gtk {
64         class Window;
65         class Style;
66 }
67
68 class Mixer_UI;
69 class MotionController;
70 class RouteGroupMenu;
71 class ArdourWindow;
72
73 class FoldbackStrip : public AxisView, public RouteUI, public Gtk::EventBox
74 {
75 public:
76         FoldbackStrip (Mixer_UI&, ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>);
77         ~FoldbackStrip ();
78
79         std::string name()  const;
80         Gdk::Color color () const;
81
82         boost::shared_ptr<ARDOUR::Stripable> stripable() const { return RouteUI::stripable(); }
83
84         void* width_owner () const { return _width_owner; }
85
86         PannerUI&       panner_ui()       { return panners; }
87
88         void fast_update ();
89         void set_embedded (bool);
90
91         void set_route (boost::shared_ptr<ARDOUR::Route>);
92         void set_button_names ();
93         void revert_to_default_display ();
94
95         /** @return the delivery that is being edited using our fader; it will be the
96          *  last send passed to ::show_send, or our route's main out delivery.
97          */
98         boost::shared_ptr<ARDOUR::Delivery> current_delivery () const {
99                 return _current_delivery;
100         }
101
102         bool mixer_owned () const {
103                 return _mixer_owned;
104         }
105
106         /** The delivery that we are handling the level for with our fader has changed */
107         PBD::Signal1<void, boost::weak_ptr<ARDOUR::Delivery> > DeliveryChanged;
108
109         static PBD::Signal1<void,FoldbackStrip*> CatchDeletion;
110
111         std::string state_id() const;
112
113         void route_active_changed ();
114
115         static FoldbackStrip* entered_foldback_strip() { return _entered_foldback_strip; }
116
117 protected:
118         friend class Mixer_UI;
119         void set_packed (bool yn);
120         bool packed () { return _packed; }
121
122         void set_stuff_from_route ();
123
124 private:
125         Mixer_UI& _mixer;
126
127         void init ();
128
129         bool  _embedded;
130         bool  _packed;
131         bool  _mixer_owned;
132         Width _width;
133         void*  _width_owner;
134
135         Gtk::EventBox           spacer;
136         Gtk::VBox                       send_display;
137
138         Gtk::Frame          global_frame;
139         Gtk::VBox           global_vpacker;
140
141         PannerUI     panners;
142
143         Glib::RefPtr<Gtk::SizeGroup> button_size_group;
144
145         Gtk::Table mute_solo_table;
146         Gtk::Table bottom_button_table;
147
148         ArdourWidgets::ArdourButton output_button;
149
150         void output_button_resized (Gtk::Allocation&);
151         void comment_button_resized (Gtk::Allocation&);
152
153         Gtk::HBox show_sends_box;
154
155         std::string longest_label;
156
157         gint    mark_update_safe ();
158         guint32 mode_switch_in_progress;
159
160         ArdourWidgets::ArdourButton name_button;
161         ArdourWidgets::ArdourButton _select_button;
162         ArdourWidgets::ArdourButton _comment_button;
163         ArdourWidgets::ArdourKnob*   fb_level_control;
164
165         void setup_comment_button ();
166
167         gint output_press (GdkEventButton *);
168         gint output_release (GdkEventButton *);
169
170         Gtk::Menu output_menu;
171         std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
172         void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &,
173                                               ARDOUR::DataType type = ARDOUR::DataType::NIL);
174
175         void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>);
176
177         void io_changed_proxy ();
178
179         Gtk::Menu *send_action_menu;
180         void build_send_action_menu ();
181
182         PBD::ScopedConnection panstate_connection;
183         PBD::ScopedConnection panstyle_connection;
184         void connect_to_pan ();
185         void update_panner_choices ();
186         void update_fb_level_control ();
187
188         void update_output_display ();
189
190         void set_automated_controls_sensitivity (bool yn);
191
192         Gtk::Menu* route_ops_menu;
193         void build_route_ops_menu ();
194         gboolean name_button_button_press (GdkEventButton*);
195         void list_route_operations ();
196
197         Gtk::Menu* route_select_menu;
198         void build_route_select_menu ();
199         gboolean select_button_button_press (GdkEventButton*);
200         void list_fb_routes ();
201
202         void build_sends_menu ();
203         void remove_current_fb ();
204
205         Gtk::Style *passthru_style;
206
207         void show_passthru_color ();
208
209         void route_property_changed (const PBD::PropertyChange&);
210         void name_button_resized (Gtk::Allocation&);
211         void name_changed ();
212         void update_speed_display ();
213         void map_frozen ();
214         void hide_redirect_editors ();
215
216         bool ignore_speed_adjustment;
217
218         static FoldbackStrip* _entered_foldback_strip;
219
220         void engine_running();
221         void engine_stopped();
222
223         void set_current_delivery (boost::shared_ptr<ARDOUR::Delivery>);
224
225         void drop_send ();
226         PBD::ScopedConnection send_gone_connection;
227
228         void reset_strip_style ();
229
230         ARDOUR::DataType guess_main_type(bool for_input, bool favor_connected = true) const;
231
232         void update_io_button ();
233         void port_connected_or_disconnected (boost::weak_ptr<ARDOUR::Port>, boost::weak_ptr<ARDOUR::Port>);
234
235         bool mixer_strip_enter_event ( GdkEventCrossing * );
236         bool mixer_strip_leave_event ( GdkEventCrossing * );
237
238         void add_output_port (ARDOUR::DataType);
239
240         bool _suspend_menu_callbacks;
241 };
242
243 #endif /* __ardour_foldback_strip__ */