Note that newer libsub version is required.
[dcpomatic.git] / src / wx / metadata_dialog.cc
index e9a3b1af98baefbc2c1cb45c90d00606ae6a38a3..347f2fffd2beebf342e633f5e31f6860a294d9a3 100644 (file)
 #include "region_subtag_widget.h"
 #include "wx_util.h"
 #include "lib/film.h"
+#include "lib/film_property.h"
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/notebook.h>
 #include <wx/spinctrl.h>
 #include <wx/wx.h>
 LIBDCP_ENABLE_WARNINGS
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <boost/weak_ptr.hpp>
 
 
 using std::weak_ptr;
 using std::vector;
 using boost::optional;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 
 
 MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
@@ -102,64 +106,76 @@ MetadataDialog::setup ()
        _enable_luminance->bind(&MetadataDialog::enable_luminance_changed, this);
        _luminance_value->Bind (wxEVT_SPINCTRLDOUBLE, boost::bind(&MetadataDialog::luminance_changed, this));
        _luminance_unit->Bind (wxEVT_CHOICE, boost::bind(&MetadataDialog::luminance_changed, this));
+       _territory_type->bind(&MetadataDialog::territory_type_changed, this);
 
        _film_changed_connection = film()->Change.connect(boost::bind(&MetadataDialog::film_changed, this, _1, _2));
 
-       film_changed (ChangeType::DONE, Film::Property::RELEASE_TERRITORY);
-       film_changed (ChangeType::DONE, Film::Property::SIGN_LANGUAGE_VIDEO_LANGUAGE);
-       film_changed (ChangeType::DONE, Film::Property::FACILITY);
-       film_changed (ChangeType::DONE, Film::Property::STUDIO);
-       film_changed (ChangeType::DONE, Film::Property::TEMP_VERSION);
-       film_changed (ChangeType::DONE, Film::Property::PRE_RELEASE);
-       film_changed (ChangeType::DONE, Film::Property::RED_BAND);
-       film_changed (ChangeType::DONE, Film::Property::TWO_D_VERSION_OF_THREE_D);
-       film_changed (ChangeType::DONE, Film::Property::CHAIN);
-       film_changed (ChangeType::DONE, Film::Property::LUMINANCE);
+       film_changed(ChangeType::DONE, FilmProperty::RELEASE_TERRITORY);
+       film_changed(ChangeType::DONE, FilmProperty::SIGN_LANGUAGE_VIDEO_LANGUAGE);
+       film_changed(ChangeType::DONE, FilmProperty::FACILITY);
+       film_changed(ChangeType::DONE, FilmProperty::STUDIO);
+       film_changed(ChangeType::DONE, FilmProperty::TEMP_VERSION);
+       film_changed(ChangeType::DONE, FilmProperty::PRE_RELEASE);
+       film_changed(ChangeType::DONE, FilmProperty::RED_BAND);
+       film_changed(ChangeType::DONE, FilmProperty::TWO_D_VERSION_OF_THREE_D);
+       film_changed(ChangeType::DONE, FilmProperty::CHAIN);
+       film_changed(ChangeType::DONE, FilmProperty::LUMINANCE);
+       film_changed(ChangeType::DONE, FilmProperty::TERRITORY_TYPE);
 
        setup_sensitivity ();
 }
 
 
 void
-MetadataDialog::film_changed (ChangeType type, Film::Property property)
+MetadataDialog::territory_type_changed()
+{
+       auto data = _territory_type->get_data();
+       if (data) {
+               film()->set_territory_type(string_to_territory_type(wx_to_std(data->data())));
+       }
+}
+
+
+void
+MetadataDialog::film_changed(ChangeType type, FilmProperty property)
 {
        if (type != ChangeType::DONE) {
                return;
        }
 
-       if (property == Film::Property::SIGN_LANGUAGE_VIDEO_LANGUAGE) {
+       if (property == FilmProperty::SIGN_LANGUAGE_VIDEO_LANGUAGE) {
                _sign_language_video_language->set (film()->sign_language_video_language());
-       } else if (property == Film::Property::RELEASE_TERRITORY) {
+       } else if (property == FilmProperty::RELEASE_TERRITORY) {
                auto rt = film()->release_territory();
                checked_set (_enable_release_territory, static_cast<bool>(rt));
                if (rt) {
                        _release_territory_copy = *rt;
                        checked_set(_release_territory, *_release_territory_copy);
                }
-       } else if (property == Film::Property::FACILITY) {
+       } else if (property == FilmProperty::FACILITY) {
                checked_set (_enable_facility, static_cast<bool>(film()->facility()));
                if (film()->facility()) {
                        checked_set (_facility, *film()->facility());
                }
-       } else if (property == Film::Property::STUDIO) {
+       } else if (property == FilmProperty::STUDIO) {
                checked_set (_enable_studio, static_cast<bool>(film()->studio()));
                if (film()->studio()) {
                        checked_set (_studio, *film()->studio());
                }
-       } else if (property == Film::Property::CHAIN) {
+       } else if (property == FilmProperty::CHAIN) {
                checked_set (_enable_chain, static_cast<bool>(film()->chain()));
                if (film()->chain()) {
                        checked_set (_chain, *film()->chain());
                }
-       } else if (property == Film::Property::TEMP_VERSION) {
+       } else if (property == FilmProperty::TEMP_VERSION) {
                checked_set (_temp_version, film()->temp_version());
-       } else if (property == Film::Property::PRE_RELEASE) {
+       } else if (property == FilmProperty::PRE_RELEASE) {
                checked_set (_pre_release, film()->pre_release());
-       } else if (property == Film::Property::RED_BAND) {
+       } else if (property == FilmProperty::RED_BAND) {
                checked_set (_red_band, film()->red_band());
-       } else if (property == Film::Property::TWO_D_VERSION_OF_THREE_D) {
+       } else if (property == FilmProperty::TWO_D_VERSION_OF_THREE_D) {
                checked_set (_two_d_version_of_three_d, film()->two_d_version_of_three_d());
-       } else if (property == Film::Property::LUMINANCE) {
+       } else if (property == FilmProperty::LUMINANCE) {
                auto lum = film()->luminance();
                checked_set (_enable_luminance, static_cast<bool>(lum));
                if (lum) {
@@ -176,6 +192,9 @@ MetadataDialog::film_changed (ChangeType type, Film::Property property)
                        checked_set(_luminance_value, 14);
                        checked_set (_luminance_unit, 1);
                }
+       } else if (property == FilmProperty::TERRITORY_TYPE) {
+               _territory_type->set_by_data(territory_type_to_string(film()->territory_type()));
+               setup_sensitivity();
        }
 }
 
@@ -183,6 +202,13 @@ MetadataDialog::film_changed (ChangeType type, Film::Property property)
 void
 MetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer)
 {
+       add_label_to_sizer(sizer, panel, _("Territory type"), true, 0, wxALIGN_CENTER_VERTICAL);
+       _territory_type = new Choice(panel);
+       _territory_type->add(_("Specific"), wx_to_std(territory_type_to_string(TerritoryType::SPECIFIC)));
+       _territory_type->add(_("International texted"), wx_to_std(territory_type_to_string(TerritoryType::INTERNATIONAL_TEXTED)));
+       _territory_type->add(_("International textless"), wx_to_std(territory_type_to_string(TerritoryType::INTERNATIONAL_TEXTLESS)));
+       sizer->Add(_territory_type);
+
        _enable_release_territory = new CheckBox(panel, _("Release territory"));
        sizer->Add (_enable_release_territory, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
        _release_territory = new RegionSubtagWidget(panel, _("Release territory for this DCP"), film()->release_territory());
@@ -226,9 +252,12 @@ MetadataDialog::release_territory_changed(optional<dcp::LanguageTag::RegionSubta
 void
 MetadataDialog::setup_sensitivity ()
 {
+       auto const territory_type = film()->territory_type();
+       _enable_release_territory->Enable(territory_type == TerritoryType::SPECIFIC);
        _sign_language_video_language->enable (film()->has_sign_language_video_channel());
        auto const enabled = _enable_release_territory->GetValue();
-       _release_territory->enable(enabled);
+       _release_territory->enable(enabled && territory_type == TerritoryType::SPECIFIC);
+       _ratings->Enable(territory_type == TerritoryType::SPECIFIC);
        _facility->Enable (_enable_facility->GetValue());
        _chain->Enable (_enable_chain->GetValue());
        _studio->Enable (_enable_studio->GetValue());