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 "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;
34 column (dcp::Rating r, int c)
43 MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> film)
44 : wxDialog (parent, wxID_ANY, _("Metadata"))
47 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
48 SetSizer (overall_sizer);
50 wxFlexGridSizer* sizer = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
51 sizer->AddGrowableCol (1, 1);
54 int flags = wxALIGN_TOP | wxLEFT | wxRIGHT | wxTOP;
56 flags |= wxALIGN_RIGHT;
58 wxStaticText* m = create_label (this, _("Ratings"), true);
59 sizer->Add (m, 0, flags, DCPOMATIC_SIZER_GAP);
62 vector<EditableListColumn> columns;
63 columns.push_back (EditableListColumn("Agency", 200, true));
64 columns.push_back (EditableListColumn("Label", 50, false));
65 _ratings = new EditableList<dcp::Rating, RatingDialog> (
68 boost::bind(&MetadataDialog::ratings, this),
69 boost::bind(&MetadataDialog::set_ratings, this, _1),
70 boost::bind(&column, _1, _2),
74 sizer->Add (_ratings, 1, wxEXPAND);
76 overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
78 wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
80 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
83 overall_sizer->Layout ();
84 overall_sizer->SetSizeHints (this);
88 MetadataDialog::ratings () const
90 shared_ptr<Film> film = _film.lock ();
91 DCPOMATIC_ASSERT (film);
92 return film->ratings ();
96 MetadataDialog::set_ratings (vector<dcp::Rating> r)
98 shared_ptr<Film> film = _film.lock ();
99 DCPOMATIC_ASSERT (film);
100 film->set_ratings (r);