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