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 "rating_dialog.h"
27 #include "smpte_metadata_dialog.h"
29 #include <dcp/types.h>
30 #include <dcp/warnings.h>
31 LIBDCP_DISABLE_WARNINGS
32 #include <wx/gbsizer.h>
33 #include <wx/spinctrl.h>
34 LIBDCP_ENABLE_WARNINGS
37 using std::shared_ptr;
41 using boost::optional;
42 #if BOOST_VERSION >= 106100
43 using namespace boost::placeholders;
48 ratings_column (dcp::Rating r, int c)
59 content_versions_column (string v, int)
66 SMPTEMetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer)
68 MetadataDialog::setup_standard (panel, sizer);
70 add_label_to_sizer (sizer, panel, _("Title language"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
71 _name_language = new LanguageTagWidget(
73 wxString::Format(_("The language that the film's title (\"%s\") is in"), std_to_wx(film()->name())),
74 film()->name_language()
76 sizer->Add (_name_language->sizer(), 0, wxEXPAND);
79 int flags = wxALIGN_TOP | wxRIGHT | wxTOP;
81 flags |= wxALIGN_RIGHT;
83 auto m = create_label (panel, _("Ratings"), true);
84 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
87 vector<EditableListColumn> columns;
88 columns.push_back (EditableListColumn("Agency", 200, true));
89 columns.push_back (EditableListColumn("Label", 50, true));
90 _ratings = new EditableList<dcp::Rating, RatingDialog> (
93 boost::bind(&SMPTEMetadataDialog::ratings, this),
94 boost::bind(&SMPTEMetadataDialog::set_ratings, this, _1),
95 boost::bind(&ratings_column, _1, _2),
99 sizer->Add (_ratings, 1, wxEXPAND);
104 SMPTEMetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer)
106 MetadataDialog::setup_advanced (panel, sizer);
108 add_label_to_sizer (sizer, panel, _("Version number"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
109 _version_number = new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000);
110 sizer->Add (_version_number, 0);
112 add_label_to_sizer (sizer, panel, _("Status"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
113 _status = new wxChoice (panel, wxID_ANY);
114 sizer->Add (_status, 0);
116 _enable_distributor = new wxCheckBox (panel, wxID_ANY, _("Distributor"));
117 sizer->Add (_enable_distributor, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
118 _distributor = new wxTextCtrl (panel, wxID_ANY);
119 sizer->Add (_distributor, 1, wxEXPAND);
122 int flags = wxALIGN_TOP | wxRIGHT | wxTOP;
124 flags |= wxALIGN_RIGHT;
126 auto m = create_label (panel, _("Content versions"), true);
127 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
130 vector<EditableListColumn> columns;
131 columns.push_back (EditableListColumn("Version", 350, true));
132 _content_versions = new EditableList<string, ContentVersionDialog> (
135 boost::bind(&SMPTEMetadataDialog::content_versions, this),
136 boost::bind(&SMPTEMetadataDialog::set_content_versions, this, _1),
137 boost::bind(&content_versions_column, _1, _2),
141 sizer->Add (_content_versions, 1, wxEXPAND);
145 SMPTEMetadataDialog::SMPTEMetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
146 : MetadataDialog (parent, weak_film)
153 SMPTEMetadataDialog::setup ()
155 MetadataDialog::setup ();
157 _status->Append (_("Temporary"));
158 _status->Append (_("Pre-release"));
159 _status->Append (_("Final"));
161 _name_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::name_language_changed, this, _1));
162 _version_number->Bind (wxEVT_SPINCTRL, boost::bind(&SMPTEMetadataDialog::version_number_changed, this));
163 _status->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::status_changed, this));
164 _enable_distributor->Bind (wxEVT_CHECKBOX, boost::bind(&SMPTEMetadataDialog::enable_distributor_changed, this));
165 _distributor->Bind (wxEVT_TEXT, boost::bind(&SMPTEMetadataDialog::distributor_changed, this));
167 film_changed (ChangeType::DONE, Film::Property::NAME_LANGUAGE);
168 film_changed (ChangeType::DONE, Film::Property::VERSION_NUMBER);
169 film_changed (ChangeType::DONE, Film::Property::STATUS);
170 film_changed (ChangeType::DONE, Film::Property::DISTRIBUTOR);
171 film_changed (ChangeType::DONE, Film::Property::CONTENT_VERSIONS);
173 setup_sensitivity ();
178 SMPTEMetadataDialog::film_changed (ChangeType type, Film::Property property)
180 MetadataDialog::film_changed (type, property);
182 if (type != ChangeType::DONE || film()->interop()) {
186 if (property == Film::Property::NAME_LANGUAGE) {
187 _name_language->set (film()->name_language());
188 } else if (property == Film::Property::VERSION_NUMBER) {
189 checked_set (_version_number, film()->version_number());
190 } else if (property == Film::Property::STATUS) {
191 switch (film()->status()) {
192 case dcp::Status::TEMP:
193 checked_set (_status, 0);
195 case dcp::Status::PRE:
196 checked_set (_status, 1);
198 case dcp::Status::FINAL:
199 checked_set (_status, 2);
202 } else if (property == Film::Property::DISTRIBUTOR) {
203 checked_set (_enable_distributor, static_cast<bool>(film()->distributor()));
204 if (film()->distributor()) {
205 checked_set (_distributor, *film()->distributor());
212 SMPTEMetadataDialog::ratings () const
214 return film()->ratings ();
219 SMPTEMetadataDialog::set_ratings (vector<dcp::Rating> r)
221 film()->set_ratings (r);
226 SMPTEMetadataDialog::content_versions () const
228 return film()->content_versions ();
233 SMPTEMetadataDialog::set_content_versions (vector<string> cv)
235 film()->set_content_versions (cv);
240 SMPTEMetadataDialog::name_language_changed (dcp::LanguageTag tag)
242 film()->set_name_language (tag);
247 SMPTEMetadataDialog::version_number_changed ()
249 film()->set_version_number (_version_number->GetValue());
254 SMPTEMetadataDialog::status_changed ()
256 switch (_status->GetSelection()) {
258 film()->set_status(dcp::Status::TEMP);
261 film()->set_status(dcp::Status::PRE);
264 film()->set_status(dcp::Status::FINAL);
271 SMPTEMetadataDialog::distributor_changed ()
273 film()->set_distributor (wx_to_std(_distributor->GetValue()));
278 SMPTEMetadataDialog::setup_sensitivity ()
280 MetadataDialog::setup_sensitivity ();
282 _distributor->Enable (_enable_distributor->GetValue());
287 SMPTEMetadataDialog::enable_distributor_changed ()
289 setup_sensitivity ();
290 if (_enable_distributor->GetValue()) {
291 film()->set_distributor (wx_to_std(_distributor->GetValue()));
293 film()->set_distributor ();