Use the frame corresponding to the current mouse position when zoom dragging
[ardour.git] / gtk2_ardour / monitor_section.h
1 /*
2     Copyright (C) 2010 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
20 #include <gtkmm/box.h>
21 #include <gtkmm/table.h>
22 #include <gtkmm/eventbox.h>
23
24 #include "gtkmm2ext/bindable_button.h"
25 #include "gtkmm2ext/bindings.h"
26
27 #include "ardour_button.h"
28 #include "ardour_knob.h"
29 #include "ardour_display.h"
30 #include "level_meter.h"
31 #include "route_ui.h"
32 #include "monitor_selector.h"
33
34 #include "plugin_selector.h"
35 #include "route_processor_selection.h"
36 #include "processor_box.h"
37
38 namespace Gtkmm2ext {
39         class TearOff;
40 }
41
42 class MonitorSection : public RouteUI, public Gtk::EventBox
43 {
44   public:
45         MonitorSection (ARDOUR::Session*);
46         ~MonitorSection ();
47
48         void set_session (ARDOUR::Session*);
49
50         Gtkmm2ext::TearOff& tearoff() const { return *_tearoff; }
51
52         std::string state_id() const;
53
54         PluginSelector* plugin_selector() { return _plugin_selector; }
55
56         private:
57         Gtk::HBox hpacker;
58         Gtk::VBox vpacker;
59         Gtkmm2ext::TearOff* _tearoff;
60
61         Gtk::HBox  channel_table_packer;
62         Gtk::HBox  table_hpacker;
63         Gtk::HBox  master_packer;
64         Gtk::Table channel_table;
65         Gtk::Table channel_table_header;
66         Gtk::ScrolledWindow channel_table_scroller;
67         Gtk::Viewport channel_table_viewport;
68         Glib::RefPtr<Gtk::SizeGroup> channel_size_group;
69
70         struct ChannelButtonSet {
71                 ArdourButton cut;
72                 ArdourButton dim;
73                 ArdourButton solo;
74                 ArdourButton invert;
75
76                 ChannelButtonSet ();
77         };
78
79         typedef std::vector<ChannelButtonSet*> ChannelButtons;
80         ChannelButtons _channel_buttons;
81
82         ArdourKnob* gain_control;
83         ArdourKnob* dim_control;
84         ArdourKnob* solo_boost_control;
85         ArdourKnob* solo_cut_control;
86
87         ArdourDisplay*  gain_display;
88         ArdourDisplay*  dim_display;
89         ArdourDisplay*  solo_boost_display;
90         ArdourDisplay*  solo_cut_display;
91
92         std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
93         Gtk::Menu output_menu;
94         MonitorSelectorWindow *_output_selector;
95         ArdourButton* output_button;
96
97         void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &);
98         void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>);
99         void update_output_display ();
100         void disconnect_output ();
101         void edit_output_configuration ();
102
103         void populate_buttons ();
104         void map_state ();
105
106         boost::shared_ptr<ARDOUR::MonitorProcessor> _monitor;
107         boost::shared_ptr<ARDOUR::Route> _route;
108
109         enum MonitorActions {
110                 MonitorMono,
111                 MonitorCutAll,
112                 MonitorDimAll,
113                 ToggleExclusiveSolo,
114                 ToggleMuteOverridesSolo,
115                 SoloUseInPlace,
116                 SoloUseAFL,
117                 SoloUsePFL,
118                 ToggleMonitorProcessorBox
119         };
120
121         enum ChannelActions {
122                 CutChannel,
123                 DimChannel,
124                 SoloChannel,
125                 InvertChannel
126         };
127
128         static Glib::RefPtr<Gtk::ActionGroup> monitor_actions;
129         static void register_actions ();
130
131         static void action_proxy0 (enum MonitorActions);
132         static void action_proxy1 (enum ChannelActions, uint32_t);
133
134         void cut_channel (uint32_t);
135         void dim_channel (uint32_t);
136         void solo_channel (uint32_t);
137         void invert_channel (uint32_t);
138         void dim_all ();
139         void cut_all ();
140         void mono ();
141         void toggle_exclusive_solo ();
142         void set_button_names () {}
143         void toggle_mute_overrides_solo ();
144         void dim_level_changed ();
145         void solo_boost_changed ();
146         void gain_value_changed ();
147         gint output_press (GdkEventButton *);
148         gint output_release (GdkEventButton *);
149
150         ArdourButton solo_in_place_button;
151         ArdourButton afl_button;
152         ArdourButton pfl_button;
153         Gtk::VBox    solo_model_box;
154
155         void solo_use_in_place ();
156         void solo_use_afl ();
157         void solo_use_pfl ();
158
159         ArdourButton cut_all_button;
160         ArdourButton dim_all_button;
161         ArdourButton mono_button;
162         ArdourButton rude_solo_button;
163         ArdourButton rude_iso_button;
164         ArdourButton rude_audition_button;
165         ArdourButton exclusive_solo_button;
166         ArdourButton solo_mute_override_button;
167         ArdourButton toggle_processorbox_button;
168
169         void do_blink (bool);
170         void solo_blink (bool);
171         void audition_blink (bool);
172         bool cancel_solo (GdkEventButton*);
173         bool cancel_isolate (GdkEventButton*);
174         bool cancel_audition (GdkEventButton*);
175         void update_solo_model ();
176         void parameter_changed (std::string);
177         void isolated_changed ();
178
179         PBD::ScopedConnection config_connection;
180         PBD::ScopedConnectionList control_connections;
181         PBD::ScopedConnection _output_changed_connection;
182
183         bool _inhibit_solo_model_update;
184
185         void assign_controllables ();
186
187         void port_connected_or_disconnected (boost::weak_ptr<ARDOUR::Port>, boost::weak_ptr<ARDOUR::Port>);
188
189         void update_processor_box ();
190
191         void route_property_changed (const PBD::PropertyChange&) {}
192
193         ProcessorBox* insert_box;
194         PluginSelector* _plugin_selector;
195         RouteProcessorSelection _rr_selection;
196         void help_count_processors (boost::weak_ptr<ARDOUR::Processor> p, uint32_t* cnt) const;
197         uint32_t count_processors ();
198
199         void processors_changed (ARDOUR::RouteProcessorChange);
200         Glib::RefPtr<Gtk::Action> proctoggle;
201         bool _ui_initialized;
202
203         static Gtkmm2ext::ActionMap myactions;
204         static Gtkmm2ext::Bindings* bindings;
205
206         static void load_bindings ();
207         bool enter_handler (GdkEventCrossing*);
208         bool leave_handler (GdkEventCrossing*);
209 };