new ArdourButton class, to start to provide more control over how our buttons work...
[ardour.git] / gtk2_ardour / mixer_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_mixer_strip__
20 #define __ardour_mixer_strip__
21
22 #include <vector>
23
24 #include <cmath>
25
26 #include <gtkmm/eventbox.h>
27 #include <gtkmm/button.h>
28 #include <gtkmm/box.h>
29 #include <gtkmm/frame.h>
30 #include <gtkmm/button.h>
31 #include <gtkmm/label.h>
32 #include <gtkmm/togglebutton.h>
33 #include <gtkmm/menu.h>
34 #include <gtkmm/textview.h>
35 #include <gtkmm/adjustment.h>
36
37 #include "gtkmm2ext/auto_spin.h"
38 #include "gtkmm2ext/click_box.h"
39 #include "gtkmm2ext/bindable_button.h"
40 #include "gtkmm2ext/stateful_button.h"
41
42 #include "pbd/stateful.h"
43
44 #include "ardour/types.h"
45 #include "ardour/ardour.h"
46 #include "ardour/processor.h"
47
48 #include "pbd/fastlog.h"
49
50 #include "route_ui.h"
51 #include "gain_meter.h"
52 #include "panner_ui.h"
53 #include "enums.h"
54 #include "processor_box.h"
55 #include "ardour_dialog.h"
56
57 namespace ARDOUR {
58         class Route;
59         class Send;
60         class Processor;
61         class Session;
62         class PortInsert;
63         class Bundle;
64         class Plugin;
65 }
66 namespace Gtk {
67         class Window;
68         class Style;
69 }
70
71 class Mixer_UI;
72 class IOSelectorWindow;
73 class MotionController;
74 class RouteGroupMenu;
75
76 class MixerStrip : public RouteUI, public Gtk::EventBox
77 {
78   public:
79         MixerStrip (Mixer_UI&, ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>, bool in_mixer = true);
80         MixerStrip (Mixer_UI&, ARDOUR::Session*, bool in_mixer = true);
81         ~MixerStrip ();
82
83         void set_width_enum (Width, void* owner);
84         Width get_width_enum () const { return _width; }
85         void* width_owner () const { return _width_owner; }
86
87         GainMeter&      gain_meter()      { return gpm; }
88         PannerUI&       panner_ui()       { return panners; }
89         PluginSelector* plugin_selector();
90
91         void fast_update ();
92         void set_embedded (bool);
93
94         ARDOUR::RouteGroup* route_group() const;
95         void set_route (boost::shared_ptr<ARDOUR::Route>);
96         void set_button_names ();
97         void show_send (boost::shared_ptr<ARDOUR::Send>);
98         void revert_to_default_display ();
99
100         /** @return the delivery that is being edited using our fader; it will be the
101          *  last send passed to ::show_send, or our route's main out delivery.
102          */
103         boost::shared_ptr<ARDOUR::Delivery> current_delivery () const {
104                 return _current_delivery;
105         }
106
107         bool mixer_owned () const {
108                 return _mixer_owned;
109         }
110
111         void hide_things ();
112
113         sigc::signal<void> WidthChanged;
114
115         /** The delivery that we are handling the level for with our fader has changed */
116         PBD::Signal1<void, boost::weak_ptr<ARDOUR::Delivery> > DeliveryChanged;
117
118         static sigc::signal<void,boost::shared_ptr<ARDOUR::Route> > SwitchIO;
119         static PBD::Signal1<void,MixerStrip*> CatchDeletion;
120
121         std::string state_id() const;
122
123   protected:
124         friend class Mixer_UI;
125         void set_packed (bool yn);
126         bool packed () { return _packed; }
127
128         void set_selected(bool yn);
129         void set_stuff_from_route ();
130
131         bool on_leave_notify_event (GdkEventCrossing* ev);
132         bool on_enter_notify_event (GdkEventCrossing* ev);
133         bool on_key_press_event (GdkEventKey* ev);
134         bool on_key_release_event (GdkEventKey* ev);
135
136   private:
137         Mixer_UI& _mixer;
138
139         void init ();
140
141         bool  _embedded;
142         bool  _packed;
143         bool  _mixer_owned;
144         Width _width;
145         void*  _width_owner;
146
147         Gtk::Button         hide_button;
148         Gtk::Button         width_button;
149         Gtk::HBox           width_hide_box;
150         Gtk::VBox           whvbox;
151         Gtk::EventBox       top_event_box;
152         Gtk::EventBox*      spacer;
153
154         void hide_clicked();
155         void width_clicked ();
156
157         Gtk::Frame          global_frame;
158         Gtk::VBox           global_vpacker;
159
160         ProcessorBox processor_box;
161         GainMeter    gpm;
162         PannerUI     panners;
163
164         Gtk::Table button_table;
165         Gtk::Table rec_solo_table;
166         Gtk::Table top_button_table;
167         Gtk::Table middle_button_table;
168         Gtk::Table bottom_button_table;
169
170         Gtk::Button                  gain_unit_button;
171         Gtk::Label                   gain_unit_label;
172         Gtk::Button                  meter_point_button;
173         Gtk::Label                   meter_point_label;
174
175         void meter_changed ();
176
177         Gtk::Button diskstream_button;
178         Gtk::Label  diskstream_label;
179
180         Gtk::Button input_button;
181         Gtkmm2ext::StatefulToggleButton* midi_input_enable_button;
182         Gtk::HBox   input_button_box;
183         Gtk::Label  input_label;
184         Gtk::Button output_button;
185         Gtk::Label  output_label;
186
187         std::string longest_label;
188
189         void midi_input_status_changed ();
190         bool input_active_button_press (GdkEventButton*);
191         bool input_active_button_release (GdkEventButton*);
192
193         gint    mark_update_safe ();
194         guint32 mode_switch_in_progress;
195
196         Gtk::Button   name_button;
197
198         ArdourDialog*  comment_window;
199         Gtk::TextView* comment_area;
200
201         void comment_editor_done_editing ();
202         void setup_comment_editor ();
203         void toggle_comment ();
204
205         Gtk::Button   group_button;
206         Gtk::Label    group_label;
207         RouteGroupMenu *group_menu;
208
209         gint input_press (GdkEventButton *);
210         gint output_press (GdkEventButton *);
211
212         Gtk::Menu input_menu;
213         std::list<boost::shared_ptr<ARDOUR::Bundle> > input_menu_bundles;
214         void maybe_add_bundle_to_input_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &);
215
216         Gtk::Menu output_menu;
217         std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
218         void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &);
219
220         void bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle>);
221         void bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle>);
222
223         void edit_input_configuration ();
224         void edit_output_configuration ();
225
226         void diskstream_changed ();
227
228         Gtk::Menu *send_action_menu;
229         Gtk::CheckMenuItem* _comment_menu_item;
230         Gtk::MenuItem* rename_menu_item;
231         void build_send_action_menu ();
232
233         void new_send ();
234         void show_send_controls ();
235
236         PBD::ScopedConnection panstate_connection;
237         PBD::ScopedConnection panstyle_connection;
238         void connect_to_pan ();
239
240         void update_diskstream_display ();
241         void update_input_display ();
242         void update_output_display ();
243
244         void set_automated_controls_sensitivity (bool yn);
245
246         Gtk::Menu* route_ops_menu;
247         void build_route_ops_menu ();
248         gboolean name_button_button_press (GdkEventButton*);
249         void list_route_operations ();
250
251         gint comment_key_release_handler (GdkEventKey*);
252         void comment_changed (void *src);
253         void comment_edited ();
254         bool ignore_comment_edit;
255
256         bool select_route_group (GdkEventButton *);
257         void route_group_changed ();
258
259         IOSelectorWindow *input_selector;
260         IOSelectorWindow *output_selector;
261
262         Gtk::Style *passthru_style;
263
264         void route_color_changed ();
265         void show_passthru_color ();
266
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         void engine_running();
276         void engine_stopped();
277
278         void switch_io (boost::shared_ptr<ARDOUR::Route>);
279
280         void set_current_delivery (boost::shared_ptr<ARDOUR::Delivery>);
281         boost::shared_ptr<ARDOUR::Delivery> _current_delivery;
282
283         void drop_send ();
284         PBD::ScopedConnection send_gone_connection;
285
286         void reset_strip_style ();
287
288         static int scrollbar_height;
289
290         void update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool input_button);
291         void port_connected_or_disconnected (ARDOUR::Port *, ARDOUR::Port *);
292
293         static std::string meter_point_string (ARDOUR::MeterPoint);
294 };
295
296 #endif /* __ardour_mixer_strip__ */