Remove <gtkmm.h> include from 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 <sigc++/signal.h>
33 #include <boost/shared_ptr.hpp>
34
35 #include <gtkmm/alignment.h>
36 #include <gtkmm/box.h>
37 #include <gtkmm/cellrenderercombo.h>
38 #include <gtkmm/checkbutton.h>
39 #include <gtkmm/label.h>
40 #include <gtkmm/liststore.h>
41 #include <gtkmm/scrolledwindow.h>
42 #include <gtkmm/spinbutton.h>
43 #include <gtkmm/treemodel.h>
44 #include <gtkmm/treeview.h>
45
46 namespace ARDOUR {
47         class Session;
48         class ExportChannelConfiguration;
49         class RegionExportChannelFactory;
50         class ExportHandler;
51         class AudioPort;
52         class IO;
53         class AudioRegion;
54         class AudioTrack;
55 }
56
57 class XMLNode;
58
59 class ExportChannelSelector : public Gtk::HBox, public ARDOUR::SessionHandlePtr
60 {
61 protected:
62         typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr;
63         typedef std::list<ChannelConfigPtr> ChannelConfigList;
64         typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
65
66         ProfileManagerPtr manager;
67
68 public:
69         ExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager)
70                 : SessionHandlePtr (session)
71                 , manager (manager)
72         {}
73
74         virtual ~ExportChannelSelector () {}
75
76         virtual void sync_with_manager () = 0;
77
78         sigc::signal<void> CriticalSelectionChanged;
79 };
80
81 class PortExportChannelSelector : public ExportChannelSelector
82 {
83 public:
84
85         PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
86         ~PortExportChannelSelector ();
87
88         void sync_with_manager ();
89
90 private:
91
92         void fill_route_list ();
93         void update_channel_count ();
94         void update_split_state ();
95
96         typedef std::list<ARDOUR::ExportChannelPtr> CahnnelList;
97
98         ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
99
100         /*** GUI stuff ***/
101
102         Gtk::VBox         channels_vbox;
103         Gtk::HBox         channels_hbox;
104
105         Gtk::Label        channels_label;
106         Gtk::SpinButton   channels_spinbutton;
107         Gtk::CheckButton  split_checkbox;
108
109         /* Column record for channel selector view */
110
111         class RouteCols : public Gtk::TreeModelColumnRecord
112         {
113         public:
114
115                 struct Channel;
116
117                 RouteCols () : n_channels (0)
118                 { add (selected); add (name); add (io); add (port_list_col); }
119
120                 void add_channels (uint32_t chans);
121                 uint32_t n_channels;
122
123                 /* Channel count starts from one! */
124
125                 Channel & get_channel (uint32_t channel);
126
127                 /* Static columns */
128
129                 Gtk::TreeModelColumn<bool>           selected;
130                 Gtk::TreeModelColumn<std::string>  name;
131                 Gtk::TreeModelColumn<ARDOUR::IO *>   io;
132
133                 /* Combo list column (shared by all channels) */
134
135                 typedef Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > ComboCol;
136                 ComboCol                             port_list_col;
137
138                 /* Channel struct, that represents the selected port and its name */
139
140                 struct Channel {
141                 public:
142                         Channel (RouteCols & cols) { cols.add (port); cols.add (label); }
143
144                         Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
145                         Gtk::TreeModelColumn<std::string> label;
146                 };
147                 std::list<Channel> channels;
148
149                 /* List of available ports
150                  * Note: We need only one list of selectable ports per route,
151                  * so the list is kept in the column record
152                  */
153
154                 /* Column record for selecting ports for a channel from a route */
155
156                 class PortCols : public Gtk::TreeModel::ColumnRecord
157                 {
158                 public:
159                         PortCols () { add(selected); add(port); add(label); }
160
161                         Gtk::TreeModelColumn<bool> selected;  // not used ATM
162                         Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
163                         Gtk::TreeModelColumn<std::string> label;
164                 };
165                 PortCols port_cols;
166         };
167
168         /* Channels view */
169
170         class ChannelTreeView : public Gtk::TreeView
171         {
172         public:
173
174                 ChannelTreeView (uint32_t max_channels);
175                 void set_config (ChannelConfigPtr c);
176
177                 /* Routes have to be added before adding channels */
178
179                 void clear_routes () { route_list->clear (); }
180                 void add_route (ARDOUR::IO * route);
181                 void set_channel_count (uint32_t channels);
182
183                 sigc::signal<void> CriticalSelectionChanged;
184
185         private:
186
187                 ChannelConfigPtr config;
188                 void update_config ();
189
190                 /* Signal handlers for selections changes in the view */
191
192                 void update_toggle_selection (std::string const & path);
193                 void update_selection_text (std::string const & path, std::string const & new_text, uint32_t channel);
194
195                 RouteCols                     route_cols;
196                 Glib::RefPtr<Gtk::ListStore>  route_list;
197
198                 uint32_t                      static_columns;
199                 uint32_t                      n_channels;
200         };
201
202         uint32_t                     max_channels;
203
204         Gtk::ScrolledWindow          channel_scroller;
205         Gtk::Alignment               channel_alignment;
206         ChannelTreeView              channel_view;
207
208 };
209
210 class RegionExportChannelSelector : public ExportChannelSelector
211 {
212 public:
213         RegionExportChannelSelector (ARDOUR::Session * session,
214                                      ProfileManagerPtr manager,
215                                      ARDOUR::AudioRegion const & region,
216                                      ARDOUR::AudioTrack & track);
217
218         virtual void sync_with_manager ();
219
220 private:
221
222         void handle_selection ();
223
224         ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
225         boost::shared_ptr<ARDOUR::RegionExportChannelFactory> factory;
226         ARDOUR::AudioRegion const & region;
227         ARDOUR::AudioTrack & track;
228
229         uint32_t region_chans;
230         uint32_t track_chans;
231
232         /*** GUI components ***/
233
234         Gtk::VBox             vbox;
235
236         Gtk::RadioButtonGroup type_group;
237         Gtk::RadioButton      raw_button;
238         Gtk::RadioButton      fades_button;
239         Gtk::RadioButton      processed_button;
240 };
241
242 class TrackExportChannelSelector : public ExportChannelSelector
243 {
244   public:
245         TrackExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
246
247         virtual void sync_with_manager ();
248
249         bool track_output () const { return track_output_button.get_active(); }
250
251   private:
252
253         void fill_list();
254         void add_track (boost::shared_ptr<ARDOUR::Route> route);
255         void update_config();
256         ChannelConfigList configs;
257
258         Gtk::VBox main_layout;
259
260         struct TrackCols : public Gtk::TreeModelColumnRecord
261         {
262           public:
263                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route;
264                 Gtk::TreeModelColumn<std::string>     label;
265                 Gtk::TreeModelColumn<bool>            selected;
266                 Gtk::TreeModelColumn<uint32_t>        order_key;
267
268                 TrackCols () { add (route); add(label); add(selected); add(order_key); }
269         };
270         TrackCols                    track_cols;
271
272         Glib::RefPtr<Gtk::ListStore> track_list;
273         Gtk::TreeView                track_view;
274
275         Gtk::ScrolledWindow          track_scroller;
276
277         Gtk::HBox                    options_box;
278         Gtk::CheckButton             track_output_button;
279         Gtk::Button                  select_tracks_button;
280         Gtk::Button                  select_busses_button;
281         Gtk::Button                  select_none_button;
282         void select_tracks ();
283         void select_busses ();
284         void select_none ();
285
286         void track_outputs_selected ();
287 };
288
289 #endif /* __export_channel_selector_h__ */