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