fix math bug with numthreads computation
[ardour2.git] / gtk2_ardour / export_channel_selector.h
blob6a1c4252a47a4e2ec0e3099ff7fe2f07ada0b8a6
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 boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
52 ProfileManagerPtr manager;
54 public:
55 ExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager)
56 : SessionHandlePtr (session)
57 , manager (manager)
60 virtual ~ExportChannelSelector () {}
62 virtual void sync_with_manager () = 0;
64 sigc::signal<void> CriticalSelectionChanged;
67 class PortExportChannelSelector : public ExportChannelSelector
70 public:
72 PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager);
73 ~PortExportChannelSelector ();
75 void sync_with_manager ();
77 private:
79 void fill_route_list ();
80 void update_channel_count ();
81 void update_split_state ();
83 typedef std::list<ARDOUR::ExportChannelPtr> CahnnelList;
85 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
87 /*** GUI stuff ***/
89 Gtk::VBox channels_vbox;
90 Gtk::HBox channels_hbox;
92 Gtk::Label channels_label;
93 Gtk::SpinButton channels_spinbutton;
94 Gtk::CheckButton split_checkbox;
96 /* Column record for channel selector view */
98 class RouteCols : public Gtk::TreeModelColumnRecord
100 public:
102 struct Channel;
104 RouteCols () : n_channels (0)
105 { add (selected); add (name); add (io); add (port_list_col); }
107 void add_channels (uint32_t chans);
108 uint32_t n_channels;
110 /* Channel count starts from one! */
112 Channel & get_channel (uint32_t channel);
114 /* Static columns */
116 Gtk::TreeModelColumn<bool> selected;
117 Gtk::TreeModelColumn<Glib::ustring> name;
118 Gtk::TreeModelColumn<ARDOUR::IO *> io;
120 /* Combo list column (shared by all channels) */
122 typedef Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > ComboCol;
123 ComboCol port_list_col;
125 /* Channel struct, that represents the selected port and it's name */
127 struct Channel {
128 public:
129 Channel (RouteCols & cols) { cols.add (port); cols.add (label); }
131 Gtk::TreeModelColumn<ARDOUR::AudioPort *> port;
132 Gtk::TreeModelColumn<Glib::ustring> label;
134 std::list<Channel> channels;
136 /* List of available ports
137 * Note: We need only one list of selectable ports per route,
138 * so the list is kept in the column record
141 /* Column record for selecting ports for a channel from a route */
143 class PortCols : public Gtk::TreeModel::ColumnRecord
145 public:
146 PortCols () { add (selected); add(port); add(label); }
148 Gtk::TreeModelColumn<bool> selected; // not used ATM
149 Gtk::TreeModelColumn<ARDOUR::AudioPort *> port;
150 Gtk::TreeModelColumn<Glib::ustring> label;
152 PortCols port_cols;
155 /* Channels view */
157 class ChannelTreeView : public Gtk::TreeView {
158 public:
160 ChannelTreeView (uint32_t max_channels);
161 void set_config (ChannelConfigPtr c);
163 /* Routes have to be added before adding channels */
165 void clear_routes () { route_list->clear (); }
166 void add_route (ARDOUR::IO * route);
167 void set_channel_count (uint32_t channels);
169 sigc::signal<void> CriticalSelectionChanged;
171 private:
173 ChannelConfigPtr config;
174 void update_config ();
176 /* Signal handlers for selections changes in the view */
178 void update_toggle_selection (Glib::ustring const & path);
179 void update_selection_text (Glib::ustring const & path, Glib::ustring const & new_text, uint32_t channel);
181 RouteCols route_cols;
182 Glib::RefPtr<Gtk::ListStore> route_list;
184 uint32_t static_columns;
185 uint32_t n_channels;
188 uint32_t max_channels;
190 Gtk::ScrolledWindow channel_scroller;
191 Gtk::Alignment channel_alignment;
192 ChannelTreeView channel_view;
196 class RegionExportChannelSelector : public ExportChannelSelector
198 public:
199 RegionExportChannelSelector (ARDOUR::Session * session,
200 ProfileManagerPtr manager,
201 ARDOUR::AudioRegion const & region,
202 ARDOUR::AudioTrack & track);
204 virtual void sync_with_manager ();
206 private:
208 void handle_selection ();
210 ARDOUR::ExportProfileManager::ChannelConfigStatePtr state;
211 boost::shared_ptr<ARDOUR::RegionExportChannelFactory> factory;
212 ARDOUR::AudioRegion const & region;
213 ARDOUR::AudioTrack & track;
215 uint32_t region_chans;
216 uint32_t track_chans;
218 /*** GUI components ***/
220 Gtk::VBox vbox;
222 Gtk::RadioButtonGroup type_group;
223 Gtk::RadioButton raw_button;
224 Gtk::RadioButton fades_button;
225 Gtk::RadioButton processed_button;
228 #endif /* __export_channel_selector_h__ */