Remove erroneous assert which I added earlier.
[ardour2.git] / gtk2_ardour / export_channel_selector.h
blobdda449d931442e2607216558ecbee705693855ee
1 /*
2 Copyright (C) 2008 Paul Davis
3 Author: Sakari Bergen
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.
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.
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.
21 #ifndef __export_channel_selector_h__
22 #define __export_channel_selector_h__
24 #include <list>
26 #include "ardour/export_profile_manager.h"
27 #include "ardour/export_channel.h"
29 #include <gtkmm.h>
30 #include <sigc++/signal.h>
31 #include <boost/shared_ptr.hpp>
33 namespace ARDOUR {
34 class Session;
35 class ExportChannelConfiguration;
36 class RegionExportChannelFactory;
37 class ExportHandler;
38 class AudioPort;
39 class IO;
40 class AudioRegion;
41 class AudioTrack;
44 class XMLNode;
46 class ExportChannelSelector : public Gtk::HBox, public ARDOUR::SessionHandlePtr
48 protected:
49 typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr;
50 typedef std::list<ChannelConfigPtr> ChannelConfigList;
51 typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
53 ProfileManagerPtr manager;
55 public:
56 ExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager)
57 : SessionHandlePtr (session)
58 , manager (manager)
61 virtual ~ExportChannelSelector () {}
63 virtual void sync_with_manager () = 0;
65 sigc::signal<void> CriticalSelectionChanged;
68 class PortExportChannelSelector : public ExportChannelSelector
71 public:
73 PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
74 ~PortExportChannelSelector ();
76 void sync_with_manager ();
78 private:
80 void fill_route_list ();
81 void update_channel_count ();
82 void update_split_state ();
84 typedef std::list<ARDOUR::ExportChannelPtr> CahnnelList;
86 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
88 /*** GUI stuff ***/
90 Gtk::VBox channels_vbox;
91 Gtk::HBox channels_hbox;
93 Gtk::Label channels_label;
94 Gtk::SpinButton channels_spinbutton;
95 Gtk::CheckButton split_checkbox;
97 /* Column record for channel selector view */
99 class RouteCols : public Gtk::TreeModelColumnRecord
101 public:
103 struct Channel;
105 RouteCols () : n_channels (0)
106 { add (selected); add (name); add (io); add (port_list_col); }
108 void add_channels (uint32_t chans);
109 uint32_t n_channels;
111 /* Channel count starts from one! */
113 Channel & get_channel (uint32_t channel);
115 /* Static columns */
117 Gtk::TreeModelColumn<bool> selected;
118 Gtk::TreeModelColumn<std::string> name;
119 Gtk::TreeModelColumn<ARDOUR::IO *> io;
121 /* Combo list column (shared by all channels) */
123 typedef Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > ComboCol;
124 ComboCol port_list_col;
126 /* Channel struct, that represents the selected port and it's name */
128 struct Channel {
129 public:
130 Channel (RouteCols & cols) { cols.add (port); cols.add (label); }
132 Gtk::TreeModelColumn<ARDOUR::AudioPort *> port;
133 Gtk::TreeModelColumn<std::string> label;
135 std::list<Channel> channels;
137 /* List of available ports
138 * Note: We need only one list of selectable ports per route,
139 * so the list is kept in the column record
142 /* Column record for selecting ports for a channel from a route */
144 class PortCols : public Gtk::TreeModel::ColumnRecord
146 public:
147 PortCols () { add (selected); add(port); add(label); }
149 Gtk::TreeModelColumn<bool> selected; // not used ATM
150 Gtk::TreeModelColumn<ARDOUR::AudioPort *> port;
151 Gtk::TreeModelColumn<std::string> label;
153 PortCols port_cols;
156 /* Channels view */
158 class ChannelTreeView : public Gtk::TreeView {
159 public:
161 ChannelTreeView (uint32_t max_channels);
162 void set_config (ChannelConfigPtr c);
164 /* Routes have to be added before adding channels */
166 void clear_routes () { route_list->clear (); }
167 void add_route (ARDOUR::IO * route);
168 void set_channel_count (uint32_t channels);
170 sigc::signal<void> CriticalSelectionChanged;
172 private:
174 ChannelConfigPtr config;
175 void update_config ();
177 /* Signal handlers for selections changes in the view */
179 void update_toggle_selection (std::string const & path);
180 void update_selection_text (std::string const & path, std::string const & new_text, uint32_t channel);
182 RouteCols route_cols;
183 Glib::RefPtr<Gtk::ListStore> route_list;
185 uint32_t static_columns;
186 uint32_t n_channels;
189 uint32_t max_channels;
191 Gtk::ScrolledWindow channel_scroller;
192 Gtk::Alignment channel_alignment;
193 ChannelTreeView channel_view;
197 class RegionExportChannelSelector : public ExportChannelSelector
199 public:
200 RegionExportChannelSelector (ARDOUR::Session * session,
201 ProfileManagerPtr manager,
202 ARDOUR::AudioRegion const & region,
203 ARDOUR::AudioTrack & track);
205 virtual void sync_with_manager ();
207 private:
209 void handle_selection ();
211 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
212 boost::shared_ptr<ARDOUR::RegionExportChannelFactory> factory;
213 ARDOUR::AudioRegion const & region;
214 ARDOUR::AudioTrack & track;
216 uint32_t region_chans;
217 uint32_t track_chans;
219 /*** GUI components ***/
221 Gtk::VBox vbox;
223 Gtk::RadioButtonGroup type_group;
224 Gtk::RadioButton raw_button;
225 Gtk::RadioButton fades_button;
226 Gtk::RadioButton processed_button;
229 class TrackExportChannelSelector : public ExportChannelSelector
231 public:
232 TrackExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
234 virtual void sync_with_manager ();
236 private:
238 void fill_list();
239 void add_track(ARDOUR::Route * route);
240 void update_config();
242 ChannelConfigList configs;
244 struct TrackCols : public Gtk::TreeModelColumnRecord
246 public:
247 Gtk::TreeModelColumn<ARDOUR::Route *> track;
248 Gtk::TreeModelColumn<std::string> label;
249 Gtk::TreeModelColumn<bool> selected;
251 TrackCols () { add (track); add(label); add(selected); }
253 TrackCols track_cols;
255 Glib::RefPtr<Gtk::ListStore> track_list;
256 Gtk::TreeView track_view;
258 Gtk::ScrolledWindow track_scroller;
262 #endif /* __export_channel_selector_h__ */