Fix thinkos in cubasish theme
[ardour.git] / gtk2_ardour / export_format_dialog.h
1 /*
2  * Copyright (C) 2008-2013 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2009 David Robillard <d@drobilla.net>
4  * Copyright (C) 2011-2012 Sakari Bergen <sakari.bergen@beatwaves.net>
5  * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
6  * Copyright (C) 2015-2018 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_format_dialog_h__
24 #define __export_format_dialog_h__
25
26 #include "ardour/types.h"
27 #include "ardour/export_format_manager.h"
28 #include "ardour/export_format_compatibility.h"
29 #include "ardour/export_formats.h"
30
31 #include "pbd/xml++.h"
32 #include "pbd/signals.h"
33
34 #include "ardour_dialog.h"
35 #include "audio_clock.h"
36
37 #ifdef interface
38 #undef interface
39 #endif
40
41 #include <gtkmm/adjustment.h>
42 #include <gtkmm/box.h>
43 #include <gtkmm/checkbutton.h>
44 #include <gtkmm/combobox.h>
45 #include <gtkmm/entry.h>
46 #include <gtkmm/label.h>
47 #include <gtkmm/liststore.h>
48 #include <gtkmm/radiobutton.h>
49 #include <gtkmm/spinbutton.h>
50 #include <gtkmm/table.h>
51 #include <gtkmm/treeview.h>
52
53 class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList
54 {
55 private:
56
57         typedef ARDOUR::WeakExportFormatCompatibilityPtr WeakCompatPtr;
58         typedef ARDOUR::WeakExportFormatPtr WeakFormatPtr;
59         typedef ARDOUR::ExportFormatManager::WeakQualityPtr WeakQualityPtr;
60         typedef ARDOUR::ExportFormatManager::WeakSampleRatePtr WeakSampleRatePtr;
61         typedef ARDOUR::ExportFormatManager::WeakSampleFormatPtr WeakSampleFormatPtr;
62         typedef ARDOUR::ExportFormatManager::WeakDitherTypePtr WeakDitherTypePtr;
63
64         typedef boost::shared_ptr<ARDOUR::ExportFormatSpecification> FormatPtr;
65
66
67 public:
68
69         explicit ExportFormatDialog (FormatPtr format, bool new_dialog = false);
70         ~ExportFormatDialog ();
71
72         void set_session (ARDOUR::Session* s);
73
74 private:
75
76         FormatPtr                   format;
77         ARDOUR::ExportFormatManager manager;
78
79         XMLNode & original_state;
80
81         ARDOUR::AnyTime silence_start;
82         ARDOUR::AnyTime silence_end;
83
84         void end_dialog ();
85         void revert ();
86
87         /*** Init functions ***/
88
89         void load_state (FormatPtr spec);
90         void init_format_table ();
91         void init_encoding_option_widgets ();
92
93         /*** Interactive selections ***/
94
95         /* These are connected to signals from GUI components, and should change element states  */
96
97         void update_compatibility_selection (std::string const & path);
98         void update_quality_selection ();
99         void update_format_selection ();
100         void update_sample_rate_selection ();
101         void update_sample_format_selection ();
102         void update_dither_type_selection ();
103
104         template<typename ColsT>
105         void update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
106
107         /* These are connected to signals from elements, and should only update the gui */
108
109         void change_compatibility_selection (bool select, WeakCompatPtr compat);
110
111         void change_quality_selection (bool select, WeakQualityPtr quality);
112         void change_format_selection (bool select, WeakFormatPtr format);
113         void change_sample_rate_selection (bool select, WeakSampleRatePtr rate);
114         void change_sample_format_selection (bool select, WeakSampleFormatPtr format);
115         void change_dither_type_selection (bool select, WeakDitherTypePtr type);
116
117         template<typename T, typename ColsT>
118         void change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
119
120         void change_quality_compatibility (bool compatibility, WeakQualityPtr quality);
121         void change_format_compatibility (bool compatibility, WeakFormatPtr format);
122         void change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate);
123         void change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format);
124         void change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type);
125
126         template<typename T, typename ColsT>
127         void change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
128                                    std::string const & c_incompatible = "red", std::string const & c_compatible = "white");
129
130         void update_description();
131
132         uint32_t applying_changes_from_engine;
133
134         /*** Non-interactive selections ***/
135
136         void update_name ();
137
138         void update_trim_start_selection ();
139         void update_trim_end_selection ();
140
141         void update_normalize_selection ();
142         void update_normalize_sensitivity ();
143         void update_silence_start_selection ();
144         void update_silence_end_selection ();
145
146         void update_clock (AudioClock & clock, ARDOUR::AnyTime const & time);
147         void update_time (ARDOUR::AnyTime & time, AudioClock const & clock);
148
149         void update_src_quality_selection ();
150         void update_codec_quality_selection ();
151         void update_tagging_selection ();
152         void set_codec_quality_selection ();
153
154         /*** Encoding options */
155
156         void change_encoding_options (ARDOUR::ExportFormatPtr ptr);
157
158         void empty_encoding_option_table ();
159         void remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from);
160
161         void show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr);
162         void show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr);
163         void show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr);
164         void show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr);
165         void show_ffmpeg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ptr);
166
167         void fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr);
168         void fill_codec_quality_lists (boost::shared_ptr<ARDOUR::HasCodecQuality> ptr);
169
170         /*** GUI components ***/
171
172         /* Name, new and remove */
173
174         Gtk::HBox  name_hbox;
175
176         Gtk::Label name_label;
177         Gtk::Entry name_entry;
178         Gtk::Label name_generated_part;
179
180         /* Normalize */
181
182         Gtk::HBox        normalize_hbox;
183         Gtk::CheckButton normalize_checkbox;
184         Gtk::RadioButton normalize_peak_rb;
185         Gtk::RadioButton normalize_loudness_rb;
186         Gtk::SpinButton  normalize_dbfs_spinbutton;
187         Gtk::Adjustment  normalize_dbfs_adjustment;
188         Gtk::SpinButton  normalize_lufs_spinbutton;
189         Gtk::Adjustment  normalize_lufs_adjustment;
190         Gtk::SpinButton  normalize_dbtp_spinbutton;
191         Gtk::Adjustment  normalize_dbtp_adjustment;
192         Gtk::Label       normalize_dbfs_label;
193         Gtk::Label       normalize_lufs_label;
194         Gtk::Label       normalize_dbtp_label;
195
196         /* Silence  */
197
198         Gtk::Table       silence_table;
199
200         Gtk::CheckButton trim_start_checkbox;
201         Gtk::CheckButton silence_start_checkbox;
202         AudioClock       silence_start_clock;
203
204         Gtk::CheckButton trim_end_checkbox;
205         Gtk::CheckButton silence_end_checkbox;
206         AudioClock       silence_end_clock;
207
208         /* Post-export hook */
209
210         Gtk::Label       command_label;
211         Gtk::Entry       command_entry;
212
213         /* Format table */
214
215         struct CompatibilityCols : public Gtk::TreeModelColumnRecord
216         {
217         public:
218                 Gtk::TreeModelColumn<ARDOUR::ExportFormatCompatibilityPtr>  ptr;
219                 Gtk::TreeModelColumn<bool>                                  selected;
220                 Gtk::TreeModelColumn<std::string>                           label;
221
222                 CompatibilityCols () { add(ptr); add(selected); add(label); }
223         };
224         CompatibilityCols            compatibility_cols;
225         Glib::RefPtr<Gtk::ListStore> compatibility_list;
226
227         /* Hack to disallow row selection in compatibilities */
228         void prohibit_compatibility_selection ();
229         sigc::connection compatibility_select_connection;
230
231         struct QualityCols : public Gtk::TreeModelColumnRecord
232         {
233         public:
234                 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::QualityPtr>  ptr;
235                 Gtk::TreeModelColumn<std::string>                            color;
236                 Gtk::TreeModelColumn<std::string>                            label;
237
238                 QualityCols () { add(ptr); add(color); add(label); }
239         };
240         QualityCols                  quality_cols;
241         Glib::RefPtr<Gtk::ListStore> quality_list;
242
243         struct FormatCols : public Gtk::TreeModelColumnRecord
244         {
245         public:
246                 Gtk::TreeModelColumn<ARDOUR::ExportFormatPtr>  ptr;
247                 Gtk::TreeModelColumn<std::string>              color;
248                 Gtk::TreeModelColumn<std::string>              label;
249
250                 FormatCols () { add(ptr); add(color); add(label); }
251         };
252         FormatCols                   format_cols;
253         Glib::RefPtr<Gtk::ListStore> format_list;
254
255         struct SampleRateCols : public Gtk::TreeModelColumnRecord
256         {
257         public:
258                 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::SampleRatePtr>  ptr;
259                 Gtk::TreeModelColumn<std::string>                               color;
260                 Gtk::TreeModelColumn<std::string>                               label;
261
262                 SampleRateCols () { add(ptr); add(color); add(label); }
263         };
264         SampleRateCols               sample_rate_cols;
265         Glib::RefPtr<Gtk::ListStore> sample_rate_list;
266
267         Gtk::Table       format_table;
268
269         Gtk::Label       compatibility_label;
270         Gtk::Label       quality_label;
271         Gtk::Label       format_label;
272         Gtk::Label       sample_rate_label;
273
274         Gtk::TreeView    compatibility_view;
275         Gtk::TreeView    quality_view;
276         Gtk::TreeView    format_view;
277         Gtk::TreeView    sample_rate_view;
278
279         /* SRC quality combo */
280
281         struct SRCQualityCols : public Gtk::TreeModelColumnRecord
282         {
283         public:
284                 Gtk::TreeModelColumn<ARDOUR::ExportFormatBase::SRCQuality>  id;
285                 Gtk::TreeModelColumn<std::string>                         label;
286
287                 SRCQualityCols () { add(id); add(label); }
288         };
289         SRCQualityCols               src_quality_cols;
290         Glib::RefPtr<Gtk::ListStore> src_quality_list;
291
292         Gtk::Label      src_quality_label;
293         Gtk::ComboBox   src_quality_combo;
294
295         /* Common encoding option components */
296
297         Gtk::VBox   encoding_options_vbox;
298         Gtk::Label  encoding_options_label;
299
300         Gtk::Table  encoding_options_table;
301
302         /* Other common components */
303
304         Gtk::Button * revert_button;
305         Gtk::Button * close_button;
306
307         /*** Changing encoding option stuff ***/
308
309         /* Linear */
310
311         struct SampleFormatCols : public Gtk::TreeModelColumnRecord
312         {
313         public:
314                 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::SampleFormatPtr>   ptr;
315                 Gtk::TreeModelColumn<std::string>                              color;
316                 Gtk::TreeModelColumn<std::string>                              label;
317
318                 SampleFormatCols () { add(ptr); add(color); add(label); }
319         };
320         SampleFormatCols             sample_format_cols;
321         Glib::RefPtr<Gtk::ListStore> sample_format_list;
322
323         struct DitherTypeCols : public Gtk::TreeModelColumnRecord
324         {
325         public:
326                 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::DitherTypePtr>   ptr;
327                 Gtk::TreeModelColumn<std::string>                            color;
328                 Gtk::TreeModelColumn<std::string>                            label;
329
330                 DitherTypeCols () { add(ptr); add (color); add(label); }
331         };
332         DitherTypeCols               dither_type_cols;
333         Glib::RefPtr<Gtk::ListStore> dither_type_list;
334
335         Gtk::Label  sample_format_label;
336         Gtk::Label  dither_label;
337
338         Gtk::CheckButton with_cue;
339         Gtk::CheckButton with_toc;
340         Gtk::CheckButton with_mp4chaps;
341
342         Gtk::VBox cue_toc_vbox;
343
344         void update_with_toc ();
345         void update_with_cue ();
346         void update_with_mp4chaps();
347         void update_command ();
348
349         Gtk::TreeView sample_format_view;
350         Gtk::TreeView dither_type_view;
351
352
353         /* codec quality combo */
354
355         struct CodecQualityCols : public Gtk::TreeModelColumnRecord
356         {
357         public:
358                 Gtk::TreeModelColumn<int>          quality;
359                 Gtk::TreeModelColumn<std::string>  label;
360
361                 CodecQualityCols () { add(quality); add(label); }
362         };
363         CodecQualityCols             codec_quality_cols;
364         Glib::RefPtr<Gtk::ListStore> codec_quality_list;
365
366         Gtk::ComboBox   codec_quality_combo;
367
368         /* Tagging */
369
370         Gtk::CheckButton  tag_checkbox;
371
372 };
373
374 #endif /* __export_format_dialog_h__ */