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