2 Copyright (C) 2008 Paul Davis
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__
26 #include "ardour/export_profile_manager.h"
32 #include <sigc++/signal.h>
33 #include <boost/shared_ptr.hpp>
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>
48 class ExportChannelConfiguration;
49 class RegionExportChannelFactory;
59 class ExportChannelSelector : public Gtk::HBox, public ARDOUR::SessionHandlePtr
62 typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr;
63 typedef std::list<ChannelConfigPtr> ChannelConfigList;
64 typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
66 ProfileManagerPtr manager;
69 ExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager)
70 : SessionHandlePtr (session)
74 virtual ~ExportChannelSelector () {}
76 virtual void sync_with_manager () = 0;
78 sigc::signal<void> CriticalSelectionChanged;
81 class PortExportChannelSelector : public ExportChannelSelector
85 PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
86 ~PortExportChannelSelector ();
88 void sync_with_manager ();
92 void fill_route_list ();
93 void update_channel_count ();
94 void update_split_state ();
96 typedef std::list<ARDOUR::ExportChannelPtr> CahnnelList;
98 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
102 Gtk::VBox channels_vbox;
103 Gtk::HBox channels_hbox;
105 Gtk::Label channels_label;
106 Gtk::SpinButton channels_spinbutton;
107 Gtk::CheckButton split_checkbox;
109 /* Column record for channel selector view */
111 class RouteCols : public Gtk::TreeModelColumnRecord
117 RouteCols () : n_channels (0)
118 { add (selected); add (name); add (io); add (port_list_col); }
120 void add_channels (uint32_t chans);
123 /* Channel count starts from one! */
125 Channel & get_channel (uint32_t channel);
129 Gtk::TreeModelColumn<bool> selected;
130 Gtk::TreeModelColumn<std::string> name;
131 Gtk::TreeModelColumn<ARDOUR::IO *> io;
133 /* Combo list column (shared by all channels) */
135 typedef Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > ComboCol;
136 ComboCol port_list_col;
138 /* Channel struct, that represents the selected port and its name */
142 Channel (RouteCols & cols) { cols.add (port); cols.add (label); }
144 Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
145 Gtk::TreeModelColumn<std::string> label;
147 std::list<Channel> channels;
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
154 /* Column record for selecting ports for a channel from a route */
156 class PortCols : public Gtk::TreeModel::ColumnRecord
159 PortCols () { add(selected); add(port); add(label); }
161 Gtk::TreeModelColumn<bool> selected; // not used ATM
162 Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
163 Gtk::TreeModelColumn<std::string> label;
170 class ChannelTreeView : public Gtk::TreeView
174 ChannelTreeView (uint32_t max_channels);
175 void set_config (ChannelConfigPtr c);
177 /* Routes have to be added before adding channels */
179 void clear_routes () { route_list->clear (); }
180 void add_route (ARDOUR::IO * route);
181 void set_channel_count (uint32_t channels);
183 sigc::signal<void> CriticalSelectionChanged;
187 ChannelConfigPtr config;
188 void update_config ();
190 /* Signal handlers for selections changes in the view */
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);
195 RouteCols route_cols;
196 Glib::RefPtr<Gtk::ListStore> route_list;
198 uint32_t static_columns;
202 uint32_t max_channels;
204 Gtk::ScrolledWindow channel_scroller;
205 Gtk::Alignment channel_alignment;
206 ChannelTreeView channel_view;
210 class RegionExportChannelSelector : public ExportChannelSelector
213 RegionExportChannelSelector (ARDOUR::Session * session,
214 ProfileManagerPtr manager,
215 ARDOUR::AudioRegion const & region,
216 ARDOUR::AudioTrack & track);
218 virtual void sync_with_manager ();
222 void handle_selection ();
224 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
225 boost::shared_ptr<ARDOUR::RegionExportChannelFactory> factory;
226 ARDOUR::AudioRegion const & region;
227 ARDOUR::AudioTrack & track;
229 uint32_t region_chans;
230 uint32_t track_chans;
232 /*** GUI components ***/
236 Gtk::RadioButtonGroup type_group;
237 Gtk::RadioButton raw_button;
238 Gtk::RadioButton fades_button;
239 Gtk::RadioButton processed_button;
242 class TrackExportChannelSelector : public ExportChannelSelector
245 TrackExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
247 virtual void sync_with_manager ();
249 bool track_output () const { return track_output_button.get_active(); }
254 void add_track (boost::shared_ptr<ARDOUR::Route> route);
255 void update_config();
256 ChannelConfigList configs;
258 Gtk::VBox main_layout;
260 struct TrackCols : public Gtk::TreeModelColumnRecord
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;
268 TrackCols () { add (route); add(label); add(selected); add(order_key); }
270 TrackCols track_cols;
272 Glib::RefPtr<Gtk::ListStore> track_list;
273 Gtk::TreeView track_view;
275 Gtk::ScrolledWindow track_scroller;
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 ();
286 void track_outputs_selected ();
289 #endif /* __export_channel_selector_h__ */