fix issue with initialization of a BBT_Time 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_tagging_selection ();
149
150         /*** Encoding options */
151
152         void change_encoding_options (ARDOUR::ExportFormatPtr ptr);
153
154         void empty_encoding_option_table ();
155         void remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from);
156
157         void show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr);
158         void show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr);
159         void show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr);
160         void show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr);
161
162         void fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr);
163
164         /*** GUI components ***/
165
166         /* Name, new and remove */
167
168         Gtk::HBox  name_hbox;
169
170         Gtk::Label name_label;
171         Gtk::Entry name_entry;
172         Gtk::Label name_generated_part;
173
174         /* Normalize */
175
176         Gtk::HBox        normalize_hbox;
177         Gtk::CheckButton normalize_checkbox;
178         Gtk::RadioButton normalize_peak_rb;
179         Gtk::RadioButton normalize_loudness_rb;
180         Gtk::SpinButton  normalize_dbfs_spinbutton;
181         Gtk::Adjustment  normalize_dbfs_adjustment;
182         Gtk::SpinButton  normalize_lufs_spinbutton;
183         Gtk::Adjustment  normalize_lufs_adjustment;
184         Gtk::SpinButton  normalize_dbtp_spinbutton;
185         Gtk::Adjustment  normalize_dbtp_adjustment;
186         Gtk::Label       normalize_dbfs_label;
187         Gtk::Label       normalize_lufs_label;
188         Gtk::Label       normalize_dbtp_label;
189
190         /* Silence  */
191
192         Gtk::Table       silence_table;
193
194         Gtk::CheckButton trim_start_checkbox;
195         Gtk::CheckButton silence_start_checkbox;
196         AudioClock       silence_start_clock;
197
198         Gtk::CheckButton trim_end_checkbox;
199         Gtk::CheckButton silence_end_checkbox;
200         AudioClock       silence_end_clock;
201
202         /* Post-export hook */
203
204         Gtk::Label       command_label;
205         Gtk::Entry       command_entry;
206
207         /* Format table */
208
209         struct CompatibilityCols : public Gtk::TreeModelColumnRecord
210         {
211         public:
212                 Gtk::TreeModelColumn<ARDOUR::ExportFormatCompatibilityPtr>  ptr;
213                 Gtk::TreeModelColumn<bool>                                  selected;
214                 Gtk::TreeModelColumn<std::string>                           label;
215
216                 CompatibilityCols () { add(ptr); add(selected); add(label); }
217         };
218         CompatibilityCols            compatibility_cols;
219         Glib::RefPtr<Gtk::ListStore> compatibility_list;
220
221         /* Hack to disallow row selection in compatibilities */
222         void prohibit_compatibility_selection ();
223         sigc::connection compatibility_select_connection;
224
225         struct QualityCols : public Gtk::TreeModelColumnRecord
226         {
227         public:
228                 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::QualityPtr>  ptr;
229                 Gtk::TreeModelColumn<std::string>                            color;
230                 Gtk::TreeModelColumn<std::string>                            label;
231
232                 QualityCols () { add(ptr); add(color); add(label); }
233         };
234         QualityCols                  quality_cols;
235         Glib::RefPtr<Gtk::ListStore> quality_list;
236
237         struct FormatCols : public Gtk::TreeModelColumnRecord
238         {
239         public:
240                 Gtk::TreeModelColumn<ARDOUR::ExportFormatPtr>  ptr;
241                 Gtk::TreeModelColumn<std::string>              color;
242                 Gtk::TreeModelColumn<std::string>              label;
243
244                 FormatCols () { add(ptr); add(color); add(label); }
245         };
246         FormatCols                   format_cols;
247         Glib::RefPtr<Gtk::ListStore> format_list;
248
249         struct SampleRateCols : public Gtk::TreeModelColumnRecord
250         {
251         public:
252                 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::SampleRatePtr>  ptr;
253                 Gtk::TreeModelColumn<std::string>                               color;
254                 Gtk::TreeModelColumn<std::string>                               label;
255
256                 SampleRateCols () { add(ptr); add(color); add(label); }
257         };
258         SampleRateCols               sample_rate_cols;
259         Glib::RefPtr<Gtk::ListStore> sample_rate_list;
260
261         Gtk::Table       format_table;
262
263         Gtk::Label       compatibility_label;
264         Gtk::Label       quality_label;
265         Gtk::Label       format_label;
266         Gtk::Label       sample_rate_label;
267
268         Gtk::TreeView    compatibility_view;
269         Gtk::TreeView    quality_view;
270         Gtk::TreeView    format_view;
271         Gtk::TreeView    sample_rate_view;
272
273         /* SRC quality combo */
274
275         struct SRCQualityCols : public Gtk::TreeModelColumnRecord
276         {
277         public:
278                 Gtk::TreeModelColumn<ARDOUR::ExportFormatBase::SRCQuality>  id;
279                 Gtk::TreeModelColumn<std::string>                         label;
280
281                 SRCQualityCols () { add(id); add(label); }
282         };
283         SRCQualityCols               src_quality_cols;
284         Glib::RefPtr<Gtk::ListStore> src_quality_list;
285
286         Gtk::Label      src_quality_label;
287         Gtk::ComboBox   src_quality_combo;
288
289         /* Common encoding option components */
290
291         Gtk::VBox   encoding_options_vbox;
292         Gtk::Label  encoding_options_label;
293
294         Gtk::Table  encoding_options_table;
295
296         /* Other common components */
297
298         Gtk::Button * revert_button;
299         Gtk::Button * close_button;
300
301         /*** Changing encoding option stuff ***/
302
303         /* Linear */
304
305         struct SampleFormatCols : public Gtk::TreeModelColumnRecord
306         {
307         public:
308                 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::SampleFormatPtr>   ptr;
309                 Gtk::TreeModelColumn<std::string>                              color;
310                 Gtk::TreeModelColumn<std::string>                              label;
311
312                 SampleFormatCols () { add(ptr); add(color); add(label); }
313         };
314         SampleFormatCols             sample_format_cols;
315         Glib::RefPtr<Gtk::ListStore> sample_format_list;
316
317         struct DitherTypeCols : public Gtk::TreeModelColumnRecord
318         {
319         public:
320                 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::DitherTypePtr>   ptr;
321                 Gtk::TreeModelColumn<std::string>                            color;
322                 Gtk::TreeModelColumn<std::string>                            label;
323
324                 DitherTypeCols () { add(ptr); add (color); add(label); }
325         };
326         DitherTypeCols               dither_type_cols;
327         Glib::RefPtr<Gtk::ListStore> dither_type_list;
328
329         Gtk::Label  sample_format_label;
330         Gtk::Label  dither_label;
331
332         Gtk::CheckButton with_cue;
333         Gtk::CheckButton with_toc;
334         Gtk::CheckButton with_mp4chaps;
335
336         Gtk::VBox cue_toc_vbox;
337
338         void update_with_toc ();
339         void update_with_cue ();
340         void update_with_mp4chaps();
341         void update_command ();
342
343         Gtk::TreeView sample_format_view;
344         Gtk::TreeView dither_type_view;
345
346         /* Tagging */
347
348         Gtk::CheckButton  tag_checkbox;
349
350 };
351
352 #endif /* __export_format_dialog_h__ */