156063a8e5f4ee9f5e46828a637acfeddeeb28c5
[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     $Id$
19 */
20
21 #ifndef __ardour_route_ui__
22 #define __ardour_route_ui__
23
24 #include <list>
25
26 #include <pbd/xml++.h>
27 #include <ardour/ardour.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(boost::shared_ptr<ARDOUR::Route>, ARDOUR::Session&, const char*, const char*, const char*);
50         virtual ~RouteUI();
51
52         bool is_track() const;
53         bool is_audio_track() const;
54         bool is_midi_track() const;
55
56         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
57         
58         // FIXME: make these return shared_ptr
59         ARDOUR::Track*      track() const;
60         ARDOUR::AudioTrack* audio_track() const;
61         ARDOUR::MidiTrack*  midi_track() const;
62         
63         ARDOUR::Diskstream* get_diskstream() const;
64
65         string name() const;
66
67         // protected: XXX sigh this should be here
68
69         boost::shared_ptr<ARDOUR::Route> _route;
70         
71         void set_color (const Gdk::Color & c);
72         bool choose_color ();
73
74         bool ignore_toggle;
75         bool wait_for_release;
76
77         BindableToggleButton* mute_button;
78         BindableToggleButton* solo_button;
79         BindableToggleButton* rec_enable_button;
80         
81         virtual string solo_button_name () const { return "SoloButton"; }
82         virtual string safe_solo_button_name () const { return "SafeSoloButton"; }
83         
84         Gtk::Menu* mute_menu;
85         Gtk::Menu* solo_menu;
86         Gtk::Menu* remote_control_menu;
87
88         XMLNode *xml_node;
89         void ensure_xml_node ();
90
91         XMLNode* get_child_xml_node (const string & childname);
92         
93         gint mute_press(GdkEventButton*);
94         gint mute_release(GdkEventButton*);
95         gint solo_press(GdkEventButton*);
96         gint solo_release(GdkEventButton*);
97         gint rec_enable_press(GdkEventButton*);
98
99         void solo_changed(void*);
100         void mute_changed(void*);
101         virtual void redirects_changed (void *) {}
102         void route_rec_enable_changed();
103         void session_rec_enable_changed();
104
105         void build_solo_menu (void);
106         void build_remote_control_menu (void);
107         void refresh_remote_control_menu ();
108
109         void solo_safe_toggle (void*, Gtk::CheckMenuItem*);
110         void toggle_solo_safe (Gtk::CheckMenuItem*);
111
112         void toggle_mute_menu(ARDOUR::mute_type, Gtk::CheckMenuItem*);
113         void pre_fader_toggle(void*, Gtk::CheckMenuItem*);
114         void post_fader_toggle(void*, Gtk::CheckMenuItem*);
115         void control_outs_toggle(void*, Gtk::CheckMenuItem*);
116         void main_outs_toggle(void*, Gtk::CheckMenuItem*);
117
118         void build_mute_menu(void);
119         void init_mute_menu(ARDOUR::mute_type, Gtk::CheckMenuItem*);
120         
121         void set_mix_group_solo(boost::shared_ptr<ARDOUR::Route>, bool);
122         void set_mix_group_mute(boost::shared_ptr<ARDOUR::Route>, bool);
123         void set_mix_group_rec_enable(boost::shared_ptr<ARDOUR::Route>, bool);
124
125         int  set_color_from_route ();
126
127         sigc::connection blink_connection;
128
129         void rec_enable_button_blink (bool onoff, ARDOUR::AudioDiskstream *, Gtk::Widget *w);
130         
131         void remove_this_route ();
132         static gint idle_remove_this_route (RouteUI *);
133
134         void route_rename();
135         
136         virtual void name_changed (void *src);
137         void route_removed ();
138
139         Gtk::CheckMenuItem *route_active_menu_item;
140         void toggle_route_active ();
141         virtual void route_active_changed ();
142
143         Gtk::CheckMenuItem *polarity_menu_item;
144         void toggle_polarity ();
145         virtual void polarity_changed ();
146
147         void disconnect_input ();
148         void disconnect_output ();
149
150         void update_rec_display ();
151         void update_mute_display ();
152         void update_solo_display ();
153         virtual void map_frozen ();
154
155         void set_remote_control_id (uint32_t id, Gtk::CheckMenuItem* item);
156
157         void reversibly_apply_route_boolean (string name, void (ARDOUR::Route::*func)(bool, void*), bool, void *);
158         void reversibly_apply_audio_track_boolean (string name, void (ARDOUR::AudioTrack::*func)(bool, void*), bool, void *);
159         void reversibly_apply_track_boolean (string name, void (ARDOUR::Track::*func)(bool, void*), bool, void *);
160 };
161
162 #endif /* __ardour_route_ui__ */