first pass (ok, third really) at internal send+return - audio routing inside ardour...
[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/route.h"
29 #include "ardour/track.h"
30
31 #include "axis_view.h"
32
33 namespace ARDOUR {
34         class AudioTrack;
35         class MidiTrack;
36 }
37
38 namespace Gtk {
39         class Menu;
40         class CheckMenuItem;
41         class Widget;
42 }
43
44 class BindableToggleButton;
45
46 class RouteUI : public virtual AxisView
47 {
48   public:
49         RouteUI(ARDOUR::Session&, const char*, const char*, const char*);
50         RouteUI(boost::shared_ptr<ARDOUR::Route>, ARDOUR::Session&, const char*, const char*, const char*);
51
52         virtual ~RouteUI();
53
54         virtual void set_route (boost::shared_ptr<ARDOUR::Route>);
55         void set_button_names (const char*, const char*, const char*);
56
57         bool is_track() const;
58         bool is_audio_track() const;
59         bool is_midi_track() const;
60
61         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
62         
63         boost::shared_ptr<ARDOUR::Track>      track() const;
64         boost::shared_ptr<ARDOUR::AudioTrack> audio_track() const;
65         boost::shared_ptr<ARDOUR::MidiTrack>  midi_track() const;
66         
67         boost::shared_ptr<ARDOUR::Diskstream> get_diskstream() const;
68
69         std::string name() const;
70
71         // protected: XXX sigh this should be here
72
73         boost::shared_ptr<ARDOUR::Route> _route;
74         
75         void set_color (const Gdk::Color & c);
76         bool choose_color ();
77
78         bool ignore_toggle;
79         bool wait_for_release;
80         bool multiple_mute_change;
81         bool multiple_solo_change;
82
83         BindableToggleButton* mute_button;
84         BindableToggleButton* solo_button;
85         BindableToggleButton* rec_enable_button; /* audio tracks */
86         BindableToggleButton* show_sends_button; /* busses */
87
88         void send_blink (bool);
89         sigc::connection send_blink_connection;
90         
91         virtual std::string solo_button_name () const { return "SoloButton"; }
92         virtual std::string safe_solo_button_name () const { return "SafeSoloButton"; }
93         
94         Gtk::Menu* mute_menu;
95         Gtk::Menu* solo_menu;
96         Gtk::Menu* remote_control_menu;
97         Gtk::Menu* sends_menu;
98
99         XMLNode *xml_node;
100         void ensure_xml_node ();
101
102         virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter param);
103         
104         bool mute_press(GdkEventButton*);
105         bool mute_release(GdkEventButton*);
106         bool solo_press(GdkEventButton*);
107         bool solo_release(GdkEventButton*);
108         bool rec_enable_press(GdkEventButton*);
109         bool rec_enable_release(GdkEventButton*);
110         bool show_sends_press(GdkEventButton*);
111         bool show_sends_release(GdkEventButton*);
112
113         void build_sends_menu ();
114         void set_sends_gain_from_track ();
115         void set_sends_gain_to_zero ();
116         void set_sends_gain_to_unity ();
117
118         void solo_changed(void*);
119         void solo_changed_so_update_mute ();
120         void mute_changed(void*);
121         virtual void processors_changed () {}
122         void route_rec_enable_changed();
123         void session_rec_enable_changed();
124
125         void build_solo_menu (void);
126         void build_remote_control_menu (void);
127         void refresh_remote_control_menu ();
128
129         void solo_isolated_toggle (void*, Gtk::CheckMenuItem*);
130         void toggle_solo_isolated (Gtk::CheckMenuItem*);
131
132         void toggle_mute_menu(ARDOUR::MuteMaster::MutePoint, Gtk::CheckMenuItem*);
133         void pre_fader_toggle(void*, Gtk::CheckMenuItem*);
134         void post_fader_toggle(void*, Gtk::CheckMenuItem*);
135         void control_outs_toggle(void*, Gtk::CheckMenuItem*);
136         void main_outs_toggle(void*, Gtk::CheckMenuItem*);
137
138         void build_mute_menu(void);
139         void init_mute_menu(ARDOUR::MuteMaster::MutePoint, Gtk::CheckMenuItem*);
140         
141         void set_mix_group_solo(boost::shared_ptr<ARDOUR::Route>, bool);
142         void set_mix_group_mute(boost::shared_ptr<ARDOUR::Route>, bool);
143         void set_mix_group_rec_enable(boost::shared_ptr<ARDOUR::Route>, bool);
144
145         int  set_color_from_route ();
146
147         void remove_this_route ();
148         static gint idle_remove_this_route (RouteUI *);
149
150         void route_rename();
151         
152         virtual void name_changed ();
153         void route_removed ();
154
155         Gtk::CheckMenuItem *route_active_menu_item;
156         void toggle_route_active ();
157         virtual void route_active_changed ();
158
159         Gtk::CheckMenuItem *polarity_menu_item;
160         void toggle_polarity ();
161         virtual void polarity_changed ();
162
163         Gtk::CheckMenuItem *denormal_menu_item;
164         void toggle_denormal_protection();
165         virtual void denormal_protection_changed ();
166
167         void disconnect_input ();
168         void disconnect_output ();
169
170         virtual void update_rec_display ();
171         void update_mute_display ();
172
173         void update_solo_display ();
174
175         virtual void map_frozen ();
176
177         void set_remote_control_id (uint32_t id, Gtk::CheckMenuItem* item);
178
179         void reversibly_apply_route_boolean (std::string name, void (ARDOUR::Route::*func)(bool, void*), bool, void *);
180         void reversibly_apply_track_boolean (std::string name, void (ARDOUR::Track::*func)(bool, void*), bool, void *);
181
182         void adjust_latency ();
183         void save_as_template ();
184  
185    protected:
186         std::vector<sigc::connection> connections;
187         std::string s_name;
188         std::string m_name;
189         std::string r_name;
190  
191         bool self_destruct;
192
193         void init ();
194         void reset ();
195
196   private:
197         void check_rec_enable_sensitivity ();
198         void parameter_changed (std::string const &);
199 };
200
201 #endif /* __ardour_route_ui__ */