Display the rating agency name rather than the URL (if we have it).
[dcpomatic.git] / src / wx / metadata_dialog.cc
index 6054e3abcf26e476955f98efc35d25647917880e..b1c58a27e96616b0c4a92a80046a7e96263bc494 100644 (file)
 
 
 #include "dcpomatic_button.h"
+#include "editable_list.h"
 #include "full_language_tag_dialog.h"
+#include "language_tag_widget.h"
 #include "metadata_dialog.h"
+#include "rating_dialog.h"
 #include "wx_util.h"
 #include "lib/film.h"
-#include <boost/bind.hpp>
-#include <boost/weak_ptr.hpp>
+#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/weak_ptr.hpp>
 
 
 using std::weak_ptr;
+using std::vector;
 
 
 MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
        : wxDialog (parent, wxID_ANY, _("Metadata"))
        , WeakFilm (weak_film)
 {
-
+       for (auto system: dcp::rating_systems()) {
+               _rating_system_agency_to_name[system.agency] = system.name;
+       }
 }
 
 
@@ -73,6 +82,7 @@ MetadataDialog::setup ()
        overall_sizer->Layout ();
        overall_sizer->SetSizeHints (this);
 
+       _sign_language_video_language->Changed.connect (boost::bind(&MetadataDialog::sign_language_video_language_changed, this));
        _edit_release_territory->Bind (wxEVT_BUTTON, boost::bind(&MetadataDialog::edit_release_territory, this));
        _enable_release_territory->Bind (wxEVT_CHECKBOX, boost::bind(&MetadataDialog::enable_release_territory_changed, this));
        _enable_facility->Bind (wxEVT_CHECKBOX, boost::bind(&MetadataDialog::enable_facility_changed, this));
@@ -92,6 +102,7 @@ MetadataDialog::setup ()
        _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);
@@ -112,7 +123,9 @@ MetadataDialog::film_changed (ChangeType type, Film::Property property)
                return;
        }
 
-       if (property == Film::Property::RELEASE_TERRITORY) {
+       if (property == Film::Property::SIGN_LANGUAGE_VIDEO_LANGUAGE) {
+               _sign_language_video_language->set (film()->sign_language_video_language());
+       } else if (property == Film::Property::RELEASE_TERRITORY) {
                auto rt = film()->release_territory();
                checked_set (_enable_release_territory, static_cast<bool>(rt));
                if (rt) {
@@ -175,6 +188,29 @@ MetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer)
                s->Add (_edit_release_territory, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
                sizer->Add (s, 0, wxEXPAND);
        }
+
+       vector<EditableListColumn> columns;
+       columns.push_back(EditableListColumn("Agency", 200, true));
+       columns.push_back(EditableListColumn("Label", 400, true));
+       _ratings = new EditableList<dcp::Rating, RatingDialog> (
+               panel,
+               columns,
+               boost::bind(&MetadataDialog::ratings, this),
+               boost::bind(&MetadataDialog::set_ratings, this, _1),
+               [this](dcp::Rating r, int c) {
+                       if (c == 0) {
+                               auto iter = _rating_system_agency_to_name.find(r.agency);
+                               if (iter != _rating_system_agency_to_name.end()) {
+                                       return iter->second;
+                               }
+                               return r.agency;
+                       }
+                       return r.label;
+               },
+               true,
+               EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE
+               );
+       _ratings->SetMinSize(wxSize(600, -1));
 }
 
 
@@ -196,6 +232,7 @@ MetadataDialog::edit_release_territory ()
 void
 MetadataDialog::setup_sensitivity ()
 {
+       _sign_language_video_language->enable (film()->has_sign_language_video_channel());
        auto const enabled = _enable_release_territory->GetValue();
        _release_territory_text->Enable (enabled);
        _edit_release_territory->Enable (enabled);
@@ -222,6 +259,10 @@ MetadataDialog::enable_release_territory_changed ()
 void
 MetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer)
 {
+       add_label_to_sizer (sizer, panel, _("Sign language video language"), true, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT);
+       _sign_language_video_language = new LanguageTagWidget (panel, _("Language used for any sign language video track"), {}, {});
+       sizer->Add (_sign_language_video_language->sizer(), 1, wxEXPAND);
+
        _enable_facility = new wxCheckBox (panel, wxID_ANY, _("Facility"));
        sizer->Add (_enable_facility, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
        _facility = new wxTextCtrl (panel, wxID_ANY);
@@ -258,6 +299,7 @@ MetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer)
        {
                auto s = new wxBoxSizer (wxHORIZONTAL);
                _luminance_value = new wxSpinCtrlDouble (panel, wxID_ANY);
+               _luminance_value->SetRange (0.1, 32.0);
                _luminance_value->SetDigits (1);
                _luminance_value->SetIncrement (0.1);
                s->Add (_luminance_value, 0);
@@ -266,7 +308,7 @@ MetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer)
                sizer->Add (s, 1, wxEXPAND);
        }
 
-       _luminance_unit->Append (wxString::FromUTF8(_("candela per m²")));
+       _luminance_unit->Append (_("candela per m²"));
        _luminance_unit->Append (_("foot lambert"));
 
 }
@@ -387,3 +429,24 @@ MetadataDialog::luminance_changed ()
        film()->set_luminance (dcp::Luminance(_luminance_value->GetValue(), unit));
 }
 
+
+void
+MetadataDialog::sign_language_video_language_changed ()
+{
+       film()->set_sign_language_video_language(_sign_language_video_language->get());
+}
+
+
+vector<dcp::Rating>
+MetadataDialog::ratings() const
+{
+       return film()->ratings();
+}
+
+
+void
+MetadataDialog::set_ratings(vector<dcp::Rating> r)
+{
+       film()->set_ratings(r);
+}
+