/* Copyright (C) 2019-2021 Carl Hetherington This file is part of DCP-o-matic. DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DCP-o-matic. If not, see . */ #include "check_box.h" #include "content_version_dialog.h" #include "editable_list.h" #include "language_tag_dialog.h" #include "language_tag_widget.h" #include "rating_dialog.h" #include "smpte_metadata_dialog.h" #include "lib/film.h" #include #include LIBDCP_DISABLE_WARNINGS #include #include LIBDCP_ENABLE_WARNINGS using std::shared_ptr; using std::string; using std::vector; using std::weak_ptr; using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif static string content_versions_column (string v, int) { return v; } void SMPTEMetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer) { MetadataDialog::setup_standard (panel, sizer); add_label_to_sizer (sizer, panel, _("Title language"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL); _name_language = new LanguageTagWidget( panel, wxString::Format(_("The language that the film's title (\"%s\") is in"), std_to_wx(film()->name())), film()->name_language() ); sizer->Add (_name_language->sizer(), 0, wxEXPAND); { int flags = wxALIGN_TOP | wxRIGHT | wxTOP; #ifdef __WXOSX__ flags |= wxALIGN_RIGHT; #endif auto m = create_label (panel, _("Ratings"), true); sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP); } sizer->Add (_ratings, 1, wxEXPAND); } void SMPTEMetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer) { MetadataDialog::setup_advanced (panel, sizer); add_label_to_sizer (sizer, panel, _("Version number"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL); _version_number = new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000); sizer->Add (_version_number, 0); add_label_to_sizer (sizer, panel, _("Status"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL); _status = new wxChoice (panel, wxID_ANY); sizer->Add (_status, 0); _enable_distributor = new CheckBox(panel, _("Distributor")); sizer->Add (_enable_distributor, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL); _distributor = new wxTextCtrl (panel, wxID_ANY); sizer->Add (_distributor, 1, wxEXPAND); { int flags = wxALIGN_TOP | wxRIGHT | wxTOP; #ifdef __WXOSX__ flags |= wxALIGN_RIGHT; #endif auto m = create_label (panel, _("Content versions"), true); sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP); } vector columns; columns.push_back(EditableListColumn(_("Version"), 350, true)); _content_versions = new EditableList ( panel, columns, boost::bind(&SMPTEMetadataDialog::content_versions, this), boost::bind(&SMPTEMetadataDialog::set_content_versions, this, _1), EditableList::add_with_dialog, EditableList::edit_with_dialog, boost::bind(&content_versions_column, _1, _2), EditableListTitle::INVISIBLE, EditableListButton::NEW | EditableListButton::REMOVE ); sizer->Add (_content_versions, 1, wxEXPAND); } SMPTEMetadataDialog::SMPTEMetadataDialog (wxWindow* parent, weak_ptr weak_film) : MetadataDialog (parent, weak_film) { } void SMPTEMetadataDialog::setup () { MetadataDialog::setup (); _status->Append (_("Temporary")); _status->Append (_("Pre-release")); _status->Append (_("Final")); _name_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::name_language_changed, this, _1)); _version_number->Bind (wxEVT_SPINCTRL, boost::bind(&SMPTEMetadataDialog::version_number_changed, this)); _status->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::status_changed, this)); _enable_distributor->bind(&SMPTEMetadataDialog::enable_distributor_changed, this); _distributor->Bind (wxEVT_TEXT, boost::bind(&SMPTEMetadataDialog::distributor_changed, this)); film_changed(ChangeType::DONE, FilmProperty::NAME_LANGUAGE); film_changed(ChangeType::DONE, FilmProperty::VERSION_NUMBER); film_changed(ChangeType::DONE, FilmProperty::STATUS); film_changed(ChangeType::DONE, FilmProperty::DISTRIBUTOR); film_changed(ChangeType::DONE, FilmProperty::CONTENT_VERSIONS); setup_sensitivity (); } void SMPTEMetadataDialog::film_changed(ChangeType type, FilmProperty property) { MetadataDialog::film_changed (type, property); if (type != ChangeType::DONE || film()->interop()) { return; } if (property == FilmProperty::NAME_LANGUAGE) { _name_language->set (film()->name_language()); } else if (property == FilmProperty::VERSION_NUMBER) { checked_set (_version_number, film()->version_number()); } else if (property == FilmProperty::STATUS) { switch (film()->status()) { case dcp::Status::TEMP: checked_set (_status, 0); break; case dcp::Status::PRE: checked_set (_status, 1); break; case dcp::Status::FINAL: checked_set (_status, 2); break; } } else if (property == FilmProperty::DISTRIBUTOR) { checked_set (_enable_distributor, static_cast(film()->distributor())); if (film()->distributor()) { checked_set (_distributor, *film()->distributor()); } } } vector SMPTEMetadataDialog::content_versions () const { return film()->content_versions (); } void SMPTEMetadataDialog::set_content_versions (vector cv) { film()->set_content_versions (cv); } void SMPTEMetadataDialog::name_language_changed (dcp::LanguageTag tag) { film()->set_name_language (tag); } void SMPTEMetadataDialog::version_number_changed () { film()->set_version_number (_version_number->GetValue()); } void SMPTEMetadataDialog::status_changed () { switch (_status->GetSelection()) { case 0: film()->set_status(dcp::Status::TEMP); break; case 1: film()->set_status(dcp::Status::PRE); break; case 2: film()->set_status(dcp::Status::FINAL); break; } } void SMPTEMetadataDialog::distributor_changed () { film()->set_distributor (wx_to_std(_distributor->GetValue())); } void SMPTEMetadataDialog::setup_sensitivity () { MetadataDialog::setup_sensitivity (); _distributor->Enable (_enable_distributor->GetValue()); } void SMPTEMetadataDialog::enable_distributor_changed () { setup_sensitivity (); if (_enable_distributor->GetValue()) { film()->set_distributor (wx_to_std(_distributor->GetValue())); } else { film()->set_distributor (); } }