2 Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "dcp_panel.h"
23 #include "key_dialog.h"
24 #include "isdcf_metadata_dialog.h"
25 #include "audio_dialog.h"
26 #include "focus_manager.h"
27 #include "check_box.h"
28 #include "static_text.h"
29 #include "check_box.h"
30 #include "dcpomatic_button.h"
31 #include "markers_dialog.h"
32 #include "metadata_dialog.h"
33 #include "lib/ratio.h"
34 #include "lib/config.h"
35 #include "lib/dcp_content_type.h"
38 #include "lib/ffmpeg_content.h"
39 #include "lib/audio_processor.h"
40 #include "lib/video_content.h"
41 #include "lib/text_content.h"
42 #include "lib/dcp_content.h"
43 #include "lib/audio_content.h"
44 #include <dcp/locale_convert.h>
47 #include <wx/notebook.h>
48 #include <wx/gbsizer.h>
49 #include <wx/spinctrl.h>
50 #include <boost/lexical_cast.hpp>
51 #include <boost/foreach.hpp>
61 using boost::lexical_cast;
62 using boost::shared_ptr;
63 using boost::weak_ptr;
64 using dcp::locale_convert;
66 DCPPanel::DCPPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer)
69 , _metadata_dialog (0)
72 , _generally_sensitive (true)
74 _panel = new wxPanel (n);
75 _sizer = new wxBoxSizer (wxVERTICAL);
76 _panel->SetSizer (_sizer);
78 _grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
79 _sizer->Add (_grid, 0, wxEXPAND | wxALL, 8);
81 _name_label = create_label (_panel, _("Name"), true);
82 _name = new wxTextCtrl (_panel, wxID_ANY);
83 FocusManager::instance()->add(_name);
85 _use_isdcf_name = new CheckBox (_panel, _("Use ISDCF name"));
86 _edit_isdcf_button = new Button (_panel, _("Details..."));
87 _copy_isdcf_name_button = new Button (_panel, _("Copy as name"));
89 /* wxST_ELLIPSIZE_MIDDLE works around a bug in GTK2 and/or wxWidgets, see
90 http://trac.wxwidgets.org/ticket/12539
92 _dcp_name = new StaticText (
93 _panel, wxT (""), wxDefaultPosition, wxDefaultSize,
94 wxALIGN_CENTRE_HORIZONTAL | wxST_NO_AUTORESIZE | wxST_ELLIPSIZE_MIDDLE
97 _dcp_content_type_label = create_label (_panel, _("Content Type"), true);
98 _dcp_content_type = new wxChoice (_panel, wxID_ANY);
100 _signed = new CheckBox (_panel, _("Signed"));
101 _encrypted = new CheckBox (_panel, _("Encrypted"));
103 wxClientDC dc (_panel);
104 wxSize size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
107 _key_label = create_label (_panel, _("Key"), true);
108 _key = new StaticText (_panel, "", wxDefaultPosition, size);
109 _edit_key = new Button (_panel, _("Edit..."));
111 _reels_label = create_label (_panel, _("Reels"), true);
112 _reel_type = new wxChoice (_panel, wxID_ANY);
114 _reel_length_label = create_label (_panel, _("Reel length"), true);
115 _reel_length = new wxSpinCtrl (_panel, wxID_ANY);
116 _reel_length_gb_label = create_label (_panel, _("GB"), false);
118 _standard_label = create_label (_panel, _("Standard"), true);
119 _standard = new wxChoice (_panel, wxID_ANY);
121 _upload_after_make_dcp = new CheckBox (_panel, _("Upload DCP to TMS after it is made"));
123 _markers = new Button (_panel, _("Markers..."));
124 _metadata = new Button (_panel, _("Metadata..."));
126 _notebook = new wxNotebook (_panel, wxID_ANY);
127 _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
129 _notebook->AddPage (make_video_panel (), _("Video"), false);
130 _notebook->AddPage (make_audio_panel (), _("Audio"), false);
132 _name->Bind (wxEVT_TEXT, boost::bind (&DCPPanel::name_changed, this));
133 _use_isdcf_name->Bind (wxEVT_CHECKBOX, boost::bind (&DCPPanel::use_isdcf_name_toggled, this));
134 _edit_isdcf_button->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::edit_isdcf_button_clicked, this));
135 _copy_isdcf_name_button->Bind(wxEVT_BUTTON, boost::bind (&DCPPanel::copy_isdcf_name_button_clicked, this));
136 _dcp_content_type->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::dcp_content_type_changed, this));
137 _signed->Bind (wxEVT_CHECKBOX, boost::bind (&DCPPanel::signed_toggled, this));
138 _encrypted->Bind (wxEVT_CHECKBOX, boost::bind (&DCPPanel::encrypted_toggled, this));
139 _edit_key->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::edit_key_clicked, this));
140 _reel_type->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::reel_type_changed, this));
141 _reel_length->Bind (wxEVT_SPINCTRL, boost::bind (&DCPPanel::reel_length_changed, this));
142 _standard->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::standard_changed, this));
143 _upload_after_make_dcp->Bind (wxEVT_CHECKBOX, boost::bind (&DCPPanel::upload_after_make_dcp_changed, this));
144 _markers->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::markers_clicked, this));
145 _metadata->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::metadata_clicked, this));
147 BOOST_FOREACH (DCPContentType const * i, DCPContentType::all()) {
148 _dcp_content_type->Append (std_to_wx (i->pretty_name ()));
151 _reel_type->Append (_("Single reel"));
152 _reel_type->Append (_("Split by video content"));
153 /// TRANSLATORS: translate the word "Custom" here; do not include the "Reel|" prefix
154 _reel_type->Append (S_("Reel|Custom"));
156 _reel_length->SetRange (1, 64);
158 _standard->Append (_("SMPTE"));
159 _standard->Append (_("Interop"));
161 Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this, _1));
167 DCPPanel::add_to_grid ()
169 Config::Interface interface = Config::instance()->interface_complexity ();
173 add_label_to_sizer (_grid, _name_label, true, wxGBPosition (r, 0));
174 _grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
177 int flags = wxALIGN_CENTER_VERTICAL;
179 flags |= wxALIGN_RIGHT;
182 bool const full = interface == Config::INTERFACE_FULL;
184 _use_isdcf_name->Show (full);
185 _edit_isdcf_button->Show (full);
186 _copy_isdcf_name_button->Show (full);
189 _grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
191 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
192 s->Add (_edit_isdcf_button, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
193 s->Add (_copy_isdcf_name_button, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_X_GAP);
194 _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
199 _grid->Add (_dcp_name, wxGBPosition(r, 0), wxGBSpan (1, 2), wxALIGN_CENTER_VERTICAL | wxEXPAND);
202 add_label_to_sizer (_grid, _dcp_content_type_label, true, wxGBPosition (r, 0));
203 _grid->Add (_dcp_content_type, wxGBPosition (r, 1));
206 _signed->Show (full);
208 _grid->Add (_signed, wxGBPosition (r, 0), wxGBSpan (1, 2));
212 _grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
216 _key_label->Show (full);
218 _edit_key->Show (full);
219 _reels_label->Show (full);
220 _reel_type->Show (full);
221 _reel_length_label->Show (full);
222 _reel_length->Show (full);
223 _reel_length_gb_label->Show (full);
224 _standard_label->Show (full);
225 _standard->Show (full);
226 _upload_after_make_dcp->Show (full);
227 _markers->Show (full);
228 _metadata->Show (full);
229 _reencode_j2k->Show (full);
230 _encrypted->Show (full);
233 add_label_to_sizer (_grid, _key_label, true, wxGBPosition (r, 0));
235 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
236 s->Add (_key, 1, wxALIGN_CENTER_VERTICAL);
238 _grid->Add (s, wxGBPosition (r, 1));
242 add_label_to_sizer (_grid, _reels_label, true, wxGBPosition (r, 0));
243 _grid->Add (_reel_type, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
246 add_label_to_sizer (_grid, _reel_length_label, true, wxGBPosition (r, 0));
248 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
249 s->Add (_reel_length);
250 add_label_to_sizer (s, _reel_length_gb_label, false);
251 _grid->Add (s, wxGBPosition (r, 1));
255 add_label_to_sizer (_grid, _standard_label, true, wxGBPosition (r, 0));
256 _grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
259 _grid->Add (_upload_after_make_dcp, wxGBPosition (r, 0), wxGBSpan (1, 2));
262 wxBoxSizer* extra = new wxBoxSizer (wxHORIZONTAL);
263 extra->Add (_markers, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
264 extra->Add (_metadata, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
265 _grid->Add (extra, wxGBPosition(r, 0), wxGBSpan(1, 2));
271 DCPPanel::edit_key_clicked ()
273 KeyDialog* d = new KeyDialog (_panel, _film->key ());
274 if (d->ShowModal () == wxID_OK) {
275 _film->set_key (d->key ());
281 DCPPanel::name_changed ()
287 _film->set_name (string (_name->GetValue().mb_str()));
291 DCPPanel::j2k_bandwidth_changed ()
297 _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
301 DCPPanel::signed_toggled ()
307 _film->set_signed (_signed->GetValue ());
311 DCPPanel::encrypted_toggled ()
317 _film->set_encrypted (_encrypted->GetValue ());
320 /** Called when the frame rate choice widget has been changed */
322 DCPPanel::frame_rate_choice_changed ()
328 _film->set_video_frame_rate (
329 boost::lexical_cast<int>(
330 wx_to_std(_frame_rate_choice->GetString(_frame_rate_choice->GetSelection()))
336 /** Called when the frame rate spin widget has been changed */
338 DCPPanel::frame_rate_spin_changed ()
344 _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
348 DCPPanel::audio_channels_changed ()
354 _film->set_audio_channels (locale_convert<int> (string_client_data (_audio_channels->GetClientObject (_audio_channels->GetSelection ()))));
358 DCPPanel::resolution_changed ()
364 _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
368 DCPPanel::standard_changed ()
374 _film->set_interop (_standard->GetSelection() == 1);
378 DCPPanel::upload_after_make_dcp_changed ()
384 _film->set_upload_after_make_dcp (_upload_after_make_dcp->GetValue ());
388 DCPPanel::markers_clicked ()
390 if (_markers_dialog) {
391 _markers_dialog->Destroy ();
395 _markers_dialog = new MarkersDialog (_panel, _film, _viewer);
396 _markers_dialog->Show();
400 DCPPanel::metadata_clicked ()
402 if (_metadata_dialog) {
403 _metadata_dialog->Destroy ();
404 _metadata_dialog = 0;
407 _metadata_dialog = new MetadataDialog (_panel, _film);
408 _metadata_dialog->Show ();
412 DCPPanel::film_changed (int p)
417 case Film::CONTAINER:
421 checked_set (_name, _film->name());
424 case Film::DCP_CONTENT_TYPE:
425 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
429 checked_set (_signed, _film->is_signed ());
431 case Film::ENCRYPTED:
432 checked_set (_encrypted, _film->encrypted ());
433 if (_film->encrypted ()) {
434 _film->set_signed (true);
435 _signed->Enable (false);
436 _key->Enable (_generally_sensitive);
437 _edit_key->Enable (_generally_sensitive);
439 _signed->Enable (_generally_sensitive);
440 _key->Enable (false);
441 _edit_key->Enable (false);
445 checked_set (_key, _film->key().hex().substr (0, 8) + "...");
447 case Film::RESOLUTION:
448 checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
452 case Film::J2K_BANDWIDTH:
453 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
455 case Film::USE_ISDCF_NAME:
457 checked_set (_use_isdcf_name, _film->use_isdcf_name ());
459 _edit_isdcf_button->Enable (_film->use_isdcf_name ());
462 case Film::ISDCF_METADATA:
465 case Film::VIDEO_FRAME_RATE:
468 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
469 if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
470 checked_set (_frame_rate_choice, i);
477 checked_set (_frame_rate_choice, -1);
480 checked_set (_frame_rate_spin, _film->video_frame_rate ());
482 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
486 case Film::AUDIO_CHANNELS:
487 if (_film->audio_channels () < minimum_allowed_audio_channels ()) {
488 _film->set_audio_channels (minimum_allowed_audio_channels ());
490 checked_set (_audio_channels, locale_convert<string> (max (minimum_allowed_audio_channels(), _film->audio_channels ())));
495 checked_set (_three_d, _film->three_d ());
498 case Film::REENCODE_J2K:
499 checked_set (_reencode_j2k, _film->reencode_j2k());
502 checked_set (_standard, _film->interop() ? 1 : 0);
504 _markers->Enable (!_film->interop());
506 case Film::AUDIO_PROCESSOR:
507 if (_film->audio_processor ()) {
508 checked_set (_audio_processor, _film->audio_processor()->id());
510 checked_set (_audio_processor, 0);
512 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
513 film_changed (Film::AUDIO_CHANNELS);
515 case Film::REEL_TYPE:
516 checked_set (_reel_type, _film->reel_type ());
517 _reel_length->Enable (_film->reel_type() == REELTYPE_BY_LENGTH);
519 case Film::REEL_LENGTH:
520 checked_set (_reel_length, _film->reel_length() / 1000000000LL);
522 case Film::UPLOAD_AFTER_MAKE_DCP:
523 checked_set (_upload_after_make_dcp, _film->upload_after_make_dcp ());
534 DCPPanel::film_content_changed (int property)
536 if (property == AudioContentProperty::STREAMS ||
537 property == TextContentProperty::USE ||
538 property == TextContentProperty::BURN ||
539 property == VideoContentProperty::SCALE ||
540 property == DCPContentProperty::REFERENCE_VIDEO ||
541 property == DCPContentProperty::REFERENCE_AUDIO ||
542 property == DCPContentProperty::REFERENCE_TEXT) {
544 setup_sensitivity ();
550 DCPPanel::setup_container ()
553 vector<Ratio const *> ratios = Ratio::containers ();
554 vector<Ratio const *>::iterator i = ratios.begin ();
555 while (i != ratios.end() && *i != _film->container ()) {
560 if (i == ratios.end()) {
561 checked_set (_container, -1);
562 checked_set (_container_size, wxT (""));
564 checked_set (_container, n);
565 dcp::Size const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
566 checked_set (_container_size, wxString::Format ("%dx%d", size.width, size.height));
572 /** Called when the container widget has been changed */
574 DCPPanel::container_changed ()
580 int const n = _container->GetSelection ();
582 vector<Ratio const *> ratios = Ratio::containers ();
583 DCPOMATIC_ASSERT (n < int (ratios.size()));
584 _film->set_container (ratios[n]);
588 /** Called when the DCP content type widget has been changed */
590 DCPPanel::dcp_content_type_changed ()
596 int const n = _dcp_content_type->GetSelection ();
597 if (n != wxNOT_FOUND) {
598 _film->set_dcp_content_type (DCPContentType::from_index (n));
603 DCPPanel::set_film (shared_ptr<Film> film)
605 /* We are changing film, so destroy any dialogs for the old one */
607 _audio_dialog->Destroy ();
610 if (_markers_dialog) {
611 _markers_dialog->Destroy ();
614 if (_metadata_dialog) {
615 _metadata_dialog->Destroy ();
616 _metadata_dialog = 0;
622 /* Really should all the film_changed below but this might be enough */
623 checked_set (_dcp_name, wxT(""));
624 set_general_sensitivity (false);
628 film_changed (Film::NAME);
629 film_changed (Film::USE_ISDCF_NAME);
630 film_changed (Film::CONTENT);
631 film_changed (Film::DCP_CONTENT_TYPE);
632 film_changed (Film::CONTAINER);
633 film_changed (Film::RESOLUTION);
634 film_changed (Film::SIGNED);
635 film_changed (Film::ENCRYPTED);
636 film_changed (Film::KEY);
637 film_changed (Film::J2K_BANDWIDTH);
638 film_changed (Film::ISDCF_METADATA);
639 film_changed (Film::VIDEO_FRAME_RATE);
640 film_changed (Film::AUDIO_CHANNELS);
641 film_changed (Film::SEQUENCE);
642 film_changed (Film::THREE_D);
643 film_changed (Film::INTEROP);
644 film_changed (Film::AUDIO_PROCESSOR);
645 film_changed (Film::REEL_TYPE);
646 film_changed (Film::REEL_LENGTH);
647 film_changed (Film::UPLOAD_AFTER_MAKE_DCP);
648 film_changed (Film::REENCODE_J2K);
650 set_general_sensitivity(static_cast<bool>(_film));
654 DCPPanel::set_general_sensitivity (bool s)
656 _generally_sensitive = s;
657 setup_sensitivity ();
661 DCPPanel::setup_sensitivity ()
663 _name->Enable (_generally_sensitive);
664 _use_isdcf_name->Enable (_generally_sensitive);
665 _edit_isdcf_button->Enable (_generally_sensitive);
666 _dcp_content_type->Enable (_generally_sensitive);
667 _copy_isdcf_name_button->Enable (_generally_sensitive);
669 bool si = _generally_sensitive;
670 if (_film && _film->encrypted ()) {
673 _signed->Enable (si);
675 _encrypted->Enable (_generally_sensitive);
676 _key->Enable (_generally_sensitive && _film && _film->encrypted ());
677 _edit_key->Enable (_generally_sensitive && _film && _film->encrypted ());
678 _reel_type->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio());
679 _reel_length->Enable (_generally_sensitive && _film && _film->reel_type() == REELTYPE_BY_LENGTH);
680 _upload_after_make_dcp->Enable (_generally_sensitive);
681 _markers->Enable (_generally_sensitive && _film && !_film->interop());
682 _metadata->Enable (_generally_sensitive);
683 _frame_rate_choice->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
684 _frame_rate_spin->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
685 _audio_channels->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
686 _audio_processor->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
687 _j2k_bandwidth->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
688 _container->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
689 _best_frame_rate->Enable (_generally_sensitive && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
690 _resolution->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
691 _three_d->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
692 _standard->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio());
693 _reencode_j2k->Enable (_generally_sensitive && _film);
694 _show_audio->Enable (_generally_sensitive && _film);
698 DCPPanel::use_isdcf_name_toggled ()
704 _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
708 DCPPanel::edit_isdcf_button_clicked ()
714 ISDCFMetadataDialog* d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata (), _film->three_d ());
716 _film->set_isdcf_metadata (d->isdcf_metadata ());
721 DCPPanel::setup_dcp_name ()
723 _dcp_name->SetLabel (std_to_wx (_film->dcp_name (true)));
724 _dcp_name->SetToolTip (std_to_wx (_film->dcp_name (true)));
728 DCPPanel::best_frame_rate_clicked ()
734 _film->set_video_frame_rate (_film->best_video_frame_rate ());
738 DCPPanel::three_d_changed ()
744 _film->set_three_d (_three_d->GetValue ());
748 DCPPanel::reencode_j2k_changed ()
754 _film->set_reencode_j2k (_reencode_j2k->GetValue());
758 DCPPanel::config_changed (Config::Property p)
760 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
761 setup_frame_rate_widget ();
763 if (p == Config::INTERFACE_COMPLEXITY) {
769 _video_grid->Clear ();
770 add_video_panel_to_grid ();
771 _video_grid->Layout ();
773 _audio_grid->Clear ();
774 add_audio_panel_to_grid ();
775 _audio_grid->Layout ();
780 DCPPanel::setup_frame_rate_widget ()
782 if (Config::instance()->allow_any_dcp_frame_rate ()) {
783 _frame_rate_choice->Hide ();
784 _frame_rate_spin->Show ();
786 _frame_rate_choice->Show ();
787 _frame_rate_spin->Hide ();
790 _frame_rate_sizer->Layout ();
794 DCPPanel::make_video_panel ()
796 wxPanel* panel = new wxPanel (_notebook);
797 wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
798 _video_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
799 sizer->Add (_video_grid, 0, wxALL, 8);
800 panel->SetSizer (sizer);
802 _container_label = create_label (panel, _("Container"), true);
803 _container = new wxChoice (panel, wxID_ANY);
804 _container_size = new StaticText (panel, wxT (""));
806 _resolution_label = create_label (panel, _("Resolution"), true);
807 _resolution = new wxChoice (panel, wxID_ANY);
809 _frame_rate_label = create_label (panel, _("Frame Rate"), true);
810 _frame_rate_choice = new wxChoice (panel, wxID_ANY);
811 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
812 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
813 _frame_rate_spin = new wxSpinCtrl (panel, wxID_ANY);
814 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
815 setup_frame_rate_widget ();
816 _best_frame_rate = new Button (panel, _("Use best"));
817 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
819 _three_d = new CheckBox (panel, _("3D"));
821 _j2k_bandwidth_label = create_label (panel, _("JPEG2000 bandwidth\nfor newly-encoded data"), true);
822 _j2k_bandwidth = new wxSpinCtrl (panel, wxID_ANY);
823 _mbits_label = create_label (panel, _("Mbit/s"), false);
825 _reencode_j2k = new CheckBox (panel, _("Re-encode JPEG2000 data from input"));
827 _container->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::container_changed, this));
828 _frame_rate_choice->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::frame_rate_choice_changed, this));
829 _frame_rate_spin->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::frame_rate_spin_changed, this));
830 _best_frame_rate->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::best_frame_rate_clicked, this));
831 _j2k_bandwidth->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
832 /* Also listen to wxEVT_TEXT so that typing numbers directly in is always noticed */
833 _j2k_bandwidth->Bind (wxEVT_TEXT, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
834 _resolution->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::resolution_changed, this));
835 _three_d->Bind (wxEVT_CHECKBOX, boost::bind(&DCPPanel::three_d_changed, this));
836 _reencode_j2k->Bind (wxEVT_CHECKBOX, boost::bind(&DCPPanel::reencode_j2k_changed, this));
838 BOOST_FOREACH (Ratio const * i, Ratio::containers()) {
839 _container->Append (std_to_wx(i->container_nickname()));
842 BOOST_FOREACH (int i, Config::instance()->allowed_dcp_frame_rates()) {
843 _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (i)));
846 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
847 _frame_rate_spin->SetRange (1, 480);
849 _resolution->Append (_("2K"));
850 _resolution->Append (_("4K"));
852 add_video_panel_to_grid ();
858 DCPPanel::add_video_panel_to_grid ()
860 bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
864 add_label_to_sizer (_video_grid, _container_label, true, wxGBPosition (r, 0));
866 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
867 s->Add (_container, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
868 s->Add (_container_size, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
869 _video_grid->Add (s, wxGBPosition(r, 1));
873 add_label_to_sizer (_video_grid, _resolution_label, true, wxGBPosition (r, 0));
874 _video_grid->Add (_resolution, wxGBPosition (r, 1));
877 add_label_to_sizer (_video_grid, _frame_rate_label, true, wxGBPosition (r, 0));
879 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
880 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
881 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
882 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
883 _video_grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
887 _video_grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
890 _j2k_bandwidth_label->Show (full);
891 _j2k_bandwidth->Show (full);
892 _mbits_label->Show (full);
895 add_label_to_sizer (_video_grid, _j2k_bandwidth_label, true, wxGBPosition (r, 0));
896 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
897 s->Add (_j2k_bandwidth, 1);
898 add_label_to_sizer (s, _mbits_label, false);
899 _video_grid->Add (s, wxGBPosition (r, 1));
901 _video_grid->Add (_reencode_j2k, wxGBPosition(r, 0), wxGBSpan(1, 2));
906 DCPPanel::minimum_allowed_audio_channels () const
909 if (_film && _film->audio_processor ()) {
910 min = _film->audio_processor()->out_channels ();
921 DCPPanel::make_audio_panel ()
923 wxPanel* panel = new wxPanel (_notebook);
924 wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
925 _audio_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
926 sizer->Add (_audio_grid, 0, wxALL, 8);
927 panel->SetSizer (sizer);
929 _channels_label = create_label (panel, _("Channels"), true);
930 _audio_channels = new wxChoice (panel, wxID_ANY);
931 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
933 _processor_label = create_label (panel, _("Processor"), true);
934 _audio_processor = new wxChoice (panel, wxID_ANY);
935 _audio_processor->Append (_("None"), new wxStringClientData (N_("none")));
936 BOOST_FOREACH (AudioProcessor const * ap, AudioProcessor::all ()) {
937 _audio_processor->Append (std_to_wx (ap->name ()), new wxStringClientData (std_to_wx (ap->id ())));
940 _show_audio = new Button (panel, _("Show audio..."));
942 _audio_channels->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_channels_changed, this));
943 _audio_processor->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_processor_changed, this));
944 _show_audio->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::show_audio_clicked, this));
946 add_audio_panel_to_grid ();
952 DCPPanel::add_audio_panel_to_grid ()
954 bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
958 _channels_label->Show (full);
959 _audio_channels->Show (full);
962 add_label_to_sizer (_audio_grid, _channels_label, true, wxGBPosition (r, 0));
963 _audio_grid->Add (_audio_channels, wxGBPosition (r, 1));
967 _processor_label->Show (full);
968 _audio_processor->Show (full);
971 add_label_to_sizer (_audio_grid, _processor_label, true, wxGBPosition (r, 0));
972 _audio_grid->Add (_audio_processor, wxGBPosition (r, 1));
976 _audio_grid->Add (_show_audio, wxGBPosition (r, 0), wxGBSpan (1, 2));
981 DCPPanel::copy_isdcf_name_button_clicked ()
983 _film->set_name (_film->isdcf_name (true));
984 _film->set_use_isdcf_name (false);
988 DCPPanel::audio_processor_changed ()
994 string const s = string_client_data (_audio_processor->GetClientObject (_audio_processor->GetSelection ()));
995 _film->set_audio_processor (AudioProcessor::from_id (s));
999 DCPPanel::show_audio_clicked ()
1005 if (_audio_dialog) {
1006 _audio_dialog->Destroy ();
1010 AudioDialog* d = new AudioDialog (_panel, _film);
1015 DCPPanel::reel_type_changed ()
1021 _film->set_reel_type (static_cast<ReelType> (_reel_type->GetSelection ()));
1025 DCPPanel::reel_length_changed ()
1031 _film->set_reel_length (_reel_length->GetValue() * 1000000000LL);