NO-OP whitespace & foratting of header files
[ardour.git] / gtk2_ardour / export_channel_selector.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sakari Bergen
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __export_channel_selector_h__
22 #define __export_channel_selector_h__
23
24 #include <list>
25
26 #include "ardour/export_profile_manager.h"
27
28 #ifdef interface
29 #undef interface
30 #endif
31
32 #include <gtkmm.h>
33 #include <sigc++/signal.h>
34 #include <boost/shared_ptr.hpp>
35
36 namespace ARDOUR {
37         class Session;
38         class ExportChannelConfiguration;
39         class RegionExportChannelFactory;
40         class ExportHandler;
41         class AudioPort;
42         class IO;
43         class AudioRegion;
44         class AudioTrack;
45 }
46
47 class XMLNode;
48
49 class ExportChannelSelector : public Gtk::HBox, public ARDOUR::SessionHandlePtr
50 {
51 protected:
52         typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr;
53         typedef std::list<ChannelConfigPtr> ChannelConfigList;
54         typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
55
56         ProfileManagerPtr manager;
57
58 public:
59         ExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager)
60                 : SessionHandlePtr (session)
61                 , manager (manager)
62         {}
63
64         virtual ~ExportChannelSelector () {}
65
66         virtual void sync_with_manager () = 0;
67
68         sigc::signal<void> CriticalSelectionChanged;
69 };
70
71 class PortExportChannelSelector : public ExportChannelSelector
72 {
73 public:
74
75         PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
76         ~PortExportChannelSelector ();
77
78         void sync_with_manager ();
79
80 private:
81
82         void fill_route_list ();
83         void update_channel_count ();
84         void update_split_state ();
85
86         typedef std::list<ARDOUR::ExportChannelPtr> CahnnelList;
87
88         ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
89
90         /*** GUI stuff ***/
91
92         Gtk::VBox         channels_vbox;
93         Gtk::HBox         channels_hbox;
94
95         Gtk::Label        channels_label;
96         Gtk::SpinButton   channels_spinbutton;
97         Gtk::CheckButton  split_checkbox;
98
99         /* Column record for channel selector view */
100
101         class RouteCols : public Gtk::TreeModelColumnRecord
102         {
103         public:
104
105                 struct Channel;
106
107                 RouteCols () : n_channels (0)
108                 { add (selected); add (name); add (io); add (port_list_col); }
109
110                 void add_channels (uint32_t chans);
111                 uint32_t n_channels;
112
113                 /* Channel count starts from one! */
114
115                 Channel & get_channel (uint32_t channel);
116
117                 /* Static columns */
118
119                 Gtk::TreeModelColumn<bool>           selected;
120                 Gtk::TreeModelColumn<std::string>  name;
121                 Gtk::TreeModelColumn<ARDOUR::IO *>   io;
122
123                 /* Combo list column (shared by all channels) */
124
125                 typedef Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > ComboCol;
126                 ComboCol                             port_list_col;
127
128                 /* Channel struct, that represents the selected port and its name */
129
130                 struct Channel {
131                 public:
132                         Channel (RouteCols & cols) { cols.add (port); cols.add (label); }
133
134                         Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
135                         Gtk::TreeModelColumn<std::string> label;
136                 };
137                 std::list<Channel> channels;
138
139                 /* List of available ports
140                  * Note: We need only one list of selectable ports per route,
141                  * so the list is kept in the column record
142                  */
143
144                 /* Column record for selecting ports for a channel from a route */
145
146                 class PortCols : public Gtk::TreeModel::ColumnRecord
147                 {
148                 public:
149                         PortCols () { add(selected); add(port); add(label); }
150
151                         Gtk::TreeModelColumn<bool> selected;  // not used ATM
152                         Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
153                         Gtk::TreeModelColumn<std::string> label;
154                 };
155                 PortCols port_cols;
156         };
157
158         /* Channels view */
159
160         class ChannelTreeView : public Gtk::TreeView
161         {
162         public:
163
164                 ChannelTreeView (uint32_t max_channels);
165                 void set_config (ChannelConfigPtr c);
166
167                 /* Routes have to be added before adding channels */
168
169                 void clear_routes () { route_list->clear (); }
170                 void add_route (ARDOUR::IO * route);
171                 void set_channel_count (uint32_t channels);
172
173                 sigc::signal<void> CriticalSelectionChanged;
174
175         private:
176
177                 ChannelConfigPtr config;
178                 void update_config ();
179
180                 /* Signal handlers for selections changes in the view */
181
182                 void update_toggle_selection (std::string const & path);
183                 void update_selection_text (std::string const & path, std::string const & new_text, uint32_t channel);
184
185                 RouteCols                     route_cols;
186                 Glib::RefPtr<Gtk::ListStore>  route_list;
187
188                 uint32_t                      static_columns;
189                 uint32_t                      n_channels;
190         };
191
192         uint32_t                     max_channels;
193
194         Gtk::ScrolledWindow          channel_scroller;
195         Gtk::Alignment               channel_alignment;
196         ChannelTreeView              channel_view;
197
198 };
199
200 class RegionExportChannelSelector : public ExportChannelSelector
201 {
202 public:
203         RegionExportChannelSelector (ARDOUR::Session * session,
204                                      ProfileManagerPtr manager,
205                                      ARDOUR::AudioRegion const & region,
206                                      ARDOUR::AudioTrack & track);
207
208         virtual void sync_with_manager ();
209
210 private:
211
212         void handle_selection ();
213
214         ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
215         boost::shared_ptr<ARDOUR::RegionExportChannelFactory> factory;
216         ARDOUR::AudioRegion const & region;
217         ARDOUR::AudioTrack & track;
218
219         uint32_t region_chans;
220         uint32_t track_chans;
221
222         /*** GUI components ***/
223
224         Gtk::VBox             vbox;
225
226         Gtk::RadioButtonGroup type_group;
227         Gtk::RadioButton      raw_button;
228         Gtk::RadioButton      fades_button;
229         Gtk::RadioButton      processed_button;
230 };
231
232 class TrackExportChannelSelector : public ExportChannelSelector
233 {
234   public:
235         TrackExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
236
237         virtual void sync_with_manager ();
238
239         bool track_output () const { return track_output_button.get_active(); }
240
241   private:
242
243         void fill_list();
244         void add_track (boost::shared_ptr<ARDOUR::Route> route);
245         void update_config();
246         ChannelConfigList configs;
247
248         Gtk::VBox main_layout;
249
250         struct TrackCols : public Gtk::TreeModelColumnRecord
251         {
252           public:
253                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route;
254                 Gtk::TreeModelColumn<std::string>     label;
255                 Gtk::TreeModelColumn<bool>            selected;
256                 Gtk::TreeModelColumn<uint32_t>        order_key;
257
258                 TrackCols () { add (route); add(label); add(selected); add(order_key); }
259         };
260         TrackCols                    track_cols;
261
262         Glib::RefPtr<Gtk::ListStore> track_list;
263         Gtk::TreeView                track_view;
264
265         Gtk::ScrolledWindow          track_scroller;
266
267         Gtk::HBox                    options_box;
268         Gtk::CheckButton             track_output_button;
269         Gtk::Button                  select_tracks_button;
270         Gtk::Button                  select_busses_button;
271         Gtk::Button                  select_none_button;
272         void select_tracks ();
273         void select_busses ();
274         void select_none ();
275
276         void track_outputs_selected ();
277 };
278
279 #endif /* __export_channel_selector_h__ */