Inherit SMPTEMetadataDialog from a base class.
authorCarl Hetherington <cth@carlh.net>
Fri, 2 Apr 2021 19:59:51 +0000 (21:59 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 4 Apr 2021 18:48:34 +0000 (20:48 +0200)
src/wx/dcp_panel.cc
src/wx/metadata_dialog.cc [new file with mode: 0644]
src/wx/metadata_dialog.h [new file with mode: 0644]
src/wx/smpte_metadata_dialog.cc
src/wx/smpte_metadata_dialog.h
src/wx/wscript

index 6a5b27b18dbfea75f12f85b9c22a96905b0b3abf..dcb78dc93f8e6b6283839825822a9bbf0fdd7bd0 100644 (file)
@@ -331,6 +331,7 @@ DCPPanel::metadata_clicked ()
                }
 
                _smpte_metadata_dialog = new SMPTEMetadataDialog (_panel, _film);
+               _smpte_metadata_dialog->setup ();
                _smpte_metadata_dialog->Show ();
        }
 }
diff --git a/src/wx/metadata_dialog.cc b/src/wx/metadata_dialog.cc
new file mode 100644 (file)
index 0000000..abc95c3
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+    Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "metadata_dialog.h"
+#include "wx_util.h"
+#include "lib/film.h"
+#include <boost/bind.hpp>
+#include <boost/weak_ptr.hpp>
+#include <wx/notebook.h>
+#include <wx/wx.h>
+
+
+using std::weak_ptr;
+
+
+MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
+       : wxDialog (parent, wxID_ANY, _("Metadata"))
+       , WeakFilm (weak_film)
+{
+
+}
+
+
+void
+MetadataDialog::setup ()
+{
+       auto notebook = new wxNotebook (this, wxID_ANY);
+
+       auto prepare = [notebook](std::function<void (wxPanel*, wxSizer*)> setup, wxString name) {
+               auto panel = new wxPanel (notebook, wxID_ANY);
+               auto sizer = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+               sizer->AddGrowableCol (1, 1);
+               setup (panel, sizer);
+               auto overall_sizer = new wxBoxSizer (wxVERTICAL);
+               overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+               panel->SetSizer (overall_sizer);
+               notebook->AddPage (panel, name);
+       };
+
+       prepare (boost::bind(&MetadataDialog::setup_standard, this, _1, _2), _("Standard"));
+       prepare (boost::bind(&MetadataDialog::setup_advanced, this, _1, _2), _("Advanced"));
+
+       auto overall_sizer = new wxBoxSizer (wxVERTICAL);
+       overall_sizer->Add (notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+
+       auto buttons = CreateSeparatedButtonSizer (wxCLOSE);
+       if (buttons) {
+               overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+       }
+
+       SetSizer (overall_sizer);
+       overall_sizer->Layout ();
+       overall_sizer->SetSizeHints (this);
+}
+
diff --git a/src/wx/metadata_dialog.h b/src/wx/metadata_dialog.h
new file mode 100644 (file)
index 0000000..ef5dd06
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+    Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/warnings.h"
+#include "lib/weak_film.h"
+DCPOMATIC_DISABLE_WARNINGS
+#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
+
+
+class MetadataDialog : public wxDialog, public WeakFilm
+{
+public:
+       MetadataDialog (wxWindow* parent, std::weak_ptr<Film> film);
+
+       virtual void setup ();
+
+protected:
+       virtual void setup_standard (wxPanel*, wxSizer*) {}
+       virtual void setup_advanced (wxPanel*, wxSizer*) {}
+};
index 464da6710b71ecc4f4cc57204b1987e2e98065db..a2e9d355adf5bab34c8e6c432ff76b1434707f13 100644 (file)
@@ -28,7 +28,6 @@
 #include "lib/film.h"
 #include <dcp/types.h>
 #include <wx/gbsizer.h>
-#include <wx/notebook.h>
 #include <wx/spinctrl.h>
 
 
@@ -60,13 +59,10 @@ content_versions_column (string v, int)
 }
 
 
-wxPanel *
-SMPTEMetadataDialog::main_panel (wxWindow* parent)
+void
+SMPTEMetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer)
 {
-       auto panel = new wxPanel (parent, wxID_ANY);
-
-       auto sizer = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       sizer->AddGrowableCol (1, 1);
+       MetadataDialog::setup_standard (panel, sizer);
 
        add_label_to_sizer (sizer, panel, _("Title language"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
        _name_language = new LanguageTagWidget(
@@ -98,22 +94,13 @@ SMPTEMetadataDialog::main_panel (wxWindow* parent)
                false
                );
        sizer->Add (_ratings, 1, wxEXPAND);
-
-       auto overall_sizer = new wxBoxSizer (wxVERTICAL);
-       overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-       panel->SetSizer (overall_sizer);
-
-       return panel;
 }
 
 
-wxPanel *
-SMPTEMetadataDialog::advanced_panel (wxWindow* parent)
+void
+SMPTEMetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer)
 {
-       auto panel = new wxPanel (parent, wxID_ANY);
-
-       auto sizer = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       sizer->AddGrowableCol (1, 1);
+       MetadataDialog::setup_advanced (panel, sizer);
 
        _enable_release_territory = new wxCheckBox (panel, wxID_ANY, _("Release territory"));
        sizer->Add (_enable_release_territory, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
@@ -182,34 +169,20 @@ SMPTEMetadataDialog::advanced_panel (wxWindow* parent)
                false
                );
        sizer->Add (_content_versions, 1, wxEXPAND);
-
-       auto overall_sizer = new wxBoxSizer (wxVERTICAL);
-       overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-       panel->SetSizer (overall_sizer);
-
-       return panel;
 }
 
 
 SMPTEMetadataDialog::SMPTEMetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
-       : wxDialog (parent, wxID_ANY, _("Metadata"))
-       , WeakFilm (weak_film)
+       : MetadataDialog (parent, weak_film)
 {
-       auto notebook = new wxNotebook (this, wxID_ANY);
-       notebook->AddPage (main_panel(notebook), _("Standard"));
-       notebook->AddPage (advanced_panel(notebook), _("Advanced"));
 
-       auto overall_sizer = new wxBoxSizer (wxVERTICAL);
-       overall_sizer->Add (notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+}
 
-       auto buttons = CreateSeparatedButtonSizer (wxCLOSE);
-       if (buttons) {
-               overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
-       }
 
-       SetSizer (overall_sizer);
-       overall_sizer->Layout ();
-       overall_sizer->SetSizeHints (this);
+void
+SMPTEMetadataDialog::setup ()
+{
+       MetadataDialog::setup ();
 
        _status->Append (_("Temporary"));
        _status->Append (_("Pre-release"));
@@ -232,8 +205,6 @@ SMPTEMetadataDialog::SMPTEMetadataDialog (wxWindow* parent, weak_ptr<Film> weak_
        _luminance_unit->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::luminance_changed, this));
        _enable_release_territory->Bind (wxEVT_CHECKBOX, boost::bind(&SMPTEMetadataDialog::enable_release_territory_changed, this));
 
-       _version_number->SetFocus ();
-
        _film_changed_connection = film()->Change.connect(boost::bind(&SMPTEMetadataDialog::film_changed, this, _1, _2));
 
        film_changed (ChangeType::DONE, Film::Property::NAME_LANGUAGE);
index 46272adbb17b433606a42e067fcc4a5b212c6b07..e27401e87531bcb0ddcab9ac8fa6fadf871b915f 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "editable_list.h"
 #include "full_language_tag_dialog.h"
+#include "metadata_dialog.h"
 #include "lib/film.h"
 #include "lib/weak_film.h"
 #include <dcp/language_tag.h>
@@ -36,14 +37,17 @@ class LanguageTagWidget;
 class LanguageTagDialog;
 
 
-class SMPTEMetadataDialog : public wxDialog, public WeakFilm
+class SMPTEMetadataDialog : public MetadataDialog
 {
 public:
        SMPTEMetadataDialog (wxWindow* parent, std::weak_ptr<Film> film);
 
+       void setup () override;
+
 private:
-       wxPanel* main_panel (wxWindow* parent);
-       wxPanel* advanced_panel (wxWindow* parent);
+       void setup_standard (wxPanel* parent, wxSizer* sizer) override;
+       void setup_advanced (wxPanel* parent, wxSizer* sizer) override;
+
        std::vector<dcp::Rating> ratings () const;
        void set_ratings (std::vector<dcp::Rating> r);
        std::vector<std::string> content_versions () const;
index 76eea3fa5363d713aeb7aca928deb69659be1d12..013377e1658fe8b05e60a60d59688437313c8936 100644 (file)
@@ -99,6 +99,7 @@ sources = """
           make_chain_dialog.cc
           markers_dialog.cc
           message_dialog.cc
+          metadata_dialog.cc
           monitor_dialog.cc
           move_to_dialog.cc
           nag_dialog.cc