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