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 ());
458 if (_film->use_isdcf_name()) {
459 /* We are going back to using an ISDCF name. Remove anything after a _ in the current name,
460 in case the user has clicked 'Copy as name' then re-ticked 'Use ISDCF name' (#1513).
462 string const name = _film->name ();
463 string::size_type const u = name.find("_");
464 if (u != string::npos) {
465 _film->set_name (name.substr(0, u));
469 _edit_isdcf_button->Enable (_film->use_isdcf_name ());
472 case Film::ISDCF_METADATA:
475 case Film::VIDEO_FRAME_RATE:
478 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
479 if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
480 checked_set (_frame_rate_choice, i);
487 checked_set (_frame_rate_choice, -1);
490 checked_set (_frame_rate_spin, _film->video_frame_rate ());
492 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
496 case Film::AUDIO_CHANNELS:
497 if (_film->audio_channels () < minimum_allowed_audio_channels ()) {
498 _film->set_audio_channels (minimum_allowed_audio_channels ());
500 checked_set (_audio_channels, locale_convert<string> (max (minimum_allowed_audio_channels(), _film->audio_channels ())));
505 checked_set (_three_d, _film->three_d ());
508 case Film::REENCODE_J2K:
509 checked_set (_reencode_j2k, _film->reencode_j2k());
512 checked_set (_standard, _film->interop() ? 1 : 0);
514 _markers->Enable (!_film->interop());
516 case Film::AUDIO_PROCESSOR:
517 if (_film->audio_processor ()) {
518 checked_set (_audio_processor, _film->audio_processor()->id());
520 checked_set (_audio_processor, 0);
522 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
523 film_changed (Film::AUDIO_CHANNELS);
525 case Film::REEL_TYPE:
526 checked_set (_reel_type, _film->reel_type ());
527 _reel_length->Enable (_film->reel_type() == REELTYPE_BY_LENGTH);
529 case Film::REEL_LENGTH:
530 checked_set (_reel_length, _film->reel_length() / 1000000000LL);
532 case Film::UPLOAD_AFTER_MAKE_DCP:
533 checked_set (_upload_after_make_dcp, _film->upload_after_make_dcp ());
544 DCPPanel::film_content_changed (int property)
546 if (property == AudioContentProperty::STREAMS ||
547 property == TextContentProperty::USE ||
548 property == TextContentProperty::BURN ||
549 property == VideoContentProperty::SCALE ||
550 property == DCPContentProperty::REFERENCE_VIDEO ||
551 property == DCPContentProperty::REFERENCE_AUDIO ||
552 property == DCPContentProperty::REFERENCE_TEXT) {
554 setup_sensitivity ();
560 DCPPanel::setup_container ()
563 vector<Ratio const *> ratios = Ratio::containers ();
564 vector<Ratio const *>::iterator i = ratios.begin ();
565 while (i != ratios.end() && *i != _film->container ()) {
570 if (i == ratios.end()) {
571 checked_set (_container, -1);
572 checked_set (_container_size, wxT (""));
574 checked_set (_container, n);
575 dcp::Size const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
576 checked_set (_container_size, wxString::Format ("%dx%d", size.width, size.height));
582 /** Called when the container widget has been changed */
584 DCPPanel::container_changed ()
590 int const n = _container->GetSelection ();
592 vector<Ratio const *> ratios = Ratio::containers ();
593 DCPOMATIC_ASSERT (n < int (ratios.size()));
594 _film->set_container (ratios[n]);
598 /** Called when the DCP content type widget has been changed */
600 DCPPanel::dcp_content_type_changed ()
606 int const n = _dcp_content_type->GetSelection ();
607 if (n != wxNOT_FOUND) {
608 _film->set_dcp_content_type (DCPContentType::from_index (n));
613 DCPPanel::set_film (shared_ptr<Film> film)
615 /* We are changing film, so destroy any dialogs for the old one */
617 _audio_dialog->Destroy ();
620 if (_markers_dialog) {
621 _markers_dialog->Destroy ();
624 if (_metadata_dialog) {
625 _metadata_dialog->Destroy ();
626 _metadata_dialog = 0;
632 /* Really should all the film_changed below but this might be enough */
633 checked_set (_dcp_name, wxT(""));
634 set_general_sensitivity (false);
638 film_changed (Film::NAME);
639 film_changed (Film::USE_ISDCF_NAME);
640 film_changed (Film::CONTENT);
641 film_changed (Film::DCP_CONTENT_TYPE);
642 film_changed (Film::CONTAINER);
643 film_changed (Film::RESOLUTION);
644 film_changed (Film::SIGNED);
645 film_changed (Film::ENCRYPTED);
646 film_changed (Film::KEY);
647 film_changed (Film::J2K_BANDWIDTH);
648 film_changed (Film::ISDCF_METADATA);
649 film_changed (Film::VIDEO_FRAME_RATE);
650 film_changed (Film::AUDIO_CHANNELS);
651 film_changed (Film::SEQUENCE);
652 film_changed (Film::THREE_D);
653 film_changed (Film::INTEROP);
654 film_changed (Film::AUDIO_PROCESSOR);
655 film_changed (Film::REEL_TYPE);
656 film_changed (Film::REEL_LENGTH);
657 film_changed (Film::UPLOAD_AFTER_MAKE_DCP);
658 film_changed (Film::REENCODE_J2K);
660 set_general_sensitivity(static_cast<bool>(_film));
664 DCPPanel::set_general_sensitivity (bool s)
666 _generally_sensitive = s;
667 setup_sensitivity ();
671 DCPPanel::setup_sensitivity ()
673 _name->Enable (_generally_sensitive);
674 _use_isdcf_name->Enable (_generally_sensitive);
675 _edit_isdcf_button->Enable (_generally_sensitive);
676 _dcp_content_type->Enable (_generally_sensitive);
677 _copy_isdcf_name_button->Enable (_generally_sensitive);
679 bool si = _generally_sensitive;
680 if (_film && _film->encrypted ()) {
683 _signed->Enable (si);
685 _encrypted->Enable (_generally_sensitive);
686 _key->Enable (_generally_sensitive && _film && _film->encrypted ());
687 _edit_key->Enable (_generally_sensitive && _film && _film->encrypted ());
688 _reel_type->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio());
689 _reel_length->Enable (_generally_sensitive && _film && _film->reel_type() == REELTYPE_BY_LENGTH);
690 _upload_after_make_dcp->Enable (_generally_sensitive);
691 _markers->Enable (_generally_sensitive && _film && !_film->interop());
692 _metadata->Enable (_generally_sensitive);
693 _frame_rate_choice->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
694 _frame_rate_spin->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
695 _audio_channels->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
696 _audio_processor->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
697 _j2k_bandwidth->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
698 _container->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
699 _best_frame_rate->Enable (_generally_sensitive && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
700 _resolution->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
701 _three_d->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
702 _standard->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio());
703 _reencode_j2k->Enable (_generally_sensitive && _film);
704 _show_audio->Enable (_generally_sensitive && _film);
708 DCPPanel::use_isdcf_name_toggled ()
714 _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
718 DCPPanel::edit_isdcf_button_clicked ()
724 ISDCFMetadataDialog* d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata (), _film->three_d ());
726 _film->set_isdcf_metadata (d->isdcf_metadata ());
731 DCPPanel::setup_dcp_name ()
733 _dcp_name->SetLabel (std_to_wx (_film->dcp_name (true)));
734 _dcp_name->SetToolTip (std_to_wx (_film->dcp_name (true)));
738 DCPPanel::best_frame_rate_clicked ()
744 _film->set_video_frame_rate (_film->best_video_frame_rate ());
748 DCPPanel::three_d_changed ()
754 _film->set_three_d (_three_d->GetValue ());
758 DCPPanel::reencode_j2k_changed ()
764 _film->set_reencode_j2k (_reencode_j2k->GetValue());
768 DCPPanel::config_changed (Config::Property p)
770 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
771 setup_frame_rate_widget ();
773 if (p == Config::INTERFACE_COMPLEXITY) {
779 _video_grid->Clear ();
780 add_video_panel_to_grid ();
781 _video_grid->Layout ();
783 _audio_grid->Clear ();
784 add_audio_panel_to_grid ();
785 _audio_grid->Layout ();
786 } else if (p == Config::SHOW_EXPERIMENTAL_AUDIO_PROCESSORS) {
787 _audio_processor->Clear ();
788 add_audio_processors ();
790 film_changed (Film::AUDIO_PROCESSOR);
796 DCPPanel::setup_frame_rate_widget ()
798 if (Config::instance()->allow_any_dcp_frame_rate ()) {
799 _frame_rate_choice->Hide ();
800 _frame_rate_spin->Show ();
802 _frame_rate_choice->Show ();
803 _frame_rate_spin->Hide ();
806 _frame_rate_sizer->Layout ();
810 DCPPanel::make_video_panel ()
812 wxPanel* panel = new wxPanel (_notebook);
813 wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
814 _video_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
815 sizer->Add (_video_grid, 0, wxALL, 8);
816 panel->SetSizer (sizer);
818 _container_label = create_label (panel, _("Container"), true);
819 _container = new wxChoice (panel, wxID_ANY);
820 _container_size = new StaticText (panel, wxT (""));
822 _resolution_label = create_label (panel, _("Resolution"), true);
823 _resolution = new wxChoice (panel, wxID_ANY);
825 _frame_rate_label = create_label (panel, _("Frame Rate"), true);
826 _frame_rate_choice = new wxChoice (panel, wxID_ANY);
827 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
828 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
829 _frame_rate_spin = new wxSpinCtrl (panel, wxID_ANY);
830 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
831 setup_frame_rate_widget ();
832 _best_frame_rate = new Button (panel, _("Use best"));
833 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
835 _three_d = new CheckBox (panel, _("3D"));
837 _j2k_bandwidth_label = create_label (panel, _("JPEG2000 bandwidth\nfor newly-encoded data"), true);
838 _j2k_bandwidth = new wxSpinCtrl (panel, wxID_ANY);
839 _mbits_label = create_label (panel, _("Mbit/s"), false);
841 _reencode_j2k = new CheckBox (panel, _("Re-encode JPEG2000 data from input"));
843 _container->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::container_changed, this));
844 _frame_rate_choice->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::frame_rate_choice_changed, this));
845 _frame_rate_spin->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::frame_rate_spin_changed, this));
846 _best_frame_rate->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::best_frame_rate_clicked, this));
847 _j2k_bandwidth->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
848 /* Also listen to wxEVT_TEXT so that typing numbers directly in is always noticed */
849 _j2k_bandwidth->Bind (wxEVT_TEXT, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
850 _resolution->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::resolution_changed, this));
851 _three_d->Bind (wxEVT_CHECKBOX, boost::bind(&DCPPanel::three_d_changed, this));
852 _reencode_j2k->Bind (wxEVT_CHECKBOX, boost::bind(&DCPPanel::reencode_j2k_changed, this));
854 BOOST_FOREACH (Ratio const * i, Ratio::containers()) {
855 _container->Append (std_to_wx(i->container_nickname()));
858 BOOST_FOREACH (int i, Config::instance()->allowed_dcp_frame_rates()) {
859 _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (i)));
862 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
863 _frame_rate_spin->SetRange (1, 480);
865 _resolution->Append (_("2K"));
866 _resolution->Append (_("4K"));
868 add_video_panel_to_grid ();
874 DCPPanel::add_video_panel_to_grid ()
876 bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
880 add_label_to_sizer (_video_grid, _container_label, true, wxGBPosition (r, 0));
882 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
883 s->Add (_container, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
884 s->Add (_container_size, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
885 _video_grid->Add (s, wxGBPosition(r, 1));
889 add_label_to_sizer (_video_grid, _resolution_label, true, wxGBPosition (r, 0));
890 _video_grid->Add (_resolution, wxGBPosition (r, 1));
893 add_label_to_sizer (_video_grid, _frame_rate_label, true, wxGBPosition (r, 0));
895 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
896 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
897 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
898 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
899 _video_grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
903 _video_grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
906 _j2k_bandwidth_label->Show (full);
907 _j2k_bandwidth->Show (full);
908 _mbits_label->Show (full);
911 add_label_to_sizer (_video_grid, _j2k_bandwidth_label, true, wxGBPosition (r, 0));
912 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
913 s->Add (_j2k_bandwidth, 1);
914 add_label_to_sizer (s, _mbits_label, false);
915 _video_grid->Add (s, wxGBPosition (r, 1));
917 _video_grid->Add (_reencode_j2k, wxGBPosition(r, 0), wxGBSpan(1, 2));
922 DCPPanel::minimum_allowed_audio_channels () const
925 if (_film && _film->audio_processor ()) {
926 min = _film->audio_processor()->out_channels ();
937 DCPPanel::make_audio_panel ()
939 wxPanel* panel = new wxPanel (_notebook);
940 _audio_panel_sizer = new wxBoxSizer (wxVERTICAL);
941 _audio_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
942 _audio_panel_sizer->Add (_audio_grid, 0, wxALL, 8);
943 panel->SetSizer (_audio_panel_sizer);
945 _channels_label = create_label (panel, _("Channels"), true);
946 _audio_channels = new wxChoice (panel, wxID_ANY);
947 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
949 _processor_label = create_label (panel, _("Processor"), true);
950 _audio_processor = new wxChoice (panel, wxID_ANY);
951 add_audio_processors ();
953 _show_audio = new Button (panel, _("Show audio..."));
955 _audio_channels->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_channels_changed, this));
956 _audio_processor->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_processor_changed, this));
957 _show_audio->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::show_audio_clicked, this));
959 add_audio_panel_to_grid ();
965 DCPPanel::add_audio_panel_to_grid ()
967 bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
971 _channels_label->Show (full);
972 _audio_channels->Show (full);
975 add_label_to_sizer (_audio_grid, _channels_label, true, wxGBPosition (r, 0));
976 _audio_grid->Add (_audio_channels, wxGBPosition (r, 1));
980 _processor_label->Show (full);
981 _audio_processor->Show (full);
984 add_label_to_sizer (_audio_grid, _processor_label, true, wxGBPosition (r, 0));
985 _audio_grid->Add (_audio_processor, wxGBPosition (r, 1));
989 _audio_grid->Add (_show_audio, wxGBPosition (r, 0), wxGBSpan (1, 2));
994 DCPPanel::copy_isdcf_name_button_clicked ()
996 _film->set_name (_film->isdcf_name (true));
997 _film->set_use_isdcf_name (false);
1001 DCPPanel::audio_processor_changed ()
1007 string const s = string_client_data (_audio_processor->GetClientObject (_audio_processor->GetSelection ()));
1008 _film->set_audio_processor (AudioProcessor::from_id (s));
1012 DCPPanel::show_audio_clicked ()
1018 if (_audio_dialog) {
1019 _audio_dialog->Destroy ();
1023 AudioDialog* d = new AudioDialog (_panel, _film);
1028 DCPPanel::reel_type_changed ()
1034 _film->set_reel_type (static_cast<ReelType> (_reel_type->GetSelection ()));
1038 DCPPanel::reel_length_changed ()
1044 _film->set_reel_length (_reel_length->GetValue() * 1000000000LL);
1048 DCPPanel::add_audio_processors ()
1050 _audio_processor->Append (_("None"), new wxStringClientData (N_("none")));
1051 BOOST_FOREACH (AudioProcessor const * ap, AudioProcessor::visible()) {
1052 _audio_processor->Append (std_to_wx(ap->name()), new wxStringClientData(std_to_wx(ap->id())));
1054 _audio_panel_sizer->Layout();