abc95c3c15c57f5ae28c7091956a89faa2602640
[dcpomatic.git] / src / wx / metadata_dialog.cc
1 /*
2     Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21
22 #include "metadata_dialog.h"
23 #include "wx_util.h"
24 #include "lib/film.h"
25 #include <boost/bind.hpp>
26 #include <boost/weak_ptr.hpp>
27 #include <wx/notebook.h>
28 #include <wx/wx.h>
29
30
31 using std::weak_ptr;
32
33
34 MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
35         : wxDialog (parent, wxID_ANY, _("Metadata"))
36         , WeakFilm (weak_film)
37 {
38
39 }
40
41
42 void
43 MetadataDialog::setup ()
44 {
45         auto notebook = new wxNotebook (this, wxID_ANY);
46
47         auto prepare = [notebook](std::function<void (wxPanel*, wxSizer*)> setup, wxString name) {
48                 auto panel = new wxPanel (notebook, wxID_ANY);
49                 auto sizer = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
50                 sizer->AddGrowableCol (1, 1);
51                 setup (panel, sizer);
52                 auto overall_sizer = new wxBoxSizer (wxVERTICAL);
53                 overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
54                 panel->SetSizer (overall_sizer);
55                 notebook->AddPage (panel, name);
56         };
57
58         prepare (boost::bind(&MetadataDialog::setup_standard, this, _1, _2), _("Standard"));
59         prepare (boost::bind(&MetadataDialog::setup_advanced, this, _1, _2), _("Advanced"));
60
61         auto overall_sizer = new wxBoxSizer (wxVERTICAL);
62         overall_sizer->Add (notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
63
64         auto buttons = CreateSeparatedButtonSizer (wxCLOSE);
65         if (buttons) {
66                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
67         }
68
69         SetSizer (overall_sizer);
70         overall_sizer->Layout ();
71         overall_sizer->SetSizeHints (this);
72 }
73