2 Copyright (C) 2023 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/>.
22 #include "check_box.h"
23 #include "dcp_referencing_dialog.h"
24 #include "static_text.h"
26 #include "lib/dcp_content.h"
28 #include "lib/types.h"
29 #include <wx/gbsizer.h>
33 using std::dynamic_pointer_cast;
34 using std::shared_ptr;
38 #if BOOST_VERSION >= 106100
39 using namespace boost::placeholders;
43 DCPReferencingDialog::DCPReferencingDialog(wxWindow* parent, shared_ptr<const Film> film)
44 : wxDialog(parent, wxID_ANY, _("Version file (VF) setup"))
46 , _dcp_grid(new wxGridBagSizer(DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP))
47 , _overall_sizer(new wxBoxSizer(wxVERTICAL))
49 _film_connection = film->Change.connect(boost::bind(&DCPReferencingDialog::film_changed, this, _1, _2));
50 _film_content_connection = film->ContentChange.connect(boost::bind(&DCPReferencingDialog::film_content_changed, this, _1, _3));
52 _overall_sizer->Add(_dcp_grid, 1, wxALL, DCPOMATIC_DIALOG_BORDER);
53 SetSizer(_overall_sizer);
55 auto buttons = CreateSeparatedButtonSizer(wxOK);
57 _overall_sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder());
65 DCPReferencingDialog::film_changed(ChangeType type, FilmProperty property)
67 if (type != ChangeType::DONE) {
72 property == FilmProperty::INTEROP ||
73 property == FilmProperty::RESOLUTION ||
74 property == FilmProperty::CONTAINER ||
75 property == FilmProperty::REEL_TYPE ||
76 property == FilmProperty::VIDEO_FRAME_RATE ||
77 property == FilmProperty::CONTENT) {
84 DCPReferencingDialog::film_content_changed(ChangeType type, int property)
86 if (type != ChangeType::DONE) {
91 property != DCPContentProperty::REFERENCE_VIDEO &&
92 property != DCPContentProperty::REFERENCE_AUDIO &&
93 property != DCPContentProperty::REFERENCE_TEXT) {
100 DCPReferencingDialog::setup()
103 _dcp_grid->Clear(true);
106 for (auto const& heading: { _("DCP"), _("Picture"), _("Sound"), _("Subtitles"), _("Closed captions") }) {
107 auto text = new StaticText(this, heading);
108 wxFont font(*wxNORMAL_FONT);
109 font.SetWeight(wxFONTWEIGHT_BOLD);
111 _dcp_grid->Add(text, wxGBPosition(0, column), wxDefaultSpan, wxALL, DCPOMATIC_SIZER_GAP);
115 auto const all_parts = { Part::VIDEO, Part::AUDIO, Part::SUBTITLES, Part::CLOSED_CAPTIONS };
118 for (auto& content: _film->content()) {
119 auto dcp_content = dynamic_pointer_cast<DCPContent>(content);
125 record.content = dcp_content;
126 _dcp_grid->Add(new StaticText(this, std_to_wx(dcp_content->name())), wxGBPosition(row, 0));
128 for (auto const& part: all_parts) {
129 record.check_box[part] = new CheckBox(this, wxT(""));
132 record.check_box[part]->set(dcp_content->reference_video());
135 record.check_box[part]->set(dcp_content->reference_audio());
137 case Part::SUBTITLES:
138 record.check_box[part]->set(dcp_content->reference_text(TextType::OPEN_SUBTITLE));
140 case Part::CLOSED_CAPTIONS:
141 record.check_box[part]->set(dcp_content->reference_text(TextType::CLOSED_CAPTION));
144 DCPOMATIC_ASSERT(false);
146 record.check_box[part]->bind(&DCPReferencingDialog::checkbox_changed, this, weak_ptr<DCPContent>(dcp_content), record.check_box[part], part);
147 _dcp_grid->Add(record.check_box[part], wxGBPosition(row, column++), wxDefaultSpan, wxALIGN_CENTER);
151 auto add_problem = [this, &row](wxString const& cannot, string why_not) {
152 auto reason = new StaticText(this, cannot + wxT(": ") + std_to_wx(why_not));
153 wxFont font(*wxNORMAL_FONT);
154 font.SetStyle(wxFONTSTYLE_ITALIC);
155 reason->SetFont(font);
156 _dcp_grid->Add(reason, wxGBPosition(row, 0), wxGBSpan(1, 5), wxLEFT, DCPOMATIC_SIZER_X_GAP * 4);
162 if (!dcp_content->can_reference_anything(_film, why_not)) {
163 for (auto const& part: all_parts) {
164 record.check_box[part]->Enable(false);
166 add_problem(_("Cannot reference this DCP"), why_not);
168 if (!dcp_content->can_reference_video(_film, why_not)) {
169 record.check_box[Part::VIDEO]->Enable(false);
170 if (dcp_content->video) {
171 add_problem(_("Cannot reference this DCP's video"), why_not);
175 if (!dcp_content->can_reference_audio(_film, why_not)) {
176 record.check_box[Part::AUDIO]->Enable(false);
177 if (dcp_content->audio) {
178 add_problem(_("Cannot reference this DCP's audio"), why_not);
182 if (!dcp_content->can_reference_text(_film, TextType::OPEN_SUBTITLE, why_not)) {
183 record.check_box[Part::SUBTITLES]->Enable(false);
184 if (dcp_content->text_of_original_type(TextType::OPEN_SUBTITLE)) {
185 add_problem(_("Cannot reference this DCP's subtitles"), why_not);
189 if (!dcp_content->can_reference_text(_film, TextType::CLOSED_CAPTION, why_not)) {
190 record.check_box[Part::CLOSED_CAPTIONS]->Enable(false);
191 if (dcp_content->text_of_original_type(TextType::CLOSED_CAPTION)) {
192 add_problem(_("Cannot reference this DCP's closed captions"), why_not);
197 _dcps.push_back(record);
201 _overall_sizer->Layout();
202 _overall_sizer->SetSizeHints(this);
207 DCPReferencingDialog::checkbox_changed(weak_ptr<DCPContent> weak_content, CheckBox* check_box, Part part)
209 auto content = weak_content.lock();
216 content->set_reference_video(check_box->get());
219 content->set_reference_audio(check_box->get());
221 case Part::SUBTITLES:
222 content->set_reference_text(TextType::OPEN_SUBTITLE, check_box->get());
224 case Part::CLOSED_CAPTIONS:
225 content->set_reference_text(TextType::CLOSED_CAPTION, check_box->get());
228 DCPOMATIC_ASSERT(false);