1 /*
2  * Copyright (C) 2010-2018 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2014-2015 Ben Loftis <ben@harrisonconsoles.com>
5  * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef __gtk2_ardour_monitor_section_h__
23 #define __gtk2_ardour_monitor_section_h__
24 
25 #include <gtkmm/box.h>
26 #include <gtkmm/eventbox.h>
27 #include <gtkmm/sizegroup.h>
28 #include <gtkmm/table.h>
29 #include <gtkmm/viewport.h>
30 
31 #include "gtkmm2ext/bindings.h"
32 
33 #include "widgets/ardour_button.h"
34 #include "widgets/ardour_knob.h"
35 #include "widgets/ardour_display.h"
36 
37 #include "level_meter.h"
38 #include "route_ui.h"
39 #include "monitor_selector.h"
40 
41 #include "processor_box.h"
42 #include "processor_selection.h"
43 
44 namespace ArdourWidgets {
45 	class TearOff;
46 }
47 
48 class PluginSelector;
49 
50 class MonitorSection : public RouteUI, public Gtk::EventBox
51 {
52 public:
53 	MonitorSection ();
54 	~MonitorSection ();
55 
56 	void set_session (ARDOUR::Session*);
57 
tearoff()58 	ArdourWidgets::TearOff& tearoff() const { return *_tearoff; }
59 
60 	std::string state_id() const;
61 
62 	PluginSelector* plugin_selector();
63 
64 	void use_others_actions ();
65 
66 private:
67 	Gtk::HBox hpacker;
68 	Gtk::VBox vpacker;
69 	ArdourWidgets::TearOff* _tearoff;
70 
71 	Gtk::HBox  channel_table_packer;
72 	Gtk::HBox  table_hpacker;
73 	Gtk::HBox  master_packer;
74 	Gtk::Table channel_table_header;
75 	Gtk::Table *channel_table;
76 	Gtk::ScrolledWindow channel_table_scroller;
77 	Gtk::Viewport channel_table_viewport;
78 	Glib::RefPtr<Gtk::SizeGroup> channel_size_group;
79 
80 	struct ChannelButtonSet {
81 		ArdourWidgets::ArdourButton cut;
82 		ArdourWidgets::ArdourButton dim;
83 		ArdourWidgets::ArdourButton solo;
84 		ArdourWidgets::ArdourButton invert;
85 
86 		ChannelButtonSet ();
87 	};
88 
89 	typedef std::vector<ChannelButtonSet*> ChannelButtons;
90 	ChannelButtons _channel_buttons;
91 
92 	ArdourWidgets::ArdourKnob* gain_control;
93 	ArdourWidgets::ArdourKnob* dim_control;
94 	ArdourWidgets::ArdourKnob* solo_boost_control;
95 	ArdourWidgets::ArdourKnob* solo_cut_control;
96 
97 	ArdourWidgets::ArdourDisplay*  gain_display;
98 	ArdourWidgets::ArdourDisplay*  dim_display;
99 	ArdourWidgets::ArdourDisplay*  solo_boost_display;
100 	ArdourWidgets::ArdourDisplay*  solo_cut_display;
101 
102 	std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
103 	Gtk::Menu output_menu;
104 	MonitorSelectorWindow *_output_selector;
105 	ArdourWidgets::ArdourButton* output_button;
106 
107 	void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &);
108 	void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>);
109 	void update_output_display ();
110 	void disconnect_output ();
111 	void edit_output_configuration ();
112 
113 	void populate_buttons ();
114 	void map_state ();
115 
116 	boost::shared_ptr<ARDOUR::MonitorProcessor> _monitor;
117 
118 	Glib::RefPtr<Gtk::ActionGroup> monitor_actions;
119 	Glib::RefPtr<Gtk::ActionGroup> solo_actions;
120 	void register_actions ();
121 
122 	void cut_channel (uint32_t);
123 	void dim_channel (uint32_t);
124 	void solo_channel (uint32_t);
125 	void invert_channel (uint32_t);
126 	void dim_all ();
127 	void cut_all ();
128 	void mono ();
129 	void toggle_exclusive_solo ();
set_button_names()130 	void set_button_names () {}
131 	void toggle_mute_overrides_solo ();
132 	void dim_level_changed ();
133 	void solo_boost_changed ();
134 	void gain_value_changed ();
135 	gint output_press (GdkEventButton *);
136 	gint output_release (GdkEventButton *);
137 
138 	ArdourWidgets::ArdourButton solo_in_place_button;
139 	ArdourWidgets::ArdourButton afl_button;
140 	ArdourWidgets::ArdourButton pfl_button;
141 	Gtk::VBox    solo_model_box;
142 
143 	void solo_use_in_place ();
144 	void solo_use_afl ();
145 	void solo_use_pfl ();
146 
147 	ArdourWidgets::ArdourButton cut_all_button;
148 	ArdourWidgets::ArdourButton dim_all_button;
149 	ArdourWidgets::ArdourButton mono_button;
150 	ArdourWidgets::ArdourButton rude_solo_button;
151 	ArdourWidgets::ArdourButton rude_iso_button;
152 	ArdourWidgets::ArdourButton rude_audition_button;
153 	ArdourWidgets::ArdourButton exclusive_solo_button;
154 	ArdourWidgets::ArdourButton solo_mute_override_button;
155 	ArdourWidgets::ArdourButton toggle_processorbox_button;
156 
157 	void do_blink (bool);
158 	void solo_blink (bool);
159 	void audition_blink (bool);
160 	bool cancel_solo (GdkEventButton*);
161 	bool cancel_isolate (GdkEventButton*);
162 	bool cancel_audition (GdkEventButton*);
163 	void update_solo_model ();
164 	void parameter_changed (std::string);
165 	void isolated_changed ();
166 
167 	PBD::ScopedConnection config_connection;
168 	PBD::ScopedConnectionList connections;
169 	PBD::ScopedConnectionList route_connections;
170 
171 	bool _inhibit_solo_model_update;
172 
173 	void assign_controllables ();
174 	void unassign_controllables ();
175 
176 	void port_connected_or_disconnected (boost::weak_ptr<ARDOUR::Port>, boost::weak_ptr<ARDOUR::Port>);
177 	void port_pretty_name_changed (std::string);
178 
179 	void update_processor_box ();
180 
route_property_changed(const PBD::PropertyChange &)181 	void route_property_changed (const PBD::PropertyChange&) {}
182 
183 	ProcessorBox* insert_box;
184 	ProcessorSelection _rr_selection;
185 	void help_count_processors (boost::weak_ptr<ARDOUR::Processor> p, uint32_t* cnt) const;
186 	uint32_t count_processors ();
187 
188 	void processors_changed (ARDOUR::RouteProcessorChange);
189 	Glib::RefPtr<Gtk::ToggleAction> proctoggle;
190 	bool _ui_initialized;
191 
192 	Gtkmm2ext::Bindings* bindings;
193 
194 	void load_bindings ();
195 	bool enter_handler (GdkEventCrossing*);
196 	bool leave_handler (GdkEventCrossing*);
197 
198 	void toggle_use_monitor_section ();
199 	void drop_route ();
200 };
201 
202 #endif /* __gtk2_ardour_monitor_section_h__ */
203