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 "check_box.h"
23 #include "content_version_dialog.h"
24 #include "editable_list.h"
25 #include "language_tag_dialog.h"
26 #include "language_tag_widget.h"
27 #include "rating_dialog.h"
28 #include "smpte_metadata_dialog.h"
30 #include <dcp/types.h>
31 #include <dcp/warnings.h>
32 LIBDCP_DISABLE_WARNINGS
33 #include <wx/gbsizer.h>
34 #include <wx/spinctrl.h>
35 LIBDCP_ENABLE_WARNINGS
38 using std::shared_ptr;
42 using boost::optional;
43 #if BOOST_VERSION >= 106100
44 using namespace boost::placeholders;
49 content_versions_column (string v, int)
56 SMPTEMetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer)
58 MetadataDialog::setup_standard (panel, sizer);
60 add_label_to_sizer (sizer, panel, _("Title language"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
61 _name_language = new LanguageTagWidget(
63 wxString::Format(_("The language that the film's title (\"%s\") is in"), std_to_wx(film()->name())),
64 film()->name_language()
66 sizer->Add (_name_language->sizer(), 0, wxEXPAND);
69 int flags = wxALIGN_TOP | wxRIGHT | wxTOP;
71 flags |= wxALIGN_RIGHT;
73 auto m = create_label (panel, _("Ratings"), true);
74 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
77 sizer->Add (_ratings, 1, wxEXPAND);
82 SMPTEMetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer)
84 MetadataDialog::setup_advanced (panel, sizer);
86 add_label_to_sizer (sizer, panel, _("Version number"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
87 _version_number = new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000);
88 sizer->Add (_version_number, 0);
90 add_label_to_sizer (sizer, panel, _("Status"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
91 _status = new wxChoice (panel, wxID_ANY);
92 sizer->Add (_status, 0);
94 _enable_distributor = new CheckBox(panel, _("Distributor"));
95 sizer->Add (_enable_distributor, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
96 _distributor = new wxTextCtrl (panel, wxID_ANY);
97 sizer->Add (_distributor, 1, wxEXPAND);
100 int flags = wxALIGN_TOP | wxRIGHT | wxTOP;
102 flags |= wxALIGN_RIGHT;
104 auto m = create_label (panel, _("Content versions"), true);
105 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
108 vector<EditableListColumn> columns;
109 columns.push_back (EditableListColumn("Version", 350, true));
110 _content_versions = new EditableList<string, ContentVersionDialog> (
113 boost::bind(&SMPTEMetadataDialog::content_versions, this),
114 boost::bind(&SMPTEMetadataDialog::set_content_versions, this, _1),
115 boost::bind(&content_versions_column, _1, _2),
116 EditableListTitle::INVISIBLE,
117 EditableListButton::NEW | EditableListButton::REMOVE
119 sizer->Add (_content_versions, 1, wxEXPAND);
123 SMPTEMetadataDialog::SMPTEMetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
124 : MetadataDialog (parent, weak_film)
131 SMPTEMetadataDialog::setup ()
133 MetadataDialog::setup ();
135 _status->Append (_("Temporary"));
136 _status->Append (_("Pre-release"));
137 _status->Append (_("Final"));
139 _name_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::name_language_changed, this, _1));
140 _version_number->Bind (wxEVT_SPINCTRL, boost::bind(&SMPTEMetadataDialog::version_number_changed, this));
141 _status->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::status_changed, this));
142 _enable_distributor->bind(&SMPTEMetadataDialog::enable_distributor_changed, this);
143 _distributor->Bind (wxEVT_TEXT, boost::bind(&SMPTEMetadataDialog::distributor_changed, this));
145 film_changed(ChangeType::DONE, FilmProperty::NAME_LANGUAGE);
146 film_changed(ChangeType::DONE, FilmProperty::VERSION_NUMBER);
147 film_changed(ChangeType::DONE, FilmProperty::STATUS);
148 film_changed(ChangeType::DONE, FilmProperty::DISTRIBUTOR);
149 film_changed(ChangeType::DONE, FilmProperty::CONTENT_VERSIONS);
151 setup_sensitivity ();
156 SMPTEMetadataDialog::film_changed(ChangeType type, FilmProperty property)
158 MetadataDialog::film_changed (type, property);
160 if (type != ChangeType::DONE || film()->interop()) {
164 if (property == FilmProperty::NAME_LANGUAGE) {
165 _name_language->set (film()->name_language());
166 } else if (property == FilmProperty::VERSION_NUMBER) {
167 checked_set (_version_number, film()->version_number());
168 } else if (property == FilmProperty::STATUS) {
169 switch (film()->status()) {
170 case dcp::Status::TEMP:
171 checked_set (_status, 0);
173 case dcp::Status::PRE:
174 checked_set (_status, 1);
176 case dcp::Status::FINAL:
177 checked_set (_status, 2);
180 } else if (property == FilmProperty::DISTRIBUTOR) {
181 checked_set (_enable_distributor, static_cast<bool>(film()->distributor()));
182 if (film()->distributor()) {
183 checked_set (_distributor, *film()->distributor());
190 SMPTEMetadataDialog::content_versions () const
192 return film()->content_versions ();
197 SMPTEMetadataDialog::set_content_versions (vector<string> cv)
199 film()->set_content_versions (cv);
204 SMPTEMetadataDialog::name_language_changed (dcp::LanguageTag tag)
206 film()->set_name_language (tag);
211 SMPTEMetadataDialog::version_number_changed ()
213 film()->set_version_number (_version_number->GetValue());
218 SMPTEMetadataDialog::status_changed ()
220 switch (_status->GetSelection()) {
222 film()->set_status(dcp::Status::TEMP);
225 film()->set_status(dcp::Status::PRE);
228 film()->set_status(dcp::Status::FINAL);
235 SMPTEMetadataDialog::distributor_changed ()
237 film()->set_distributor (wx_to_std(_distributor->GetValue()));
242 SMPTEMetadataDialog::setup_sensitivity ()
244 MetadataDialog::setup_sensitivity ();
246 _distributor->Enable (_enable_distributor->GetValue());
251 SMPTEMetadataDialog::enable_distributor_changed ()
253 setup_sensitivity ();
254 if (_enable_distributor->GetValue()) {
255 film()->set_distributor (wx_to_std(_distributor->GetValue()));
257 film()->set_distributor ();