Remove erroneous assert which I added earlier.
[ardour2.git] / gtk2_ardour / export_format_dialog.h
blob0371b775440a807b87557b219fa835e68961ce64
1 /*
2 Copyright (C) 2008 Paul Davis
3 Author: Sakari Bergen
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"
35 #include <gtkmm.h>
37 class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList {
38 private:
40 typedef ARDOUR::WeakExportFormatCompatibilityPtr WeakCompatPtr;
41 typedef ARDOUR::WeakExportFormatPtr WeakFormatPtr;
42 typedef ARDOUR::ExportFormatManager::WeakQualityPtr WeakQualityPtr;
43 typedef ARDOUR::ExportFormatManager::WeakSampleRatePtr WeakSampleRatePtr;
44 typedef ARDOUR::ExportFormatManager::WeakSampleFormatPtr WeakSampleFormatPtr;
45 typedef ARDOUR::ExportFormatManager::WeakDitherTypePtr WeakDitherTypePtr;
47 typedef boost::shared_ptr<ARDOUR::ExportFormatSpecification> FormatPtr;
50 public:
52 explicit ExportFormatDialog (FormatPtr format, bool new_dialog = false);
53 ~ExportFormatDialog ();
55 void set_session (ARDOUR::Session* s);
57 private:
59 FormatPtr format;
60 ARDOUR::ExportFormatManager manager;
62 XMLNode & original_state;
64 ARDOUR::AnyTime silence_start;
65 ARDOUR::AnyTime silence_end;
67 void end_dialog ();
68 void revert ();
70 /*** Init functions ***/
72 void load_state (FormatPtr spec);
73 void init_format_table ();
74 void init_encoding_option_widgets ();
76 /*** Interactive selections ***/
78 /* These are connected to signals from GUI components, and should change element states */
80 void update_compatibility_selection (std::string const & path);
81 void update_quality_selection ();
82 void update_format_selection ();
83 void update_sample_rate_selection ();
84 void update_sample_format_selection ();
85 void update_dither_type_selection ();
87 template<typename ColsT>
88 void update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
90 /* These are connected to signals from elements, and should only update the gui */
92 void change_compatibility_selection (bool select, WeakCompatPtr compat);
94 void change_quality_selection (bool select, WeakQualityPtr quality);
95 void change_format_selection (bool select, WeakFormatPtr format);
96 void change_sample_rate_selection (bool select, WeakSampleRatePtr rate);
97 void change_sample_format_selection (bool select, WeakSampleFormatPtr format);
98 void change_dither_type_selection (bool select, WeakDitherTypePtr type);
100 template<typename T, typename ColsT>
101 void change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
103 void change_quality_compatibility (bool compatibility, WeakQualityPtr quality);
104 void change_format_compatibility (bool compatibility, WeakFormatPtr format);
105 void change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate);
106 void change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format);
107 void change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type);
109 template<typename T, typename ColsT>
110 void change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
111 std::string const & c_incompatible = "red", std::string const & c_compatible = "white");
113 uint32_t applying_changes_from_engine;
115 /*** Non-interactive selections ***/
117 void update_name ();
119 void update_trim_start_selection ();
120 void update_trim_end_selection ();
122 void update_normalize_selection ();
123 void update_silence_start_selection ();
124 void update_silence_end_selection ();
126 void update_clock (AudioClock & clock, ARDOUR::AnyTime const & time);
127 void update_time (ARDOUR::AnyTime & time, AudioClock const & clock);
129 void update_src_quality_selection ();
130 void update_tagging_selection ();
132 /*** Encoding options */
134 void change_encoding_options (ARDOUR::ExportFormatPtr ptr);
136 void empty_encoding_option_table ();
137 void remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from);
139 void show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr);
140 void show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr);
141 void show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr);
142 void show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr);
144 void fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr);
146 /*** GUI components ***/
148 /* Name, new and remove */
150 Gtk::HBox name_hbox;
152 Gtk::Label name_label;
153 Gtk::Entry name_entry;
155 /* Normalize */
157 Gtk::HBox normalize_hbox;
158 Gtk::CheckButton normalize_checkbox;
159 Gtk::SpinButton normalize_spinbutton;
160 Gtk::Adjustment normalize_adjustment;
161 Gtk::Label normalize_db_label;
163 /* Silence */
165 Gtk::Table silence_table;
167 Gtk::CheckButton trim_start_checkbox;
168 Gtk::CheckButton silence_start_checkbox;
169 AudioClock silence_start_clock;
171 Gtk::CheckButton trim_end_checkbox;
172 Gtk::CheckButton silence_end_checkbox;
173 AudioClock silence_end_clock;
175 /* Format table */
177 struct CompatibilityCols : public Gtk::TreeModelColumnRecord
179 public:
180 Gtk::TreeModelColumn<ARDOUR::ExportFormatCompatibilityPtr> ptr;
181 Gtk::TreeModelColumn<bool> selected;
182 Gtk::TreeModelColumn<std::string> label;
184 CompatibilityCols () { add(ptr); add(selected); add(label); }
186 CompatibilityCols compatibility_cols;
187 Glib::RefPtr<Gtk::ListStore> compatibility_list;
189 /* Hack to disallow row selection in compatibilities */
190 void prohibit_compatibility_selection ();
191 sigc::connection compatibility_select_connection;
193 struct QualityCols : public Gtk::TreeModelColumnRecord
195 public:
196 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::QualityPtr> ptr;
197 Gtk::TreeModelColumn<std::string> color;
198 Gtk::TreeModelColumn<std::string> label;
200 QualityCols () { add(ptr); add(color); add(label); }
202 QualityCols quality_cols;
203 Glib::RefPtr<Gtk::ListStore> quality_list;
205 struct FormatCols : public Gtk::TreeModelColumnRecord
207 public:
208 Gtk::TreeModelColumn<ARDOUR::ExportFormatPtr> ptr;
209 Gtk::TreeModelColumn<std::string> color;
210 Gtk::TreeModelColumn<std::string> label;
212 FormatCols () { add(ptr); add(color); add(label); }
214 FormatCols format_cols;
215 Glib::RefPtr<Gtk::ListStore> format_list;
217 struct SampleRateCols : public Gtk::TreeModelColumnRecord
219 public:
220 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::SampleRatePtr> ptr;
221 Gtk::TreeModelColumn<std::string> color;
222 Gtk::TreeModelColumn<std::string> label;
224 SampleRateCols () { add(ptr); add(color); add(label); }
226 SampleRateCols sample_rate_cols;
227 Glib::RefPtr<Gtk::ListStore> sample_rate_list;
229 Gtk::Table format_table;
231 Gtk::Label compatibility_label;
232 Gtk::Label quality_label;
233 Gtk::Label format_label;
234 Gtk::Label sample_rate_label;
236 Gtk::TreeView compatibility_view;
237 Gtk::TreeView quality_view;
238 Gtk::TreeView format_view;
239 Gtk::TreeView sample_rate_view;
241 /* SRC quality combo */
243 struct SRCQualityCols : public Gtk::TreeModelColumnRecord
245 public:
246 Gtk::TreeModelColumn<ARDOUR::ExportFormatBase::SRCQuality> id;
247 Gtk::TreeModelColumn<std::string> label;
249 SRCQualityCols () { add(id); add(label); }
251 SRCQualityCols src_quality_cols;
252 Glib::RefPtr<Gtk::ListStore> src_quality_list;
254 Gtk::Label src_quality_label;
255 Gtk::ComboBox src_quality_combo;
257 /* Common encoding option components */
259 Gtk::VBox encoding_options_vbox;
260 Gtk::Label encoding_options_label;
262 Gtk::Table encoding_options_table;
264 /* Other common components */
266 Gtk::Button * revert_button;
267 Gtk::Button * close_button;
269 /*** Changing encoding option stuff ***/
271 /* Linear */
273 struct SampleFormatCols : public Gtk::TreeModelColumnRecord
275 public:
276 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::SampleFormatPtr> ptr;
277 Gtk::TreeModelColumn<std::string> color;
278 Gtk::TreeModelColumn<std::string> label;
280 SampleFormatCols () { add(ptr); add(color); add(label); }
282 SampleFormatCols sample_format_cols;
283 Glib::RefPtr<Gtk::ListStore> sample_format_list;
285 struct DitherTypeCols : public Gtk::TreeModelColumnRecord
287 public:
288 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::DitherTypePtr> ptr;
289 Gtk::TreeModelColumn<std::string> color;
290 Gtk::TreeModelColumn<std::string> label;
292 DitherTypeCols () { add(ptr); add (color); add(label); }
294 DitherTypeCols dither_type_cols;
295 Glib::RefPtr<Gtk::ListStore> dither_type_list;
297 Gtk::Label sample_format_label;
298 Gtk::Label dither_label;
300 Gtk::TreeView sample_format_view;
301 Gtk::TreeView dither_type_view;
303 /* Tagging */
305 Gtk::CheckButton tag_checkbox;
309 #endif /* __export_format_dialog_h__ */