2 Copyright (C) 2019-2021 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 "content_version_dialog.h"
23 #include "editable_list.h"
24 #include "language_tag_dialog.h"
25 #include "language_tag_widget.h"
26 #include "smpte_metadata_dialog.h"
27 #include "rating_dialog.h"
29 #include <dcp/types.h>
30 #include <wx/gbsizer.h>
31 #include <wx/spinctrl.h>
36 using boost::optional;
37 using std::shared_ptr;
39 #if BOOST_VERSION >= 106100
40 using namespace boost::placeholders;
45 ratings_column (dcp::Rating r, int c)
56 content_versions_column (string v, int)
63 SMPTEMetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer)
65 MetadataDialog::setup_standard (panel, sizer);
67 add_label_to_sizer (sizer, panel, _("Title language"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
68 _name_language = new LanguageTagWidget(
70 wxString::Format(_("The language that the film's title (\"%s\") is in"), std_to_wx(film()->name())),
71 film()->name_language()
73 sizer->Add (_name_language->sizer(), 0, wxEXPAND);
76 int flags = wxALIGN_TOP | wxRIGHT | wxTOP;
78 flags |= wxALIGN_RIGHT;
80 auto m = create_label (panel, _("Ratings"), true);
81 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
84 vector<EditableListColumn> columns;
85 columns.push_back (EditableListColumn("Agency", 200, true));
86 columns.push_back (EditableListColumn("Label", 50, true));
87 _ratings = new EditableList<dcp::Rating, RatingDialog> (
90 boost::bind(&SMPTEMetadataDialog::ratings, this),
91 boost::bind(&SMPTEMetadataDialog::set_ratings, this, _1),
92 boost::bind(&ratings_column, _1, _2),
96 sizer->Add (_ratings, 1, wxEXPAND);
101 SMPTEMetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer)
103 MetadataDialog::setup_advanced (panel, sizer);
105 add_label_to_sizer (sizer, panel, _("Version number"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
106 _version_number = new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000);
107 sizer->Add (_version_number, 0);
109 add_label_to_sizer (sizer, panel, _("Status"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
110 _status = new wxChoice (panel, wxID_ANY);
111 sizer->Add (_status, 0);
113 _enable_distributor = new wxCheckBox (panel, wxID_ANY, _("Distributor"));
114 sizer->Add (_enable_distributor, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
115 _distributor = new wxTextCtrl (panel, wxID_ANY);
116 sizer->Add (_distributor, 1, wxEXPAND);
118 add_label_to_sizer (sizer, panel, _("Luminance"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
120 auto s = new wxBoxSizer (wxHORIZONTAL);
121 _luminance_value = new wxSpinCtrlDouble (panel, wxID_ANY);
122 _luminance_value->SetDigits (1);
123 _luminance_value->SetIncrement (0.1);
124 s->Add (_luminance_value, 0);
125 _luminance_unit = new wxChoice (panel, wxID_ANY);
126 s->Add (_luminance_unit, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
127 sizer->Add (s, 1, wxEXPAND);
131 int flags = wxALIGN_TOP | wxRIGHT | wxTOP;
133 flags |= wxALIGN_RIGHT;
135 auto m = create_label (panel, _("Content versions"), true);
136 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
139 vector<EditableListColumn> columns;
140 columns.push_back (EditableListColumn("Version", 350, true));
141 _content_versions = new EditableList<string, ContentVersionDialog> (
144 boost::bind(&SMPTEMetadataDialog::content_versions, this),
145 boost::bind(&SMPTEMetadataDialog::set_content_versions, this, _1),
146 boost::bind(&content_versions_column, _1, _2),
150 sizer->Add (_content_versions, 1, wxEXPAND);
154 SMPTEMetadataDialog::SMPTEMetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
155 : MetadataDialog (parent, weak_film)
162 SMPTEMetadataDialog::setup ()
164 MetadataDialog::setup ();
166 _status->Append (_("Temporary"));
167 _status->Append (_("Pre-release"));
168 _status->Append (_("Final"));
170 _luminance_unit->Append (wxString::FromUTF8(_("candela per m²")));
171 _luminance_unit->Append (_("foot lambert"));
173 _name_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::name_language_changed, this, _1));
174 _version_number->Bind (wxEVT_SPINCTRL, boost::bind(&SMPTEMetadataDialog::version_number_changed, this));
175 _status->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::status_changed, this));
176 _enable_distributor->Bind (wxEVT_CHECKBOX, boost::bind(&SMPTEMetadataDialog::enable_distributor_changed, this));
177 _distributor->Bind (wxEVT_TEXT, boost::bind(&SMPTEMetadataDialog::distributor_changed, this));
178 _luminance_value->Bind (wxEVT_SPINCTRLDOUBLE, boost::bind(&SMPTEMetadataDialog::luminance_changed, this));
179 _luminance_unit->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::luminance_changed, this));
181 film_changed (ChangeType::DONE, Film::Property::NAME_LANGUAGE);
182 film_changed (ChangeType::DONE, Film::Property::VERSION_NUMBER);
183 film_changed (ChangeType::DONE, Film::Property::STATUS);
184 film_changed (ChangeType::DONE, Film::Property::DISTRIBUTOR);
185 film_changed (ChangeType::DONE, Film::Property::CONTENT_VERSIONS);
186 film_changed (ChangeType::DONE, Film::Property::LUMINANCE);
188 setup_sensitivity ();
193 SMPTEMetadataDialog::film_changed (ChangeType type, Film::Property property)
195 MetadataDialog::film_changed (type, property);
197 if (type != ChangeType::DONE || film()->interop()) {
201 if (property == Film::Property::NAME_LANGUAGE) {
202 _name_language->set (film()->name_language());
203 } else if (property == Film::Property::VERSION_NUMBER) {
204 checked_set (_version_number, film()->version_number());
205 } else if (property == Film::Property::STATUS) {
206 switch (film()->status()) {
207 case dcp::Status::TEMP:
208 checked_set (_status, 0);
210 case dcp::Status::PRE:
211 checked_set (_status, 1);
213 case dcp::Status::FINAL:
214 checked_set (_status, 2);
217 } else if (property == Film::Property::DISTRIBUTOR) {
218 checked_set (_enable_distributor, static_cast<bool>(film()->distributor()));
219 if (film()->distributor()) {
220 checked_set (_distributor, *film()->distributor());
222 } else if (property == Film::Property::LUMINANCE) {
223 auto lum = film()->luminance();
225 checked_set (_luminance_value, lum->value());
226 switch (lum->unit()) {
227 case dcp::Luminance::Unit::CANDELA_PER_SQUARE_METRE:
228 checked_set (_luminance_unit, 0);
230 case dcp::Luminance::Unit::FOOT_LAMBERT:
231 checked_set (_luminance_unit, 1);
235 checked_set (_luminance_value, 4.5);
236 checked_set (_luminance_unit, 1);
243 SMPTEMetadataDialog::ratings () const
245 return film()->ratings ();
250 SMPTEMetadataDialog::set_ratings (vector<dcp::Rating> r)
252 film()->set_ratings (r);
257 SMPTEMetadataDialog::content_versions () const
259 return film()->content_versions ();
264 SMPTEMetadataDialog::set_content_versions (vector<string> cv)
266 film()->set_content_versions (cv);
271 SMPTEMetadataDialog::name_language_changed (dcp::LanguageTag tag)
273 film()->set_name_language (tag);
278 SMPTEMetadataDialog::version_number_changed ()
280 film()->set_version_number (_version_number->GetValue());
285 SMPTEMetadataDialog::status_changed ()
287 switch (_status->GetSelection()) {
289 film()->set_status(dcp::Status::TEMP);
292 film()->set_status(dcp::Status::PRE);
295 film()->set_status(dcp::Status::FINAL);
302 SMPTEMetadataDialog::distributor_changed ()
304 film()->set_distributor (wx_to_std(_distributor->GetValue()));
309 SMPTEMetadataDialog::luminance_changed ()
311 dcp::Luminance::Unit unit;
312 switch (_luminance_unit->GetSelection()) {
314 unit = dcp::Luminance::Unit::CANDELA_PER_SQUARE_METRE;
317 unit = dcp::Luminance::Unit::FOOT_LAMBERT;
320 DCPOMATIC_ASSERT (false);
323 film()->set_luminance (dcp::Luminance(_luminance_value->GetValue(), unit));
328 SMPTEMetadataDialog::setup_sensitivity ()
330 MetadataDialog::setup_sensitivity ();
332 _distributor->Enable (_enable_distributor->GetValue());
337 SMPTEMetadataDialog::enable_distributor_changed ()
339 setup_sensitivity ();
340 if (_enable_distributor->GetValue()) {
341 film()->set_distributor (wx_to_std(_distributor->GetValue()));
343 film()->set_distributor ();