Merged with trunk, and a few trivial GUI updates etc.
[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
30 #include "axis_view.h"
31
32 namespace Gtkmm2ext {
33         class BindableToggleButton;
34 }
35
36 namespace ARDOUR {
37         class AudioTrack;
38         class MidiTrack;
39 }
40
41 namespace Gtk {
42         class Menu;
43         class CheckMenuItem;
44         class Widget;
45 }
46
47 class RouteUI : public virtual AxisView
48 {
49   public:
50         RouteUI(ARDOUR::Route&, ARDOUR::Session&, const char*, const char*, const char*);
51         virtual ~RouteUI();
52
53         bool is_audio_track() const;
54         bool is_midi_track() const;
55         //ARDOUR::AudioDiskstream* get_diskstream() const;
56         ARDOUR::Diskstream* get_diskstream() const;
57
58         ARDOUR::Route& route() const { return _route; }
59         ARDOUR::AudioTrack* audio_track() const;
60         ARDOUR::MidiTrack* midi_track() const;
61
62         string name() const;
63         
64         ARDOUR::Route& _route;
65         
66         void set_color (const Gdk::Color & c);
67         bool choose_color ();
68
69         bool ignore_toggle;
70         bool wait_for_release;
71
72         Gtkmm2ext::BindableToggleButton * mute_button;
73         Gtkmm2ext::BindableToggleButton * solo_button;
74         Gtkmm2ext::BindableToggleButton * rec_enable_button;
75         
76         virtual string solo_button_name () const { return "SoloButton"; }
77         virtual string safe_solo_button_name () const { return "SafeSoloButton"; }
78         
79         Gtk::Menu* mute_menu;
80         Gtk::Menu* solo_menu;
81         Gtk::Menu* remote_control_menu;
82
83         XMLNode *xml_node;
84         void ensure_xml_node ();
85
86         XMLNode* get_child_xml_node (const string & childname);
87         
88         gint mute_press(GdkEventButton*);
89         gint mute_release(GdkEventButton*);
90         gint solo_press(GdkEventButton*);
91         gint solo_release(GdkEventButton*);
92         gint rec_enable_press(GdkEventButton*);
93
94         void solo_changed(void*);
95         void mute_changed(void*);
96         void route_rec_enable_changed(void*);
97         void session_rec_enable_changed();
98
99         void build_solo_menu (void);
100         void build_remote_control_menu (void);
101         void refresh_remote_control_menu ();
102
103         void solo_safe_toggle (void*, Gtk::CheckMenuItem*);
104         void toggle_solo_safe (Gtk::CheckMenuItem*);
105
106         void toggle_mute_menu(ARDOUR::mute_type, Gtk::CheckMenuItem*);
107         void pre_fader_toggle(void*, Gtk::CheckMenuItem*);
108         void post_fader_toggle(void*, Gtk::CheckMenuItem*);
109         void control_outs_toggle(void*, Gtk::CheckMenuItem*);
110         void main_outs_toggle(void*, Gtk::CheckMenuItem*);
111
112         void build_mute_menu(void);
113         void init_mute_menu(ARDOUR::mute_type, Gtk::CheckMenuItem*);
114         
115         void set_mix_group_solo(ARDOUR::Route&, bool);
116         void set_mix_group_mute(ARDOUR::Route&, bool);
117         void set_mix_group_rec_enable(ARDOUR::Route&, bool);
118
119         int  set_color_from_route ();
120
121         sigc::connection blink_connection;
122
123         void rec_enable_button_blink (bool onoff, ARDOUR::AudioDiskstream *, Gtk::Widget *w);
124         
125         void remove_this_route ();
126         static gint idle_remove_this_route (RouteUI *);
127
128         void route_rename();
129         
130         virtual void name_changed (void *src);
131         void route_removed ();
132
133         Gtk::CheckMenuItem *route_active_menu_item;
134         void toggle_route_active ();
135         virtual void route_active_changed ();
136
137         Gtk::CheckMenuItem *polarity_menu_item;
138         void toggle_polarity ();
139         virtual void polarity_changed ();
140
141         void disconnect_input ();
142         void disconnect_output ();
143
144         void update_rec_display ();
145         void update_mute_display ();
146         void update_solo_display ();
147         virtual void map_frozen ();
148
149         void set_remote_control_id (uint32_t id, Gtk::CheckMenuItem* item);
150
151         void reversibly_apply_route_boolean (string name, void (ARDOUR::Route::*func)(bool, void*), bool, void *);
152         void reversibly_apply_audio_track_boolean (string name, void (ARDOUR::AudioTrack::*func)(bool, void*), bool, void *);
153 };
154
155 #endif /* __ardour_route_ui__ */