Forward-port ISDCF naming tweak from 1.x.
[dcpomatic.git] / src / wx / dcp_panel.cc
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "dcp_panel.h"
21 #include "wx_util.h"
22 #include "isdcf_metadata_dialog.h"
23 #include "lib/ratio.h"
24 #include "lib/scaler.h"
25 #include "lib/config.h"
26 #include "lib/dcp_content_type.h"
27 #include "lib/util.h"
28 #include "lib/film.h"
29 #include "lib/ffmpeg_content.h"
30 #include <wx/wx.h>
31 #include <wx/notebook.h>
32 #include <wx/gbsizer.h>
33 #include <wx/spinctrl.h>
34 #include <boost/lexical_cast.hpp>
35
36 using std::cout;
37 using std::list;
38 using std::string;
39 using std::vector;
40 using boost::lexical_cast;
41 using boost::shared_ptr;
42
43 DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> f)
44         : _film (f)
45         , _generally_sensitive (true)
46 {
47         _panel = new wxPanel (n);
48         _sizer = new wxBoxSizer (wxVERTICAL);
49         _panel->SetSizer (_sizer);
50
51         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
52         _sizer->Add (grid, 0, wxEXPAND | wxALL, 8);
53
54         int r = 0;
55         
56         add_label_to_grid_bag_sizer (grid, _panel, _("Name"), true, wxGBPosition (r, 0));
57         _name = new wxTextCtrl (_panel, wxID_ANY);
58         grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
59         ++r;
60         
61         int flags = wxALIGN_CENTER_VERTICAL;
62 #ifdef __WXOSX__
63         flags |= wxALIGN_RIGHT;
64 #endif  
65
66         _use_isdcf_name = new wxCheckBox (_panel, wxID_ANY, _("Use ISDCF name"));
67         grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
68         _edit_isdcf_button = new wxButton (_panel, wxID_ANY, _("Details..."));
69         grid->Add (_edit_isdcf_button, wxGBPosition (r, 1));
70         ++r;
71
72         add_label_to_grid_bag_sizer (grid, _panel, _("DCP Name"), true, wxGBPosition (r, 0));
73         _dcp_name = new wxStaticText (_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
74         grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL | wxEXPAND);
75         ++r;
76
77         add_label_to_grid_bag_sizer (grid, _panel, _("Content Type"), true, wxGBPosition (r, 0));
78         _dcp_content_type = new wxChoice (_panel, wxID_ANY);
79         grid->Add (_dcp_content_type, wxGBPosition (r, 1));
80         ++r;
81
82         _notebook = new wxNotebook (_panel, wxID_ANY);
83         _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
84
85         _notebook->AddPage (make_video_panel (), _("Video"), false);
86         _notebook->AddPage (make_audio_panel (), _("Audio"), false);
87         
88         _signed = new wxCheckBox (_panel, wxID_ANY, _("Signed"));
89         grid->Add (_signed, wxGBPosition (r, 0), wxGBSpan (1, 2));
90         ++r;
91         
92         _encrypted = new wxCheckBox (_panel, wxID_ANY, _("Encrypted"));
93         grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
94         ++r;
95
96         add_label_to_grid_bag_sizer (grid, _panel, _("Standard"), true, wxGBPosition (r, 0));
97         _standard = new wxChoice (_panel, wxID_ANY);
98         grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
99         ++r;
100
101         _name->Bind             (wxEVT_COMMAND_TEXT_UPDATED,          boost::bind (&DCPPanel::name_changed, this));
102         _use_isdcf_name->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::use_isdcf_name_toggled, this));
103         _edit_isdcf_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&DCPPanel::edit_isdcf_button_clicked, this));
104         _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::dcp_content_type_changed, this));
105         _signed->Bind           (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::signed_toggled, this));
106         _encrypted->Bind        (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::encrypted_toggled, this));
107         _standard->Bind         (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::standard_changed, this));
108
109         vector<DCPContentType const *> const ct = DCPContentType::all ();
110         for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
111                 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
112         }
113
114         _standard->Append (_("SMPTE"));
115         _standard->Append (_("Interop"));
116
117         Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this));
118 }
119
120 void
121 DCPPanel::name_changed ()
122 {
123         if (!_film) {
124                 return;
125         }
126
127         _film->set_name (string (_name->GetValue().mb_str()));
128 }
129
130 void
131 DCPPanel::j2k_bandwidth_changed ()
132 {
133         if (!_film) {
134                 return;
135         }
136         
137         _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
138 }
139
140 void
141 DCPPanel::signed_toggled ()
142 {
143         if (!_film) {
144                 return;
145         }
146
147         _film->set_signed (_signed->GetValue ());
148 }
149
150 void
151 DCPPanel::burn_subtitles_toggled ()
152 {
153         if (!_film) {
154                 return;
155         }
156
157         _film->set_burn_subtitles (_burn_subtitles->GetValue ());
158 }
159
160 void
161 DCPPanel::encrypted_toggled ()
162 {
163         if (!_film) {
164                 return;
165         }
166
167         _film->set_encrypted (_encrypted->GetValue ());
168 }
169                                
170 /** Called when the frame rate choice widget has been changed */
171 void
172 DCPPanel::frame_rate_choice_changed ()
173 {
174         if (!_film) {
175                 return;
176         }
177
178         _film->set_video_frame_rate (
179                 boost::lexical_cast<int> (
180                         wx_to_std (_frame_rate_choice->GetString (_frame_rate_choice->GetSelection ()))
181                         )
182                 );
183 }
184
185 /** Called when the frame rate spin widget has been changed */
186 void
187 DCPPanel::frame_rate_spin_changed ()
188 {
189         if (!_film) {
190                 return;
191         }
192
193         _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
194 }
195
196 void
197 DCPPanel::audio_channels_changed ()
198 {
199         if (!_film) {
200                 return;
201         }
202
203         _film->set_audio_channels (_audio_channels->GetValue ());
204 }
205
206 void
207 DCPPanel::resolution_changed ()
208 {
209         if (!_film) {
210                 return;
211         }
212
213         _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
214 }
215
216 void
217 DCPPanel::standard_changed ()
218 {
219         if (!_film) {
220                 return;
221         }
222
223         _film->set_interop (_standard->GetSelection() == 1);
224 }
225
226 void
227 DCPPanel::film_changed (int p)
228 {
229         switch (p) {
230         case Film::NONE:
231                 break;
232         case Film::CONTAINER:
233                 setup_container ();
234                 break;
235         case Film::NAME:
236                 checked_set (_name, _film->name());
237                 setup_dcp_name ();
238                 break;
239         case Film::DCP_CONTENT_TYPE:
240                 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
241                 setup_dcp_name ();
242                 break;
243         case Film::SCALER:
244                 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
245                 break;
246         case Film::BURN_SUBTITLES:
247                 checked_set (_burn_subtitles, _film->burn_subtitles ());
248                 break;
249         case Film::SIGNED:
250                 checked_set (_signed, _film->is_signed ());
251                 break;
252         case Film::ENCRYPTED:
253                 checked_set (_encrypted, _film->encrypted ());
254                 if (_film->encrypted ()) {
255                         _film->set_signed (true);
256                         _signed->Enable (false);
257                 } else {
258                         _signed->Enable (_generally_sensitive);
259                 }
260                 break;
261         case Film::RESOLUTION:
262                 checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
263                 setup_dcp_name ();
264                 break;
265         case Film::J2K_BANDWIDTH:
266                 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
267                 break;
268         case Film::USE_ISDCF_NAME:
269         {
270                 checked_set (_use_isdcf_name, _film->use_isdcf_name ());
271                 setup_dcp_name ();
272                 bool const i = _film->use_isdcf_name ();
273                 if (i) {
274                         /* We just chose to use the ISDCF name.  The user has probably unticked and re-ticked the box,
275                            so it's fairly likey that the film's name will now be a full ISDCF one.  Based on this guess,
276                            remove anything after the first _ in the film's name here.
277                         */
278                         string const n = _film->name ();
279                         if (n.find ("_") != string::npos) {
280                                 _film->set_name (n.substr (0, n.find ("_")));
281                         }
282                 } else {
283                         /* Otherwise set the name to the full ISDCF name */
284                         _film->set_name (_film->isdcf_name (true));
285                 }
286                 _edit_isdcf_button->Enable (i);
287                 break;
288         }
289         case Film::ISDCF_METADATA:
290                 setup_dcp_name ();
291                 break;
292         case Film::VIDEO_FRAME_RATE:
293         {
294                 bool done = false;
295                 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
296                         if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
297                                 checked_set (_frame_rate_choice, i);
298                                 done = true;
299                                 break;
300                         }
301                 }
302
303                 if (!done) {
304                         checked_set (_frame_rate_choice, -1);
305                 }
306
307                 _frame_rate_spin->SetValue (_film->video_frame_rate ());
308
309                 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
310                 break;
311         }
312         case Film::AUDIO_CHANNELS:
313                 checked_set (_audio_channels, _film->audio_channels ());
314                 setup_dcp_name ();
315                 break;
316         case Film::THREE_D:
317                 checked_set (_three_d, _film->three_d ());
318                 setup_dcp_name ();
319                 break;
320         case Film::INTEROP:
321                 checked_set (_standard, _film->interop() ? 1 : 0);
322                 break;
323         default:
324                 break;
325         }
326 }
327
328 void
329 DCPPanel::film_content_changed (int property)
330 {
331         if (property == FFmpegContentProperty::AUDIO_STREAM ||
332             property == SubtitleContentProperty::USE_SUBTITLES ||
333             property == VideoContentProperty::VIDEO_SCALE) {
334                 setup_dcp_name ();
335         }
336 }
337
338
339 void
340 DCPPanel::setup_container ()
341 {
342         int n = 0;
343         vector<Ratio const *> ratios = Ratio::all ();
344         vector<Ratio const *>::iterator i = ratios.begin ();
345         while (i != ratios.end() && *i != _film->container ()) {
346                 ++i;
347                 ++n;
348         }
349         
350         if (i == ratios.end()) {
351                 checked_set (_container, -1);
352         } else {
353                 checked_set (_container, n);
354         }
355         
356         setup_dcp_name ();
357 }       
358
359 /** Called when the container widget has been changed */
360 void
361 DCPPanel::container_changed ()
362 {
363         if (!_film) {
364                 return;
365         }
366
367         int const n = _container->GetSelection ();
368         if (n >= 0) {
369                 vector<Ratio const *> ratios = Ratio::all ();
370                 assert (n < int (ratios.size()));
371                 _film->set_container (ratios[n]);
372         }
373 }
374
375 /** Called when the DCP content type widget has been changed */
376 void
377 DCPPanel::dcp_content_type_changed ()
378 {
379         if (!_film) {
380                 return;
381         }
382
383         int const n = _dcp_content_type->GetSelection ();
384         if (n != wxNOT_FOUND) {
385                 _film->set_dcp_content_type (DCPContentType::from_index (n));
386         }
387 }
388
389 void
390 DCPPanel::set_film (shared_ptr<Film> film)
391 {
392         _film = film;
393         
394         film_changed (Film::NAME);
395         film_changed (Film::USE_ISDCF_NAME);
396         film_changed (Film::CONTENT);
397         film_changed (Film::DCP_CONTENT_TYPE);
398         film_changed (Film::CONTAINER);
399         film_changed (Film::RESOLUTION);
400         film_changed (Film::SCALER);
401         film_changed (Film::SIGNED);
402         film_changed (Film::BURN_SUBTITLES);
403         film_changed (Film::ENCRYPTED);
404         film_changed (Film::J2K_BANDWIDTH);
405         film_changed (Film::ISDCF_METADATA);
406         film_changed (Film::VIDEO_FRAME_RATE);
407         film_changed (Film::AUDIO_CHANNELS);
408         film_changed (Film::SEQUENCE_VIDEO);
409         film_changed (Film::THREE_D);
410         film_changed (Film::INTEROP);
411 }
412
413 void
414 DCPPanel::set_general_sensitivity (bool s)
415 {
416         _name->Enable (s);
417         _use_isdcf_name->Enable (s);
418         _edit_isdcf_button->Enable (s);
419         _dcp_content_type->Enable (s);
420
421         bool si = s;
422         if (_film && _film->encrypted ()) {
423                 si = false;
424         }
425         _burn_subtitles->Enable (s);
426         _signed->Enable (si);
427         
428         _encrypted->Enable (s);
429         _frame_rate_choice->Enable (s);
430         _frame_rate_spin->Enable (s);
431         _audio_channels->Enable (s);
432         _j2k_bandwidth->Enable (s);
433         _container->Enable (s);
434         _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
435         _resolution->Enable (s);
436         _scaler->Enable (s);
437         _three_d->Enable (s);
438         _standard->Enable (s);
439 }
440
441 /** Called when the scaler widget has been changed */
442 void
443 DCPPanel::scaler_changed ()
444 {
445         if (!_film) {
446                 return;
447         }
448
449         int const n = _scaler->GetSelection ();
450         if (n >= 0) {
451                 _film->set_scaler (Scaler::from_index (n));
452         }
453 }
454
455 void
456 DCPPanel::use_isdcf_name_toggled ()
457 {
458         if (!_film) {
459                 return;
460         }
461
462         _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
463 }
464
465 void
466 DCPPanel::edit_isdcf_button_clicked ()
467 {
468         if (!_film) {
469                 return;
470         }
471
472         ISDCFMetadataDialog* d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata ());
473         d->ShowModal ();
474         _film->set_isdcf_metadata (d->isdcf_metadata ());
475         d->Destroy ();
476 }
477
478 void
479 DCPPanel::setup_dcp_name ()
480 {
481         string s = _film->dcp_name (true);
482         if (s.length() > 28) {
483                 _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
484                 _dcp_name->SetToolTip (std_to_wx (s));
485         } else {
486                 _dcp_name->SetLabel (std_to_wx (s));
487         }
488 }
489
490 void
491 DCPPanel::best_frame_rate_clicked ()
492 {
493         if (!_film) {
494                 return;
495         }
496         
497         _film->set_video_frame_rate (_film->best_video_frame_rate ());
498 }
499
500 void
501 DCPPanel::three_d_changed ()
502 {
503         if (!_film) {
504                 return;
505         }
506
507         _film->set_three_d (_three_d->GetValue ());
508 }
509
510 void
511 DCPPanel::config_changed ()
512 {
513         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
514         setup_frame_rate_widget ();
515 }
516
517 void
518 DCPPanel::setup_frame_rate_widget ()
519 {
520         if (Config::instance()->allow_any_dcp_frame_rate ()) {
521                 _frame_rate_choice->Hide ();
522                 _frame_rate_spin->Show ();
523         } else {
524                 _frame_rate_choice->Show ();
525                 _frame_rate_spin->Hide ();
526         }
527
528         _frame_rate_sizer->Layout ();
529 }
530
531 wxPanel *
532 DCPPanel::make_video_panel ()
533 {
534         wxPanel* panel = new wxPanel (_notebook);
535         wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
536         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
537         sizer->Add (grid, 0, wxALL, 8);
538         panel->SetSizer (sizer);
539
540         int r = 0;
541         
542         add_label_to_grid_bag_sizer (grid, panel, _("Container"), true, wxGBPosition (r, 0));
543         _container = new wxChoice (panel, wxID_ANY);
544         grid->Add (_container, wxGBPosition (r, 1));
545         ++r;
546
547         {
548                 add_label_to_grid_bag_sizer (grid, panel, _("Frame Rate"), true, wxGBPosition (r, 0));
549                 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
550                 _frame_rate_choice = new wxChoice (panel, wxID_ANY);
551                 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
552                 _frame_rate_spin = new wxSpinCtrl (panel, wxID_ANY);
553                 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
554                 setup_frame_rate_widget ();
555                 _best_frame_rate = new wxButton (panel, wxID_ANY, _("Use best"));
556                 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
557                 grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
558         }
559         ++r;
560
561         _burn_subtitles = new wxCheckBox (panel, wxID_ANY, _("Burn subtitles into image"));
562         grid->Add (_burn_subtitles, wxGBPosition (r, 0), wxGBSpan (1, 2));
563         ++r;
564
565         _three_d = new wxCheckBox (panel, wxID_ANY, _("3D"));
566         grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
567         ++r;
568
569         add_label_to_grid_bag_sizer (grid, panel, _("Resolution"), true, wxGBPosition (r, 0));
570         _resolution = new wxChoice (panel, wxID_ANY);
571         grid->Add (_resolution, wxGBPosition (r, 1));
572         ++r;
573
574         {
575                 add_label_to_grid_bag_sizer (grid, panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
576                 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
577                 _j2k_bandwidth = new wxSpinCtrl (panel, wxID_ANY);
578                 s->Add (_j2k_bandwidth, 1);
579                 add_label_to_sizer (s, panel, _("Mbit/s"), false);
580                 grid->Add (s, wxGBPosition (r, 1));
581         }
582         ++r;
583
584         add_label_to_grid_bag_sizer (grid, panel, _("Scaler"), true, wxGBPosition (r, 0));
585         _scaler = new wxChoice (panel, wxID_ANY);
586         grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
587         ++r;
588
589         _container->Bind        (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::container_changed, this));
590         _scaler->Bind           (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::scaler_changed, this));
591         _frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::frame_rate_choice_changed, this));
592         _frame_rate_spin->Bind  (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::frame_rate_spin_changed, this));
593         _best_frame_rate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&DCPPanel::best_frame_rate_clicked, this));
594         _burn_subtitles->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::burn_subtitles_toggled, this));
595         _j2k_bandwidth->Bind    (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
596         _resolution->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::resolution_changed, this));
597         _three_d->Bind          (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::three_d_changed, this));
598
599         vector<Scaler const *> const sc = Scaler::all ();
600         for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
601                 _scaler->Append (std_to_wx ((*i)->name()));
602         }
603
604         vector<Ratio const *> const ratio = Ratio::all ();
605         for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
606                 _container->Append (std_to_wx ((*i)->nickname ()));
607         }
608
609         list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
610         for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
611                 _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (*i)));
612         }
613
614         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
615         _frame_rate_spin->SetRange (1, 480);
616
617         _resolution->Append (_("2K"));
618         _resolution->Append (_("4K"));
619
620         return panel;
621 }
622
623 wxPanel *
624 DCPPanel::make_audio_panel ()
625 {
626         wxPanel* panel = new wxPanel (_notebook);
627         wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
628         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
629         sizer->Add (grid, 0, wxALL, 8);
630         panel->SetSizer (sizer);
631
632         int r = 0;
633         add_label_to_grid_bag_sizer (grid, panel, _("Channels"), true, wxGBPosition (r, 0));
634         _audio_channels = new wxSpinCtrl (panel, wxID_ANY);
635         grid->Add (_audio_channels, wxGBPosition (r, 1));
636         ++r;
637
638         _audio_channels->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DCPPanel::audio_channels_changed, this));
639
640         _audio_channels->SetRange (0, MAX_DCP_AUDIO_CHANNELS);
641
642         return panel;
643 }