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