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