2 * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
4 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
5 * Copyright (C) 2006-2011 David Robillard <d@drobilla.net>
6 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
7 * Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
8 * Copyright (C) 2014-2015 Ben Loftis <ben@harrisonconsoles.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __ardour_route_ui__
26 #define __ardour_route_ui__
30 #include "pbd/xml++.h"
31 #include "pbd/signals.h"
33 #include <gtkmm/textview.h>
34 #include <gtkmm/colorselection.h>
36 #include "gtkmm2ext/widget_state.h"
38 #include "ardour/ardour.h"
39 #include "ardour/mute_master.h"
40 #include "ardour/session.h"
41 #include "ardour/session_event.h"
42 #include "ardour/session_handle.h"
43 #include "ardour/route.h"
44 #include "ardour/route_group.h"
45 #include "ardour/track.h"
47 #include "axis_view.h"
48 #include "selectable.h"
49 #include "stripable_colorpicker.h"
50 #include "window_manager.h"
63 namespace ArdourWidgets {
69 class IOSelectorWindow;
71 class PatchChangeGridDialog;
72 class SaveTemplateDialog;
74 class RoutePinWindowProxy : public WM::ProxyBase
77 RoutePinWindowProxy (std::string const &, boost::shared_ptr<ARDOUR::Route>);
78 ~RoutePinWindowProxy();
80 Gtk::Window* get (bool create = false);
81 ARDOUR::SessionHandlePtr* session_handle();
84 boost::weak_ptr<ARDOUR::Route> _route;
86 void route_going_away ();
87 PBD::ScopedConnection going_away_connection;
90 class RouteUI : public virtual Selectable, public virtual ARDOUR::SessionHandlePtr, public virtual PBD::ScopedConnectionList, public virtual sigc::trackable
93 RouteUI (ARDOUR::Session*);
97 boost::shared_ptr<ARDOUR::Stripable> stripable() const;
99 virtual void set_route (boost::shared_ptr<ARDOUR::Route>);
100 virtual void set_button_names () = 0;
102 bool is_track() const;
103 bool is_audio_track() const;
104 bool is_midi_track() const;
105 bool has_audio_outputs () const;
107 boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
108 ARDOUR::RouteGroup* route_group() const;
110 boost::shared_ptr<ARDOUR::Track> track() const;
111 boost::shared_ptr<ARDOUR::AudioTrack> audio_track() const;
112 boost::shared_ptr<ARDOUR::MidiTrack> midi_track() const;
114 // protected: XXX sigh this should be here
116 boost::shared_ptr<ARDOUR::Route> _route;
118 virtual void set_color (uint32_t c);
119 Gdk::Color route_color () const;
120 void choose_color ();
122 void select_midi_patch ();
125 bool wait_for_release;
126 bool multiple_mute_change;
127 bool multiple_solo_change;
129 Gtk::HBox _invert_button_box;
130 ArdourWidgets::ArdourButton* mute_button;
131 ArdourWidgets::ArdourButton* solo_button;
132 ArdourWidgets::ArdourButton* rec_enable_button; /* audio tracks */
133 ArdourWidgets::ArdourButton* show_sends_button; /* busses */
134 ArdourWidgets::ArdourButton* monitor_input_button;
135 ArdourWidgets::ArdourButton* monitor_disk_button;
137 Glib::RefPtr<Gdk::Pixbuf> solo_safe_pixbuf;
139 ArdourWidgets::ArdourButton* solo_safe_led;
140 ArdourWidgets::ArdourButton* solo_isolated_led;
143 Gtk::Label monitor_input_button_label;
144 Gtk::Label monitor_disk_button_label;
146 void send_blink (bool);
147 sigc::connection send_blink_connection;
149 sigc::connection rec_blink_connection;
151 Gtk::Menu* mute_menu;
152 Gtk::Menu* solo_menu;
153 Gtk::Menu* sends_menu;
155 boost::shared_ptr<ARDOUR::Delivery> _current_delivery;
157 bool mute_press(GdkEventButton*);
158 bool mute_release(GdkEventButton*);
159 bool solo_press(GdkEventButton*);
160 bool solo_release(GdkEventButton*);
161 bool rec_enable_press(GdkEventButton*);
162 bool rec_enable_release(GdkEventButton*);
163 bool show_sends_press(GdkEventButton*);
164 bool show_sends_release(GdkEventButton*);
166 bool monitor_release(GdkEventButton*, ARDOUR::MonitorChoice);
167 bool monitor_input_press(GdkEventButton*);
168 bool monitor_input_release(GdkEventButton*);
169 bool monitor_disk_press(GdkEventButton*);
170 bool monitor_disk_release(GdkEventButton*);
171 void update_monitoring_display ();
173 void edit_input_configuration ();
174 void edit_output_configuration ();
176 void build_sends_menu ();
177 void set_sends_gain_from_track ();
178 void set_sends_gain_to_zero ();
179 void set_sends_gain_to_unity ();
180 void create_sends (ARDOUR::Placement, bool);
181 void create_selected_sends (ARDOUR::Placement, bool);
183 void solo_changed(bool, void*);
184 void solo_changed_so_update_mute ();
185 void listen_changed(void*);
186 virtual void processors_changed (ARDOUR::RouteProcessorChange) {}
187 void route_rec_enable_changed();
188 void session_rec_enable_changed();
190 void build_solo_menu ();
192 void solo_isolated_toggle (void*, Gtk::CheckMenuItem*);
193 void toggle_solo_isolated (Gtk::CheckMenuItem*);
195 bool solo_isolate_button_release (GdkEventButton*);
196 bool solo_safe_button_release (GdkEventButton*);
198 void solo_safe_toggle (void*, Gtk::CheckMenuItem*);
199 void toggle_solo_safe (Gtk::CheckMenuItem*);
201 Gtk::CheckMenuItem* pre_fader_mute_check;
202 Gtk::CheckMenuItem* post_fader_mute_check;
203 Gtk::CheckMenuItem* listen_mute_check;
204 Gtk::CheckMenuItem* main_mute_check;
205 Gtk::CheckMenuItem* solo_safe_check;
206 Gtk::CheckMenuItem* solo_isolated_check;
208 void toggle_mute_menu(ARDOUR::MuteMaster::MutePoint, Gtk::CheckMenuItem*);
209 void muting_change ();
210 void build_mute_menu(void);
211 void init_mute_menu(ARDOUR::MuteMaster::MutePoint, Gtk::CheckMenuItem*);
213 int set_color_from_route ();
218 void maybe_add_route_print_mgr ();
219 void fan_out (bool to_busses = true, bool group = true);
221 virtual void route_property_changed (const PBD::PropertyChange&) = 0;
222 void route_removed ();
224 virtual void route_active_changed () {}
225 void set_route_active (bool, bool);
226 void duplicate_selected_routes ();
228 Gtk::Menu* record_menu;
229 void build_record_menu ();
231 Gtk::CheckMenuItem *step_edit_item;
232 void toggle_step_edit ();
233 virtual void step_edit_changed (bool);
235 Gtk::CheckMenuItem *rec_safe_item;
236 void toggle_rec_safe ();
238 virtual void polarity_changed ();
240 Gtk::CheckMenuItem *denormal_menu_item;
241 void toggle_denormal_protection();
242 virtual void denormal_protection_changed ();
244 void disconnect_input ();
245 void disconnect_output ();
247 virtual void blink_rec_display (bool onoff);
248 void update_mute_display ();
250 void update_solo_display ();
252 virtual void map_frozen ();
254 void save_as_template_dialog_response (int response, SaveTemplateDialog* d);
255 void save_as_template ();
257 static Gtkmm2ext::ActiveState solo_active_state (boost::shared_ptr<ARDOUR::Stripable>);
258 static Gtkmm2ext::ActiveState solo_isolate_active_state (boost::shared_ptr<ARDOUR::Stripable>);
259 static Gtkmm2ext::ActiveState solo_safe_active_state (boost::shared_ptr<ARDOUR::Stripable>);
260 static Gtkmm2ext::ActiveState mute_active_state (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Stripable>);
262 /** Emitted when a bus has been set or unset from `display sends to this bus' mode
263 * by a click on the `Sends' button. The parameter is the route that the sends are
264 * to, or 0 if no route is now in this mode.
266 static PBD::Signal1<void, boost::shared_ptr<ARDOUR::Route> > BusSendDisplayChanged;
268 void comment_editor_done_editing ();
269 void setup_comment_editor ();
270 void open_comment_editor ();
271 void toggle_comment_editor ();
273 gint comment_key_release_handler (GdkEventKey*);
274 void comment_changed ();
275 void comment_edited ();
276 bool ignore_comment_edit;
278 void set_disk_io_point (ARDOUR::DiskIOPoint);
282 ArdourWindow* comment_window;
283 Gtk::TextView* comment_area;
284 IOSelectorWindow *input_selector;
285 IOSelectorWindow *output_selector;
287 PBD::ScopedConnectionList route_connections;
294 virtual void start_step_editing () {}
295 virtual void stop_step_editing() {}
297 void set_invert_sensitive (bool);
298 bool verify_new_route_name (const std::string& name);
300 void route_gui_changed (PBD::PropertyChange const&);
301 virtual void route_color_changed () {}
303 void check_rec_enable_sensitivity ();
305 virtual void bus_send_display_changed (boost::shared_ptr<ARDOUR::Route>);
307 static std::string program_port_prefix;
309 bool mark_hidden (bool yn);
311 PatchChangeGridDialog* patch_change_dialog () const;
314 void parameter_changed (std::string const&);
315 void relabel_solo_button ();
316 void track_mode_changed ();
317 void delete_patch_change_dialog ();
319 std::string route_state_id () const;
322 struct SoloMuteRelease {
323 SoloMuteRelease (bool was_active)
324 : active (was_active)
328 boost::shared_ptr<ARDOUR::RouteList> routes;
329 boost::shared_ptr<ARDOUR::RouteList> routes_on;
330 boost::shared_ptr<ARDOUR::RouteList> routes_off;
331 boost::shared_ptr<ARDOUR::Route> route;
336 SoloMuteRelease* _solo_release;
337 SoloMuteRelease* _mute_release;
342 void setup_invert_buttons ();
343 void set_invert_button_state ();
344 void invert_menu_toggled (uint32_t);
345 bool invert_press (GdkEventButton *);
346 bool invert_release (GdkEventButton *, uint32_t i);
348 int _i_am_the_modifier;
349 std::vector<ArdourWidgets::ArdourButton*> _invert_buttons;
350 Gtk::Menu* _invert_menu;
352 StripableColorDialog _color_picker;
354 static void set_showing_sends_to (boost::shared_ptr<ARDOUR::Route>);
355 static boost::weak_ptr<ARDOUR::Route> _showing_sends_to;
357 static uint32_t _max_invert_buttons;
360 #endif /* __ardour_route_ui__ */