2 Copyright (C) 2019 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/>.
21 #include "interop_metadata_dialog.h"
22 #include "editable_list.h"
23 #include "rating_dialog.h"
25 #include <dcp/types.h>
26 #include <wx/gbsizer.h>
30 using boost::weak_ptr;
31 using boost::shared_ptr;
32 #if BOOST_VERSION >= 106100
33 using namespace boost::placeholders;
38 column (dcp::Rating r, int c)
47 InteropMetadataDialog::InteropMetadataDialog (wxWindow* parent, weak_ptr<Film> film)
48 : wxDialog (parent, wxID_ANY, _("Metadata"))
51 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
52 SetSizer (overall_sizer);
54 wxFlexGridSizer* sizer = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
55 sizer->AddGrowableCol (1, 1);
58 int flags = wxALIGN_TOP | wxLEFT | wxRIGHT | wxTOP;
60 flags |= wxALIGN_RIGHT;
62 wxStaticText* m = create_label (this, _("Ratings"), true);
63 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
66 vector<EditableListColumn> columns;
67 columns.push_back (EditableListColumn(_("Agency"), 200, true));
68 columns.push_back (EditableListColumn(_("Label"), 50, true));
69 _ratings = new EditableList<dcp::Rating, RatingDialog> (
72 boost::bind(&InteropMetadataDialog::ratings, this),
73 boost::bind(&InteropMetadataDialog::set_ratings, this, _1),
74 boost::bind(&column, _1, _2),
78 sizer->Add (_ratings, 1, wxEXPAND);
80 add_label_to_sizer (sizer, this, _("Content version"), true);
81 _content_version = new wxTextCtrl (this, wxID_ANY);
82 sizer->Add (_content_version, 1, wxEXPAND);
84 shared_ptr<Film> f = _film.lock();
86 vector<string> cv = f->content_versions();
87 _content_version->SetValue (std_to_wx(cv.empty() ? "" : cv[0]));
89 overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
91 wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
93 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
96 overall_sizer->Layout ();
97 overall_sizer->SetSizeHints (this);
99 _content_version->Bind (wxEVT_TEXT, boost::bind(&InteropMetadataDialog::content_version_changed, this));
100 _content_version->SetFocus ();
104 InteropMetadataDialog::ratings () const
106 shared_ptr<Film> film = _film.lock ();
107 DCPOMATIC_ASSERT (film);
108 return film->ratings ();
112 InteropMetadataDialog::set_ratings (vector<dcp::Rating> r)
114 shared_ptr<Film> film = _film.lock ();
115 DCPOMATIC_ASSERT (film);
116 film->set_ratings (r);
120 InteropMetadataDialog::content_version_changed ()
122 shared_ptr<Film> film = _film.lock ();
123 DCPOMATIC_ASSERT (film);
125 cv.push_back (wx_to_std(_content_version->GetValue()));
126 film->set_content_versions (cv);