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