2 Copyright (C) 2008 Paul Davis
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.
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.
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.
21 #ifndef __export_format_dialog_h__
22 #define __export_format_dialog_h__
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"
29 #include "pbd/xml++.h"
30 #include "pbd/signals.h"
32 #include "ardour_dialog.h"
33 #include "audio_clock.h"
41 class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList {
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;
51 typedef boost::shared_ptr<ARDOUR::ExportFormatSpecification> FormatPtr;
56 explicit ExportFormatDialog (FormatPtr format, bool new_dialog = false);
57 ~ExportFormatDialog ();
59 void set_session (ARDOUR::Session* s);
64 ARDOUR::ExportFormatManager manager;
66 XMLNode & original_state;
68 ARDOUR::AnyTime silence_start;
69 ARDOUR::AnyTime silence_end;
74 /*** Init functions ***/
76 void load_state (FormatPtr spec);
77 void init_format_table ();
78 void init_encoding_option_widgets ();
80 /*** Interactive selections ***/
82 /* These are connected to signals from GUI components, and should change element states */
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 ();
91 template<typename ColsT>
92 void update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
94 /* These are connected to signals from elements, and should only update the gui */
96 void change_compatibility_selection (bool select, WeakCompatPtr compat);
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);
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);
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);
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");
117 void update_description();
119 uint32_t applying_changes_from_engine;
121 /*** Non-interactive selections ***/
125 void update_trim_start_selection ();
126 void update_trim_end_selection ();
128 void update_normalize_selection ();
129 void update_silence_start_selection ();
130 void update_silence_end_selection ();
132 void update_clock (AudioClock & clock, ARDOUR::AnyTime const & time);
133 void update_time (ARDOUR::AnyTime & time, AudioClock const & clock);
135 void update_src_quality_selection ();
136 void update_tagging_selection ();
138 /*** Encoding options */
140 void change_encoding_options (ARDOUR::ExportFormatPtr ptr);
142 void empty_encoding_option_table ();
143 void remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from);
145 void show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr);
146 void show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr);
147 void show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr);
148 void show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr);
150 void fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr);
152 /*** GUI components ***/
154 /* Name, new and remove */
158 Gtk::Label name_label;
159 Gtk::Entry name_entry;
160 Gtk::Label name_generated_part;
164 Gtk::HBox normalize_hbox;
165 Gtk::CheckButton normalize_checkbox;
166 Gtk::SpinButton normalize_spinbutton;
167 Gtk::Adjustment normalize_adjustment;
168 Gtk::Label normalize_db_label;
172 Gtk::Table silence_table;
174 Gtk::CheckButton trim_start_checkbox;
175 Gtk::CheckButton silence_start_checkbox;
176 AudioClock silence_start_clock;
178 Gtk::CheckButton trim_end_checkbox;
179 Gtk::CheckButton silence_end_checkbox;
180 AudioClock silence_end_clock;
184 struct CompatibilityCols : public Gtk::TreeModelColumnRecord
187 Gtk::TreeModelColumn<ARDOUR::ExportFormatCompatibilityPtr> ptr;
188 Gtk::TreeModelColumn<bool> selected;
189 Gtk::TreeModelColumn<std::string> label;
191 CompatibilityCols () { add(ptr); add(selected); add(label); }
193 CompatibilityCols compatibility_cols;
194 Glib::RefPtr<Gtk::ListStore> compatibility_list;
196 /* Hack to disallow row selection in compatibilities */
197 void prohibit_compatibility_selection ();
198 sigc::connection compatibility_select_connection;
200 struct QualityCols : public Gtk::TreeModelColumnRecord
203 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::QualityPtr> ptr;
204 Gtk::TreeModelColumn<std::string> color;
205 Gtk::TreeModelColumn<std::string> label;
207 QualityCols () { add(ptr); add(color); add(label); }
209 QualityCols quality_cols;
210 Glib::RefPtr<Gtk::ListStore> quality_list;
212 struct FormatCols : public Gtk::TreeModelColumnRecord
215 Gtk::TreeModelColumn<ARDOUR::ExportFormatPtr> ptr;
216 Gtk::TreeModelColumn<std::string> color;
217 Gtk::TreeModelColumn<std::string> label;
219 FormatCols () { add(ptr); add(color); add(label); }
221 FormatCols format_cols;
222 Glib::RefPtr<Gtk::ListStore> format_list;
224 struct SampleRateCols : public Gtk::TreeModelColumnRecord
227 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::SampleRatePtr> ptr;
228 Gtk::TreeModelColumn<std::string> color;
229 Gtk::TreeModelColumn<std::string> label;
231 SampleRateCols () { add(ptr); add(color); add(label); }
233 SampleRateCols sample_rate_cols;
234 Glib::RefPtr<Gtk::ListStore> sample_rate_list;
236 Gtk::Table format_table;
238 Gtk::Label compatibility_label;
239 Gtk::Label quality_label;
240 Gtk::Label format_label;
241 Gtk::Label sample_rate_label;
243 Gtk::TreeView compatibility_view;
244 Gtk::TreeView quality_view;
245 Gtk::TreeView format_view;
246 Gtk::TreeView sample_rate_view;
248 /* SRC quality combo */
250 struct SRCQualityCols : public Gtk::TreeModelColumnRecord
253 Gtk::TreeModelColumn<ARDOUR::ExportFormatBase::SRCQuality> id;
254 Gtk::TreeModelColumn<std::string> label;
256 SRCQualityCols () { add(id); add(label); }
258 SRCQualityCols src_quality_cols;
259 Glib::RefPtr<Gtk::ListStore> src_quality_list;
261 Gtk::Label src_quality_label;
262 Gtk::ComboBox src_quality_combo;
264 /* Common encoding option components */
266 Gtk::VBox encoding_options_vbox;
267 Gtk::Label encoding_options_label;
269 Gtk::Table encoding_options_table;
271 /* Other common components */
273 Gtk::Button * revert_button;
274 Gtk::Button * close_button;
276 /*** Changing encoding option stuff ***/
280 struct SampleFormatCols : public Gtk::TreeModelColumnRecord
283 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::SampleFormatPtr> ptr;
284 Gtk::TreeModelColumn<std::string> color;
285 Gtk::TreeModelColumn<std::string> label;
287 SampleFormatCols () { add(ptr); add(color); add(label); }
289 SampleFormatCols sample_format_cols;
290 Glib::RefPtr<Gtk::ListStore> sample_format_list;
292 struct DitherTypeCols : public Gtk::TreeModelColumnRecord
295 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::DitherTypePtr> ptr;
296 Gtk::TreeModelColumn<std::string> color;
297 Gtk::TreeModelColumn<std::string> label;
299 DitherTypeCols () { add(ptr); add (color); add(label); }
301 DitherTypeCols dither_type_cols;
302 Glib::RefPtr<Gtk::ListStore> dither_type_list;
304 Gtk::Label sample_format_label;
305 Gtk::Label dither_label;
307 Gtk::CheckButton with_cue;
308 Gtk::CheckButton with_toc;
310 Gtk::VBox cue_toc_vbox;
312 void update_with_toc ();
313 void update_with_cue ();
315 Gtk::TreeView sample_format_view;
316 Gtk::TreeView dither_type_view;
320 Gtk::CheckButton tag_checkbox;
324 #endif /* __export_format_dialog_h__ */