2 * Copyright (C) 2008-2013 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2008-2013 Sakari Bergen <sakari.bergen@beatwaves.net>
4 * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
5 * Copyright (C) 2013-2015 Colin Fletcher <colin.m.fletcher@googlemail.com>
6 * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef __export_channel_selector_h__
24 #define __export_channel_selector_h__
28 #include "ardour/export_profile_manager.h"
34 #include <sigc++/signal.h>
35 #include <boost/shared_ptr.hpp>
37 #include <gtkmm/alignment.h>
38 #include <gtkmm/box.h>
39 #include <gtkmm/cellrenderercombo.h>
40 #include <gtkmm/checkbutton.h>
41 #include <gtkmm/label.h>
42 #include <gtkmm/liststore.h>
43 #include <gtkmm/scrolledwindow.h>
44 #include <gtkmm/spinbutton.h>
45 #include <gtkmm/treemodel.h>
46 #include <gtkmm/treeview.h>
48 #include "widgets/ardour_dropdown.h"
52 class ExportChannelConfiguration;
53 class RegionExportChannelFactory;
63 class ExportChannelSelector : public Gtk::HBox, public ARDOUR::SessionHandlePtr
66 typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr;
67 typedef std::list<ChannelConfigPtr> ChannelConfigList;
68 typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
70 ProfileManagerPtr manager;
73 ExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager)
74 : SessionHandlePtr (session)
78 virtual ~ExportChannelSelector () {}
80 virtual void sync_with_manager () = 0;
82 sigc::signal<void> CriticalSelectionChanged;
85 class PortExportChannelSelector : public ExportChannelSelector
89 PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
90 ~PortExportChannelSelector ();
92 void sync_with_manager ();
96 void fill_route_list ();
97 void update_channel_count ();
98 void update_split_state ();
100 typedef std::list<ARDOUR::ExportChannelPtr> CahnnelList;
102 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
106 Gtk::VBox channels_vbox;
107 Gtk::HBox channels_hbox;
109 Gtk::Label channels_label;
110 Gtk::SpinButton channels_spinbutton;
111 Gtk::CheckButton split_checkbox;
113 /* Column record for channel selector view */
115 class RouteCols : public Gtk::TreeModelColumnRecord
121 RouteCols () : n_channels (0)
122 { add (selected); add (name); add (io); add (port_list_col); }
124 void add_channels (uint32_t chans);
127 /* Channel count starts from one! */
129 Channel & get_channel (uint32_t channel);
133 Gtk::TreeModelColumn<bool> selected;
134 Gtk::TreeModelColumn<std::string> name;
135 Gtk::TreeModelColumn<ARDOUR::IO *> io;
137 /* Combo list column (shared by all channels) */
139 typedef Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > ComboCol;
140 ComboCol port_list_col;
142 /* Channel struct, that represents the selected port and its name */
146 Channel (RouteCols & cols) { cols.add (port); cols.add (label); }
148 Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
149 Gtk::TreeModelColumn<std::string> label;
151 std::list<Channel> channels;
153 /* List of available ports
154 * Note: We need only one list of selectable ports per route,
155 * so the list is kept in the column record
158 /* Column record for selecting ports for a channel from a route */
160 class PortCols : public Gtk::TreeModel::ColumnRecord
163 PortCols () { add(selected); add(port); add(label); }
165 Gtk::TreeModelColumn<bool> selected; // not used ATM
166 Gtk::TreeModelColumn<boost::weak_ptr<ARDOUR::AudioPort> > port;
167 Gtk::TreeModelColumn<std::string> label;
174 class ChannelTreeView : public Gtk::TreeView
178 ChannelTreeView (uint32_t max_channels);
179 void set_config (ChannelConfigPtr c);
181 /* Routes have to be added before adding channels */
183 void clear_routes () { route_list->clear (); }
184 void add_route (ARDOUR::IO * route);
185 void set_channel_count (uint32_t channels);
187 sigc::signal<void> CriticalSelectionChanged;
191 ChannelConfigPtr config;
192 void update_config ();
194 /* Signal handlers for selections changes in the view */
196 void update_toggle_selection (std::string const & path);
197 void update_selection_text (std::string const & path, std::string const & new_text, uint32_t channel);
199 RouteCols route_cols;
200 Glib::RefPtr<Gtk::ListStore> route_list;
202 uint32_t static_columns;
206 uint32_t max_channels;
208 Gtk::ScrolledWindow channel_scroller;
209 Gtk::Alignment channel_alignment;
210 ChannelTreeView channel_view;
214 class RegionExportChannelSelector : public ExportChannelSelector
217 RegionExportChannelSelector (ARDOUR::Session * session,
218 ProfileManagerPtr manager,
219 ARDOUR::AudioRegion const & region,
220 ARDOUR::AudioTrack & track);
222 virtual void sync_with_manager ();
226 void handle_selection ();
228 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
229 boost::shared_ptr<ARDOUR::RegionExportChannelFactory> factory;
230 ARDOUR::AudioRegion const & region;
231 ARDOUR::AudioTrack & track;
233 uint32_t region_chans;
234 uint32_t track_chans;
236 /*** GUI components ***/
240 Gtk::RadioButtonGroup type_group;
241 Gtk::RadioButton raw_button;
242 Gtk::RadioButton fades_button;
243 Gtk::RadioButton processed_button;
246 class TrackExportChannelSelector : public ExportChannelSelector
249 TrackExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
250 ~TrackExportChannelSelector ();
252 virtual void sync_with_manager ();
254 bool track_output () const { return track_output_button.get_active(); }
259 void add_track (boost::shared_ptr<ARDOUR::Route> route, bool selected);
260 void update_config();
261 ChannelConfigList configs;
263 Gtk::VBox main_layout;
265 struct TrackCols : public Gtk::TreeModelColumnRecord
268 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route;
269 Gtk::TreeModelColumn<std::string> label;
270 Gtk::TreeModelColumn<bool> selected;
271 Gtk::TreeModelColumn<uint32_t> order_key;
273 TrackCols () { add (route); add(label); add(selected); add(order_key); }
275 TrackCols track_cols;
277 Glib::RefPtr<Gtk::ListStore> track_list;
278 Gtk::TreeView track_view;
280 Gtk::ScrolledWindow track_scroller;
282 Gtk::HBox options_box;
283 Gtk::CheckButton track_output_button;
284 ArdourWidgets::ArdourDropdown select_menu;
285 Gtk::CheckMenuItem* exclude_hidden;
286 Gtk::CheckMenuItem* exclude_muted;
287 void select_tracks ();
288 void select_busses ();
291 void track_outputs_selected ();
294 #endif /* __export_channel_selector_h__ */