first pass at end-to-end RT operation request (GUI->session->RT thread->GUI), just...
[ardour.git] / gtk2_ardour / route_ui.h
1 /*
2     Copyright (C) 2002 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 __ardour_route_ui__
21 #define __ardour_route_ui__
22
23 #include <list>
24
25 #include "pbd/xml++.h"
26 #include "ardour/ardour.h"
27 #include "ardour/mute_master.h"
28 #include "ardour/session_event.h"
29 #include "ardour/session.h"
30 #include "ardour/route.h"
31 #include "ardour/track.h"
32
33 #include "axis_view.h"
34
35 namespace ARDOUR {
36         class AudioTrack;
37         class MidiTrack;
38 }
39
40 namespace Gtk {
41         class Menu;
42         class CheckMenuItem;
43         class Widget;
44 }
45
46 class BindableToggleButton;
47
48 class RouteUI : public virtual AxisView
49 {
50   public:
51         RouteUI(ARDOUR::Session&);
52         RouteUI(boost::shared_ptr<ARDOUR::Route>, ARDOUR::Session&);
53
54         virtual ~RouteUI();
55
56         virtual void set_route (boost::shared_ptr<ARDOUR::Route>);
57         virtual void set_button_names () = 0;
58
59         bool is_track() const;
60         bool is_audio_track() const;
61         bool is_midi_track() const;
62
63         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
64
65         boost::shared_ptr<ARDOUR::Track>      track() const;
66         boost::shared_ptr<ARDOUR::AudioTrack> audio_track() const;
67         boost::shared_ptr<ARDOUR::MidiTrack>  midi_track() const;
68
69         boost::shared_ptr<ARDOUR::Diskstream> get_diskstream() const;
70
71         std::string name() const;
72
73         // protected: XXX sigh this should be here
74
75         boost::shared_ptr<ARDOUR::Route> _route;
76
77         void set_color (const Gdk::Color & c);
78         bool choose_color ();
79
80         bool ignore_toggle;
81         bool wait_for_release;
82         bool multiple_mute_change;
83         bool multiple_solo_change;
84
85         BindableToggleButton* mute_button;
86         BindableToggleButton* solo_button;
87         BindableToggleButton* rec_enable_button; /* audio tracks */
88         BindableToggleButton* show_sends_button; /* busses */
89
90         Gtk::Label solo_button_label;
91         Gtk::Label mute_button_label;
92         Gtk::Label rec_enable_button_label;
93
94         void send_blink (bool);
95         sigc::connection send_blink_connection;
96
97         virtual std::string solo_button_name () const { return "SoloButton"; }
98         virtual std::string safe_solo_button_name () const { return "SafeSoloButton"; }
99
100         Gtk::Menu* mute_menu;
101         Gtk::Menu* solo_menu;
102         Gtk::Menu* sends_menu;
103
104
105         XMLNode *xml_node;
106         void ensure_xml_node ();
107
108         virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter param);
109
110         bool mute_press(GdkEventButton*);
111         bool mute_release(GdkEventButton*);
112         bool solo_press(GdkEventButton*);
113         bool solo_release(GdkEventButton*);
114         bool rec_enable_press(GdkEventButton*);
115         bool rec_enable_release(GdkEventButton*);
116         bool show_sends_press(GdkEventButton*);
117         bool show_sends_release(GdkEventButton*);
118
119         void step_gain_up ();
120         void step_gain_down ();
121         void page_gain_up ();
122         void page_gain_down ();
123
124         void build_sends_menu ();
125         void set_sends_gain_from_track ();
126         void set_sends_gain_to_zero ();
127         void set_sends_gain_to_unity ();
128         void create_sends (ARDOUR::Placement);
129         void create_selected_sends (ARDOUR::Placement);
130
131         void solo_changed(void*);
132         void solo_changed_so_update_mute ();
133         void mute_changed(void*);
134         void listen_changed(void*);
135         virtual void processors_changed (ARDOUR::RouteProcessorChange) {}
136         void route_rec_enable_changed();
137         void session_rec_enable_changed();
138
139         void build_solo_menu ();
140
141         void solo_isolated_toggle (void*, Gtk::CheckMenuItem*);
142         void toggle_solo_isolated (Gtk::CheckMenuItem*);
143
144         void solo_safe_toggle (void*, Gtk::CheckMenuItem*);
145         void toggle_solo_safe (Gtk::CheckMenuItem*);
146
147         Gtk::CheckMenuItem* pre_fader_mute_check;
148         Gtk::CheckMenuItem* post_fader_mute_check;
149         Gtk::CheckMenuItem* listen_mute_check;
150         Gtk::CheckMenuItem* main_mute_check;
151
152         void toggle_mute_menu(ARDOUR::MuteMaster::MutePoint, Gtk::CheckMenuItem*);
153         void muting_change ();
154         void build_mute_menu(void);
155         void init_mute_menu(ARDOUR::MuteMaster::MutePoint, Gtk::CheckMenuItem*);
156
157         void set_route_group_solo (boost::shared_ptr<ARDOUR::Route>, bool);
158         void set_route_group_mute (boost::shared_ptr<ARDOUR::Route>, bool);
159         void set_route_group_rec_enable (boost::shared_ptr<ARDOUR::Route>, bool);
160
161         int  set_color_from_route ();
162
163         void remove_this_route ();
164         static gint idle_remove_this_route (RouteUI *);
165
166         void route_rename();
167
168         virtual void name_changed ();
169         void route_removed ();
170
171         Gtk::CheckMenuItem *route_active_menu_item;
172         void toggle_route_active ();
173         virtual void route_active_changed ();
174
175         Gtk::CheckMenuItem *polarity_menu_item;
176         void toggle_polarity ();
177         virtual void polarity_changed ();
178
179         Gtk::CheckMenuItem *denormal_menu_item;
180         void toggle_denormal_protection();
181         virtual void denormal_protection_changed ();
182
183         void disconnect_input ();
184         void disconnect_output ();
185
186         virtual void update_rec_display ();
187         void update_mute_display ();
188
189         void update_solo_display ();
190
191         virtual void map_frozen ();
192
193         void reversibly_apply_route_boolean (std::string name, void (ARDOUR::Route::*func)(bool, void*), bool, void *);
194         void reversibly_apply_track_boolean (std::string name, void (ARDOUR::Track::*func)(bool, void*), bool, void *);
195
196         void adjust_latency ();
197         void save_as_template ();
198         void open_remote_control_id_dialog ();
199
200         static int solo_visual_state (boost::shared_ptr<ARDOUR::Route>);
201         static int mute_visual_state (ARDOUR::Session &, boost::shared_ptr<ARDOUR::Route>);
202
203    protected:
204         std::vector<sigc::connection> connections;
205         bool self_destruct;
206
207         void init ();
208         void reset ();
209
210   private:
211         void check_rec_enable_sensitivity ();
212         void parameter_changed (std::string const &);
213         void relabel_solo_button ();
214
215         void post_rec_cleanup (ARDOUR::SessionEvent* ev, UndoTransaction* undo, ARDOUR::Session::GlobalRecordEnableStateCommand*);
216 };
217
218 #endif /* __ardour_route_ui__ */