From 60520afb4a6bb364c981c2b6976805d4128ac81f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 2 Apr 2021 21:59:51 +0200 Subject: [PATCH] Inherit SMPTEMetadataDialog from a base class. --- src/wx/dcp_panel.cc | 1 + src/wx/metadata_dialog.cc | 73 +++++++++++++++++++++++++++++++++ src/wx/metadata_dialog.h | 39 ++++++++++++++++++ src/wx/smpte_metadata_dialog.cc | 53 ++++++------------------ src/wx/smpte_metadata_dialog.h | 10 +++-- src/wx/wscript | 1 + 6 files changed, 133 insertions(+), 44 deletions(-) create mode 100644 src/wx/metadata_dialog.cc create mode 100644 src/wx/metadata_dialog.h diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 6a5b27b18..dcb78dc93 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -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 index 000000000..abc95c3c1 --- /dev/null +++ b/src/wx/metadata_dialog.cc @@ -0,0 +1,73 @@ +/* + Copyright (C) 2021 Carl Hetherington + + 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 . + +*/ + + +#include "metadata_dialog.h" +#include "wx_util.h" +#include "lib/film.h" +#include +#include +#include +#include + + +using std::weak_ptr; + + +MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr 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 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 index 000000000..ef5dd0687 --- /dev/null +++ b/src/wx/metadata_dialog.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2021 Carl Hetherington + + 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 . + +*/ + + +#include "lib/warnings.h" +#include "lib/weak_film.h" +DCPOMATIC_DISABLE_WARNINGS +#include +DCPOMATIC_ENABLE_WARNINGS + + +class MetadataDialog : public wxDialog, public WeakFilm +{ +public: + MetadataDialog (wxWindow* parent, std::weak_ptr film); + + virtual void setup (); + +protected: + virtual void setup_standard (wxPanel*, wxSizer*) {} + virtual void setup_advanced (wxPanel*, wxSizer*) {} +}; diff --git a/src/wx/smpte_metadata_dialog.cc b/src/wx/smpte_metadata_dialog.cc index 464da6710..a2e9d355a 100644 --- a/src/wx/smpte_metadata_dialog.cc +++ b/src/wx/smpte_metadata_dialog.cc @@ -28,7 +28,6 @@ #include "lib/film.h" #include #include -#include #include @@ -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 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 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); diff --git a/src/wx/smpte_metadata_dialog.h b/src/wx/smpte_metadata_dialog.h index 46272adbb..e27401e87 100644 --- a/src/wx/smpte_metadata_dialog.h +++ b/src/wx/smpte_metadata_dialog.h @@ -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 @@ -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); + 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 ratings () const; void set_ratings (std::vector r); std::vector content_versions () const; diff --git a/src/wx/wscript b/src/wx/wscript index 76eea3fa5..013377e16 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -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 -- 2.30.2