diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-29 09:14:20 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-29 20:53:49 +0200 |
| commit | 39fb8198febde1937019db1c300ec363aab5aa56 (patch) | |
| tree | 52bc32134e8ae2b5587b3a62130baa9acf815b60 /src/wx | |
| parent | b249700e1da7dd6631a8b4440587f4093a2bdef1 (diff) | |
C++11 tidying.
Diffstat (limited to 'src/wx')
49 files changed, 416 insertions, 200 deletions
diff --git a/src/wx/batch_job_view.cc b/src/wx/batch_job_view.cc index 07e330c4c..06f698874 100644 --- a/src/wx/batch_job_view.cc +++ b/src/wx/batch_job_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,56 +18,65 @@ */ + #include "batch_job_view.h" #include "dcpomatic_button.h" #include "lib/job_manager.h" #include <wx/sizer.h> #include <wx/button.h> + using std::list; using std::shared_ptr; + BatchJobView::BatchJobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table) : JobView (job, parent, container, table) { } + int BatchJobView::insert_position () const { return _table->GetEffectiveRowsCount() * _table->GetEffectiveColsCount(); } + void BatchJobView::finish_setup (wxWindow* parent, wxSizer* sizer) { _higher_priority = new Button (parent, _("Higher priority")); - _higher_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::higher_priority_clicked, this)); + _higher_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::higher_priority_clicked, this)); sizer->Add (_higher_priority, 1, wxALIGN_CENTER_VERTICAL); _lower_priority = new Button (parent, _("Lower priority")); - _lower_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::lower_priority_clicked, this)); + _lower_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::lower_priority_clicked, this)); sizer->Add (_lower_priority, 1, wxALIGN_CENTER_VERTICAL); } + + void BatchJobView::higher_priority_clicked () { JobManager::instance()->increase_priority (_job); } + void BatchJobView::lower_priority_clicked () { JobManager::instance()->decrease_priority (_job); } + void BatchJobView::job_list_changed () { bool high = false; bool low = false; - list<shared_ptr<Job> > jobs = JobManager::instance()->get(); - if (!jobs.empty ()) { + auto jobs = JobManager::instance()->get(); + if (!jobs.empty()) { if (_job != jobs.front()) { high = true; } diff --git a/src/wx/batch_job_view.h b/src/wx/batch_job_view.h index 688e6c374..6d9ccba31 100644 --- a/src/wx/batch_job_view.h +++ b/src/wx/batch_job_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "job_view.h" + class BatchJobView : public JobView { public: diff --git a/src/wx/content_properties_dialog.cc b/src/wx/content_properties_dialog.cc index 2e0e360d9..bc835edaf 100644 --- a/src/wx/content_properties_dialog.cc +++ b/src/wx/content_properties_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "content_properties_dialog.h" #include "wx_util.h" #include "static_text.h" @@ -26,6 +27,7 @@ #include "lib/audio_content.h" #include <boost/algorithm/string.hpp> + using std::string; using std::list; using std::pair; @@ -33,10 +35,11 @@ using std::map; using std::shared_ptr; using std::dynamic_pointer_cast; + ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr<const Film> film, shared_ptr<Content> content) : TableDialog (parent, _("Content Properties"), 2, 1, false) { - map<UserProperty::Category, list<UserProperty> > grouped; + map<UserProperty::Category, list<UserProperty>> grouped; for (auto i: content->user_properties(film)) { if (grouped.find(i.category) == grouped.end()) { grouped[i.category] = list<UserProperty> (); @@ -50,16 +53,17 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr<c maybe_add_group (grouped, UserProperty::LENGTH); /* Nasty hack to stop the bottom property being cut off on Windows / OS X */ - add (wxString (), false); - add (wxString (), false); + add (wxString(), false); + add (wxString(), false); layout (); } + void -ContentPropertiesDialog::maybe_add_group (map<UserProperty::Category, list<UserProperty> > const & groups, UserProperty::Category category) +ContentPropertiesDialog::maybe_add_group (map<UserProperty::Category, list<UserProperty>> const & groups, UserProperty::Category category) { - map<UserProperty::Category, list<UserProperty> >::const_iterator i = groups.find (category); + auto i = groups.find (category); if (i == groups.end()) { return; } @@ -80,7 +84,7 @@ ContentPropertiesDialog::maybe_add_group (map<UserProperty::Category, list<UserP break; } - wxStaticText* m = new StaticText (this, category_name); + auto m = new StaticText (this, category_name); wxFont font (*wxNORMAL_FONT); font.SetWeight (wxFONTWEIGHT_BOLD); m->SetFont (font); diff --git a/src/wx/content_properties_dialog.h b/src/wx/content_properties_dialog.h index 9faccb4b7..c7efa4497 100644 --- a/src/wx/content_properties_dialog.h +++ b/src/wx/content_properties_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,15 +18,18 @@ */ + #include "table_dialog.h" #include "lib/user_property.h" #include <list> #include <map> + class Content; class Film; class UserProperty; + class ContentPropertiesDialog : public TableDialog { public: diff --git a/src/wx/dkdm_dialog.cc b/src/wx/dkdm_dialog.cc index c46fed760..68fe4bae1 100644 --- a/src/wx/dkdm_dialog.cc +++ b/src/wx/dkdm_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "dkdm_dialog.h" #include "wx_util.h" #include "recipients_panel.h" @@ -37,6 +38,7 @@ #include <wx/listctrl.h> #include <iostream> + using std::string; using std::exception; using std::map; @@ -59,9 +61,9 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr<const Film> film) , _film (film) { /* Main sizers */ - wxBoxSizer* horizontal = new wxBoxSizer (wxHORIZONTAL); - wxBoxSizer* left = new wxBoxSizer (wxVERTICAL); - wxBoxSizer* right = new wxBoxSizer (wxVERTICAL); + auto horizontal = new wxBoxSizer (wxHORIZONTAL); + auto left = new wxBoxSizer (wxVERTICAL); + auto right = new wxBoxSizer (wxVERTICAL); horizontal->Add (left, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP * 4); horizontal->Add (right, 1, wxEXPAND); @@ -71,7 +73,7 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr<const Film> film) subheading_font.SetWeight (wxFONTWEIGHT_BOLD); /* Sub-heading: Screens */ - wxStaticText* h = new StaticText (this, _("Recipients")); + auto h = new StaticText (this, _("Recipients")); h->SetFont (subheading_font); left->Add (h, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP); _recipients = new RecipientsPanel (this); @@ -112,7 +114,7 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr<const Film> film) /* Make an overall sizer to get a nice border */ - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + auto overall_sizer = new wxBoxSizer (wxVERTICAL); overall_sizer->Add (horizontal, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER); /* Bind */ @@ -128,6 +130,7 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr<const Film> film) overall_sizer->SetSizeHints (this); } + void DKDMDialog::setup_sensitivity () { @@ -136,25 +139,27 @@ DKDMDialog::setup_sensitivity () _make->Enable (!_recipients->recipients().empty() && _timing->valid() && _cpl->has_selected()); } + bool DKDMDialog::confirm_overwrite (boost::filesystem::path path) { return confirm_dialog ( this, - wxString::Format (_("File %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data()) + wxString::Format(_("File %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data()) ); } + void DKDMDialog::make_clicked () { - shared_ptr<const Film> film = _film.lock (); + auto film = _film.lock (); DCPOMATIC_ASSERT (film); list<KDMWithMetadataPtr> kdms; try { for (auto i: _recipients->recipients()) { - KDMWithMetadataPtr p = kdm_for_dkdm_recipient (film, _cpl->cpl(), i, _timing->from(), _timing->until()); + auto p = kdm_for_dkdm_recipient (film, _cpl->cpl(), i, _timing->from(), _timing->until()); if (p) { kdms.push_back (p); } @@ -171,17 +176,17 @@ DKDMDialog::make_clicked () return; } - pair<shared_ptr<Job>, int> result = _output->make (kdms, film->name(), bind(&DKDMDialog::confirm_overwrite, this, _1)); + auto result = _output->make (kdms, film->name(), bind(&DKDMDialog::confirm_overwrite, this, _1)); if (result.first) { JobManager::instance()->add (result.first); } if (result.second > 0) { /* XXX: proper plural form support in wxWidgets? */ - wxString s = result.second == 1 ? _("%d DKDM written to %s") : _("%d DKDMs written to %s"); + auto s = result.second == 1 ? _("%d DKDM written to %s") : _("%d DKDMs written to %s"); message_dialog ( this, - wxString::Format (s, result.second, std_to_wx(_output->directory().string()).data()) + wxString::Format(s, result.second, std_to_wx(_output->directory().string()).data()) ); } } diff --git a/src/wx/dkdm_dialog.h b/src/wx/dkdm_dialog.h index 4235de511..7b20e88ec 100644 --- a/src/wx/dkdm_dialog.h +++ b/src/wx/dkdm_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ + #include "wx_util.h" #include <wx/wx.h> #include <map> + class Film; class ScreensPanel; class RecipientsPanel; @@ -30,6 +32,7 @@ class DKDMOutputPanel; class KDMCPLPanel; struct CPLSummary; + class DKDMDialog : public wxDialog { public: diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index 665281073..2ff05ddec 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,13 +18,15 @@ */ + #include "download_certificate_panel.h" + class DolbyDoremiCertificatePanel : public DownloadCertificatePanel { public: DolbyDoremiCertificatePanel (DownloadCertificateDialog* dialog); - void do_download (); - wxString name () const; + void do_download () override; + wxString name () const override; }; diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index ae62f1a0a..b9680e298 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "wx_util.h" #include "download_certificate_panel.h" #include "download_certificate_dialog.h" @@ -28,10 +29,12 @@ #include <dcp/exceptions.h> #include <boost/bind/bind.hpp> + using std::string; using boost::function; using boost::optional; + DownloadCertificatePanel::DownloadCertificatePanel (DownloadCertificateDialog* dialog) : wxPanel (dialog->notebook(), wxID_ANY) , _dialog (dialog) @@ -59,11 +62,11 @@ optional<string> DownloadCertificatePanel::load_certificate (boost::filesystem::path file) { try { - _certificate = dcp::Certificate (dcp::file_to_string (file)); + _certificate = dcp::Certificate (dcp::file_to_string(file)); } catch (dcp::MiscError& e) { return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what()); } - return optional<string>(); + return {}; } @@ -75,7 +78,7 @@ DownloadCertificatePanel::load_certificate_from_chain (boost::filesystem::path f } catch (dcp::MiscError& e) { return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what()); } - return optional<string>(); + return {}; } @@ -83,6 +86,7 @@ optional<dcp::Certificate> DownloadCertificatePanel::certificate () const { return _certificate; + } void @@ -93,11 +97,12 @@ DownloadCertificatePanel::download () /* Hack: without this the SetLabel() above has no visible effect */ wxMilliSleep (200); - signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this)); + signal_manager->when_idle (boost::bind(&DownloadCertificatePanel::do_download, this)); } + bool DownloadCertificatePanel::ready_to_download () const { - return !_serial->IsEmpty (); + return !_serial->IsEmpty(); } diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index ba355f813..25271c770 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H #define DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H + #include "lib/warnings.h" #include <dcp/certificate.h> DCPOMATIC_DISABLE_WARNINGS @@ -28,8 +30,10 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <boost/optional.hpp> + class DownloadCertificateDialog; + class DownloadCertificatePanel : public wxPanel { public: @@ -54,4 +58,5 @@ private: boost::optional<dcp::Certificate> _certificate; }; + #endif diff --git a/src/wx/email_dialog.cc b/src/wx/email_dialog.cc index 4d3ae4fe1..65fb47473 100644 --- a/src/wx/email_dialog.cc +++ b/src/wx/email_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,37 +18,42 @@ */ + #include "email_dialog.h" #include "wx_util.h" + using std::string; using std::shared_ptr; using boost::optional; + EmailDialog::EmailDialog (wxWindow* parent) : TableDialog (parent, _("Email address"), 2, 1, true) { add (_("Email address"), true); - _email = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (400, -1))); + _email = add (new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(400, -1))); layout (); _email->SetFocus (); } + void EmailDialog::set (string address) { - _email->SetValue (std_to_wx (address)); + _email->SetValue (std_to_wx(address)); } + optional<string> EmailDialog::get () const { - string s = wx_to_std (_email->GetValue ()); - if (s.empty ()) { + auto s = wx_to_std (_email->GetValue ()); + if (s.empty()) { /* Invalid email address */ - return optional<string> (); + return {}; } return s; diff --git a/src/wx/email_dialog.h b/src/wx/email_dialog.h index 932dd8714..3f622f87d 100644 --- a/src/wx/email_dialog.h +++ b/src/wx/email_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #include "table_dialog.h" #include <boost/optional.hpp> + class EmailDialog : public TableDialog { public: @@ -32,3 +34,4 @@ public: private: wxTextCtrl* _email; }; + diff --git a/src/wx/html_dialog.cc b/src/wx/html_dialog.cc index 978330187..dcae84cd9 100644 --- a/src/wx/html_dialog.cc +++ b/src/wx/html_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "html_dialog.h" #include "wx_util.h" #include "lib/cross.h" @@ -29,14 +30,16 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <iostream> + #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif + HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html) : wxDialog (parent, wxID_ANY, title) { - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + auto sizer = new wxBoxSizer (wxVERTICAL); wxFileSystem::AddHandler(new wxMemoryFSHandler); @@ -46,7 +49,7 @@ HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html) wxBitmap(std_to_wx(boost::filesystem::path(resources_path() / "me.jpg").string()), wxBITMAP_TYPE_JPEG), wxBITMAP_TYPE_JPEG ); - wxHtmlWindow* h = new wxHtmlWindow (this); + auto h = new wxHtmlWindow (this); h->SetPage (html); sizer->Add (h, 1, wxEXPAND | wxALL, 6); @@ -62,6 +65,7 @@ HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html) SetSize (h->GetInternalRepresentation()->GetWidth(), h->GetInternalRepresentation()->GetHeight() + 64); } + void HTMLDialog::link_clicked (wxHtmlLinkEvent& ev) { diff --git a/src/wx/html_dialog.h b/src/wx/html_dialog.h index 9da4c8215..2b6924179 100644 --- a/src/wx/html_dialog.h +++ b/src/wx/html_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include <wx/wx.h> DCPOMATIC_ENABLE_WARNINGS + class wxHtmlLinkEvent; + class HTMLDialog : public wxDialog { public: diff --git a/src/wx/move_to_dialog.cc b/src/wx/move_to_dialog.cc index 542655477..fdd118520 100644 --- a/src/wx/move_to_dialog.cc +++ b/src/wx/move_to_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,15 +18,18 @@ */ + #include "move_to_dialog.h" #include "lib/film.h" #include <wx/spinctrl.h> + using std::list; using std::shared_ptr; using boost::optional; using namespace dcpomatic; + MoveToDialog::MoveToDialog (wxWindow* parent, optional<DCPTime> position, shared_ptr<const Film> film) : TableDialog (parent, _("Move content"), 2, 0, true) , _film (film) @@ -49,13 +52,14 @@ MoveToDialog::MoveToDialog (wxWindow* parent, optional<DCPTime> position, shared } } + DCPTime MoveToDialog::position () const { - shared_ptr<const Film> film = _film.lock (); + auto film = _film.lock (); DCPOMATIC_ASSERT (film); - list<DCPTimePeriod> reels = film->reels (); - list<DCPTimePeriod>::const_iterator i = reels.begin (); + auto reels = film->reels (); + auto i = reels.begin (); for (int j = 0; j < _reel->GetValue() - 1; ++j) { DCPOMATIC_ASSERT (i != reels.end()); ++i; diff --git a/src/wx/move_to_dialog.h b/src/wx/move_to_dialog.h index 61520a71f..16267bc9b 100644 --- a/src/wx/move_to_dialog.h +++ b/src/wx/move_to_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ + #include "table_dialog.h" #include "lib/dcpomatic_time.h" #include <boost/optional.hpp> + class Film; class wxSpinCtrl; + class MoveToDialog : public TableDialog { public: diff --git a/src/wx/name_format_editor.cc b/src/wx/name_format_editor.cc index 5755d75f4..b2c11b50c 100644 --- a/src/wx/name_format_editor.cc +++ b/src/wx/name_format_editor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,18 +18,21 @@ */ + #include "name_format_editor.h" #include "wx_util.h" #include "static_text.h" #include "lib/util.h" + using std::string; + NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples, string suffix) - : _panel (new wxPanel (parent)) - , _example (new StaticText (_panel, "")) - , _sizer (new wxBoxSizer (wxVERTICAL)) - , _specification (new wxTextCtrl (_panel, wxID_ANY, "")) + : _panel (new wxPanel(parent)) + , _example (new StaticText(_panel, "")) + , _sizer (new wxBoxSizer(wxVERTICAL)) + , _specification (new wxTextCtrl(_panel, wxID_ANY, "")) , _name (name) , _examples (examples) , _suffix (suffix) @@ -40,22 +43,23 @@ NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp: } _panel->SetSizer (_sizer); - for (dcp::NameFormat::Map::const_iterator i = titles.begin(); i != titles.end(); ++i) { - wxStaticText* t = new StaticText (_panel, std_to_wx (String::compose ("%%%1 %2", i->first, i->second))); + for (auto const& i: titles) { + auto t = new StaticText (_panel, std_to_wx (String::compose ("%%%1 %2", i.first, i.second))); _sizer->Add (t); - wxFont font = t->GetFont(); + auto font = t->GetFont(); font.SetStyle (wxFONTSTYLE_ITALIC); font.SetPointSize (font.GetPointSize() - 1); t->SetFont (font); t->SetForegroundColour (wxColour (0, 0, 204)); } - _specification->SetValue (std_to_wx (_name.specification ())); - _specification->Bind (wxEVT_TEXT, boost::bind (&NameFormatEditor::changed, this)); + _specification->SetValue (std_to_wx (_name.specification())); + _specification->Bind (wxEVT_TEXT, boost::bind(&NameFormatEditor::changed, this)); update_example (); } + void NameFormatEditor::changed () { @@ -63,6 +67,7 @@ NameFormatEditor::changed () Changed (); } + void NameFormatEditor::update_example () { @@ -70,9 +75,9 @@ NameFormatEditor::update_example () return; } - _name.set_specification (careful_string_filter (wx_to_std (_specification->GetValue ()))); + _name.set_specification (careful_string_filter(wx_to_std(_specification->GetValue()))); - wxString example = wxString::Format (_("e.g. %s"), std_to_wx (_name.get (_examples, _suffix))); + auto example = wxString::Format (_("e.g. %s"), std_to_wx (_name.get (_examples, _suffix))); wxString wrapped; for (size_t i = 0; i < example.Length(); ++i) { if (i > 0 && (i % 40) == 0) { diff --git a/src/wx/name_format_editor.h b/src/wx/name_format_editor.h index e3728615f..596b42740 100644 --- a/src/wx/name_format_editor.h +++ b/src/wx/name_format_editor.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_NAME_FORMAT_EDITOR_H #define DCPOMATIC_NAME_FORMAT_EDITOR_H + #include "lib/compose.hpp" #include "lib/warnings.h" #include <dcp/name_format.h> @@ -29,6 +31,7 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <boost/signals2.hpp> + class NameFormatEditor { public: @@ -59,4 +62,5 @@ private: std::string _suffix; }; + #endif diff --git a/src/wx/normal_job_view.cc b/src/wx/normal_job_view.cc index 6c9c08fa7..6d2b7e9f2 100644 --- a/src/wx/normal_job_view.cc +++ b/src/wx/normal_job_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,20 +18,23 @@ */ + #include "normal_job_view.h" #include "dcpomatic_button.h" #include "lib/job.h" #include <wx/wx.h> + using std::shared_ptr; + NormalJobView::NormalJobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table) : JobView (job, parent, container, table) - , _pause (0) { } + void NormalJobView::finish_setup (wxWindow* parent, wxSizer* sizer) { @@ -41,11 +44,13 @@ NormalJobView::finish_setup (wxWindow* parent, wxSizer* sizer) } int + NormalJobView::insert_position () const { return 0; } + void NormalJobView::pause_clicked () { @@ -58,6 +63,7 @@ NormalJobView::pause_clicked () } } + void NormalJobView::finished () { diff --git a/src/wx/normal_job_view.h b/src/wx/normal_job_view.h index ea1a014f4..acd8111b6 100644 --- a/src/wx/normal_job_view.h +++ b/src/wx/normal_job_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,10 +18,13 @@ */ + #include "job_view.h" + class wxSizer; + class NormalJobView : public JobView { public: @@ -35,5 +38,5 @@ private: void pause_clicked (); void finished (); - wxButton* _pause; + wxButton* _pause = nullptr; }; diff --git a/src/wx/paste_dialog.cc b/src/wx/paste_dialog.cc index cd4518881..429e8fe6e 100644 --- a/src/wx/paste_dialog.cc +++ b/src/wx/paste_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #include "paste_dialog.h" #include "check_box.h" + PasteDialog::PasteDialog (wxWindow* parent, bool video, bool audio, bool text) : TableDialog (parent, _("Paste"), 1, 0, true) { @@ -37,18 +39,21 @@ PasteDialog::PasteDialog (wxWindow* parent, bool video, bool audio, bool text) layout (); } + bool PasteDialog::video () const { return _video->GetValue (); } + bool PasteDialog::audio () const { return _audio->GetValue (); } + bool PasteDialog::text () const { diff --git a/src/wx/paste_dialog.h b/src/wx/paste_dialog.h index 792195947..1f447d3f8 100644 --- a/src/wx/paste_dialog.h +++ b/src/wx/paste_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "table_dialog.h" + class PasteDialog : public TableDialog { public: diff --git a/src/wx/qube_certificate_panel.cc b/src/wx/qube_certificate_panel.cc index c67cc46f2..e1c6bfb41 100644 --- a/src/wx/qube_certificate_panel.cc +++ b/src/wx/qube_certificate_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "qube_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" @@ -26,6 +27,7 @@ #include "lib/config.h" #include <boost/algorithm/string/predicate.hpp> + using std::string; using std::list; using boost::optional; @@ -33,8 +35,10 @@ using boost::optional; using namespace boost::placeholders; #endif + static string const base = "ftp://certificates.qubecinema.com/"; + QubeCertificatePanel::QubeCertificatePanel (DownloadCertificateDialog* dialog, string type) : DownloadCertificatePanel (dialog) , _type (type) @@ -42,16 +46,17 @@ QubeCertificatePanel::QubeCertificatePanel (DownloadCertificateDialog* dialog, s } + void QubeCertificatePanel::do_download () { - list<string> files = ls_url(String::compose("%1SMPTE-%2/", base, _type)); + auto files = ls_url(String::compose("%1SMPTE-%2/", base, _type)); if (files.empty()) { error_dialog (this, _("Could not read certificates from Qube server.")); return; } - string const serial = wx_to_std(_serial->GetValue()); + auto const serial = wx_to_std(_serial->GetValue()); optional<string> name; for (auto i: files) { if (boost::algorithm::starts_with(i, String::compose("%1-%2-", _type, serial))) { @@ -66,7 +71,7 @@ QubeCertificatePanel::do_download () return; } - optional<string> error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1)); + auto error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1)); if (error) { _dialog->message()->SetLabel(wxT("")); @@ -77,6 +82,7 @@ QubeCertificatePanel::do_download () } } + wxString QubeCertificatePanel::name () const { diff --git a/src/wx/qube_certificate_panel.h b/src/wx/qube_certificate_panel.h index 89c67f60e..a9053dd1b 100644 --- a/src/wx/qube_certificate_panel.h +++ b/src/wx/qube_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,15 +18,17 @@ */ + #include "download_certificate_panel.h" + class QubeCertificatePanel : public DownloadCertificatePanel { public: QubeCertificatePanel (DownloadCertificateDialog* dialog, std::string type); - void do_download (); - wxString name () const; + void do_download () override; + wxString name () const override; private: std::string _type; diff --git a/src/wx/rename_template_dialog.cc b/src/wx/rename_template_dialog.cc index 970c85a8b..714e08057 100644 --- a/src/wx/rename_template_dialog.cc +++ b/src/wx/rename_template_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,24 +18,28 @@ */ + #include "rename_template_dialog.h" + RenameTemplateDialog::RenameTemplateDialog (wxWindow* parent) : TableDialog (parent, _("Rename template"), 2, 1, true) { add (_("New name"), true); - _name = add (new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (300, -1))); + _name = add (new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1))); layout (); _name->SetFocus (); } + wxString RenameTemplateDialog::get () const { return _name->GetValue (); } + void RenameTemplateDialog::set (wxString s) { diff --git a/src/wx/rename_template_dialog.h b/src/wx/rename_template_dialog.h index 4ad4ee4c4..d4304ff45 100644 --- a/src/wx/rename_template_dialog.h +++ b/src/wx/rename_template_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "table_dialog.h" + class RenameTemplateDialog : public TableDialog { public: diff --git a/src/wx/self_dkdm_dialog.cc b/src/wx/self_dkdm_dialog.cc index 71ea089dd..157912d37 100644 --- a/src/wx/self_dkdm_dialog.cc +++ b/src/wx/self_dkdm_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "self_dkdm_dialog.h" #include "wx_util.h" #include "kdm_output_panel.h" @@ -42,6 +43,7 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <iostream> + using std::string; using std::map; using std::list; @@ -52,18 +54,19 @@ using std::make_pair; using std::shared_ptr; using boost::bind; + SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr<const Film> film) : wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic")) { /* Main sizer */ - wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL); + auto vertical = new wxBoxSizer (wxVERTICAL); /* Font for sub-headings */ wxFont subheading_font (*wxNORMAL_FONT); subheading_font.SetWeight (wxFONTWEIGHT_BOLD); /* Sub-heading: CPL */ - wxStaticText* h = new StaticText (this, _("CPL")); + auto h = new StaticText (this, _("CPL")); h->SetFont (subheading_font); vertical->Add (h); _cpl = new KDMCPLPanel (this, film->cpls ()); @@ -77,7 +80,7 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr<const Film> fi _internal = new wxRadioButton (this, wxID_ANY, _("Save to KDM Creator tool's list")); vertical->Add (_internal, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); - wxBoxSizer* w = new wxBoxSizer (wxHORIZONTAL); + auto w = new wxBoxSizer (wxHORIZONTAL); _write_to = new wxRadioButton (this, wxID_ANY, _("Write to")); w->Add (_write_to, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP); @@ -96,10 +99,10 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr<const Film> fi /* Make an overall sizer to get a nice border, and put some buttons in */ - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + auto overall_sizer = new wxBoxSizer (wxVERTICAL); overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER); - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP); } @@ -122,43 +125,48 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr<const Film> fi _write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this)); } + void SelfDKDMDialog::dkdm_write_type_changed () { setup_sensitivity (); - if (_internal->GetValue ()) { - Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_INTERNAL); - } else if (_write_to->GetValue ()) { - Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_FILE); + if (_internal->GetValue()) { + Config::instance()->set_last_dkdm_write_type(Config::DKDM_WRITE_INTERNAL); + } else if (_write_to->GetValue()) { + Config::instance()->set_last_dkdm_write_type(Config::DKDM_WRITE_FILE); } } + void SelfDKDMDialog::setup_sensitivity () { _folder->Enable (_write_to->GetValue ()); - wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this)); + auto ok = dynamic_cast<wxButton *>(FindWindowById(wxID_OK, this)); if (ok) { ok->Enable (_cpl->has_selected ()); } } + boost::filesystem::path SelfDKDMDialog::cpl () const { return _cpl->cpl (); } + bool SelfDKDMDialog::internal () const { return _internal->GetValue (); } + boost::filesystem::path SelfDKDMDialog::directory () const { - return wx_to_std (_folder->GetPath ()); + return wx_to_std (_folder->GetPath()); } diff --git a/src/wx/self_dkdm_dialog.h b/src/wx/self_dkdm_dialog.h index 20c138c41..151231a00 100644 --- a/src/wx/self_dkdm_dialog.h +++ b/src/wx/self_dkdm_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "wx_util.h" #include "lib/warnings.h" #include <dcp/types.h> @@ -27,11 +28,13 @@ DCPOMATIC_ENABLE_WARNINGS #include <boost/date_time/posix_time/posix_time.hpp> #include <map> + class Film; class KDMCPLPanel; class wxDirPickerCtrl; class DirPickerCtrl; + class SelfDKDMDialog : public wxDialog { public: diff --git a/src/wx/standard_controls.cc b/src/wx/standard_controls.cc index c78844ca1..1e4ecc8d7 100644 --- a/src/wx/standard_controls.cc +++ b/src/wx/standard_controls.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ -#include "standard_controls.h" + #include "film_viewer.h" -#include <wx/wx.h> +#include "standard_controls.h" #include <wx/tglbtn.h> +#include <wx/wx.h> + using std::shared_ptr; + StandardControls::StandardControls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor_controls) : Controls (parent, viewer, editor_controls) , _play_button (new wxToggleButton(this, wxID_ANY, _("Play"))) @@ -33,6 +36,7 @@ StandardControls::StandardControls (wxWindow* parent, shared_ptr<FilmViewer> vie _play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind(&StandardControls::play_clicked, this)); } + void StandardControls::started () { @@ -40,6 +44,7 @@ StandardControls::started () _play_button->SetValue (true); } + void StandardControls::stopped () { @@ -47,12 +52,14 @@ StandardControls::stopped () _play_button->SetValue (false); } + void StandardControls::play_clicked () { check_play_state (); } + void StandardControls::check_play_state () { @@ -67,6 +74,7 @@ StandardControls::check_play_state () } } + void StandardControls::setup_sensitivity () { @@ -75,6 +83,7 @@ StandardControls::setup_sensitivity () _play_button->Enable (_film && !_film->content().empty() && !active_job); } + void StandardControls::play () { @@ -82,6 +91,7 @@ StandardControls::play () play_clicked (); } + void StandardControls::stop () { diff --git a/src/wx/standard_controls.h b/src/wx/standard_controls.h index eac47726b..191924509 100644 --- a/src/wx/standard_controls.h +++ b/src/wx/standard_controls.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "controls.h" + class StandardControls : public Controls { public: diff --git a/src/wx/suspender.cc b/src/wx/suspender.cc index 6cd78326a..88128874c 100644 --- a/src/wx/suspender.cc +++ b/src/wx/suspender.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "suspender.h" + Suspender::Suspender(boost::function<void (int)> handler) : _handler (handler) , _count (0) @@ -27,29 +29,34 @@ Suspender::Suspender(boost::function<void (int)> handler) } + Suspender::Block::Block (Suspender* s) : _suspender (s) { _suspender->increment (); } + Suspender::Block::~Block () { _suspender->decrement (); } + Suspender::Block Suspender::block () { return Block (this); } + void Suspender::increment () { ++_count; } + void Suspender::decrement () { @@ -62,6 +69,7 @@ Suspender::decrement () } } + bool Suspender::check (int property) { diff --git a/src/wx/suspender.h b/src/wx/suspender.h index 3538951a8..947d7a367 100644 --- a/src/wx/suspender.h +++ b/src/wx/suspender.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #include <boost/function.hpp> #include <set> + class Suspender { public: diff --git a/src/wx/templates_dialog.cc b/src/wx/templates_dialog.cc index e8f9b8a2b..259989d47 100644 --- a/src/wx/templates_dialog.cc +++ b/src/wx/templates_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "templates_dialog.h" #include "wx_util.h" #include "rename_template_dialog.h" @@ -25,19 +26,21 @@ #include "lib/config.h" #include <wx/wx.h> + using std::string; using boost::bind; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif + TemplatesDialog::TemplatesDialog (wxWindow* parent) : wxDialog (parent, wxID_ANY, _("Templates")) { _sizer = new wxBoxSizer (wxVERTICAL); SetSizer (_sizer); - wxSizer* hs = new wxBoxSizer (wxHORIZONTAL); + auto hs = new wxBoxSizer (wxHORIZONTAL); _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (200, 100), wxLC_REPORT | wxLC_SINGLE_SEL); wxListItem ip; @@ -49,7 +52,7 @@ TemplatesDialog::TemplatesDialog (wxWindow* parent) hs->Add (_list, 1, wxEXPAND, DCPOMATIC_SIZER_GAP); { - wxSizer* s = new wxBoxSizer (wxVERTICAL); + auto s = new wxBoxSizer (wxVERTICAL); _rename = new Button (this, _("Rename...")); s->Add (_rename, 0, wxTOP | wxBOTTOM, 2); _remove = new Button (this, _("Remove")); @@ -59,23 +62,24 @@ TemplatesDialog::TemplatesDialog (wxWindow* parent) _sizer->Add (hs, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE); + auto buttons = CreateSeparatedButtonSizer (wxCLOSE); if (buttons) { _sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } - _rename->Bind (wxEVT_BUTTON, bind (&TemplatesDialog::rename_clicked, this)); - _remove->Bind (wxEVT_BUTTON, bind (&TemplatesDialog::remove_clicked, this)); + _rename->Bind (wxEVT_BUTTON, bind(&TemplatesDialog::rename_clicked, this)); + _remove->Bind (wxEVT_BUTTON, bind(&TemplatesDialog::remove_clicked, this)); - _list->Bind (wxEVT_LIST_ITEM_SELECTED, bind (&TemplatesDialog::selection_changed, this)); - _list->Bind (wxEVT_LIST_ITEM_DESELECTED, bind (&TemplatesDialog::selection_changed, this)); - _list->Bind (wxEVT_SIZE, bind (&TemplatesDialog::resized, this, _1)); - _config_connection = Config::instance()->Changed.connect (bind (&TemplatesDialog::refresh, this)); + _list->Bind (wxEVT_LIST_ITEM_SELECTED, bind(&TemplatesDialog::selection_changed, this)); + _list->Bind (wxEVT_LIST_ITEM_DESELECTED, bind(&TemplatesDialog::selection_changed, this)); + _list->Bind (wxEVT_SIZE, bind(&TemplatesDialog::resized, this, _1)); + _config_connection = Config::instance()->Changed.connect (bind(&TemplatesDialog::refresh, this)); refresh (); selection_changed (); } + void TemplatesDialog::refresh () { @@ -90,12 +94,14 @@ TemplatesDialog::refresh () } } + void TemplatesDialog::layout () { _sizer->Layout (); } + void TemplatesDialog::selection_changed () { @@ -104,6 +110,7 @@ TemplatesDialog::selection_changed () _remove->Enable (i >= 0); } + void TemplatesDialog::rename_clicked () { @@ -118,7 +125,7 @@ TemplatesDialog::rename_clicked () li.m_mask = wxLIST_MASK_TEXT; _list->GetItem (li); - RenameTemplateDialog* d = new RenameTemplateDialog (this); + auto d = new RenameTemplateDialog (this); d->set (li.m_text); if (d->ShowModal() == wxID_OK) { if (!d->get().IsEmpty()) { @@ -131,6 +138,7 @@ TemplatesDialog::rename_clicked () d->Destroy (); } + void TemplatesDialog::remove_clicked () { @@ -145,12 +153,13 @@ TemplatesDialog::remove_clicked () li.m_mask = wxLIST_MASK_TEXT; _list->GetItem (li); - Config::instance()->delete_template (wx_to_std (li.m_text)); + Config::instance()->delete_template (wx_to_std(li.m_text)); _list->DeleteItem (i); selection_changed (); } + void TemplatesDialog::resized (wxSizeEvent& ev) { diff --git a/src/wx/templates_dialog.h b/src/wx/templates_dialog.h index 4a55e0beb..119eb42cf 100644 --- a/src/wx/templates_dialog.h +++ b/src/wx/templates_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include <wx/wx.h> @@ -25,6 +26,7 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <boost/signals2.hpp> + class TemplatesDialog : public wxDialog { public: diff --git a/src/wx/timeline_atmos_content_view.cc b/src/wx/timeline_atmos_content_view.cc index f982921ed..ec0f06ec1 100644 --- a/src/wx/timeline_atmos_content_view.cc +++ b/src/wx/timeline_atmos_content_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,10 +18,13 @@ */ + #include "timeline_atmos_content_view.h" + using std::shared_ptr; + /** @class TimelineAtmosContentView * @brief Timeline view for AtmosContent. */ @@ -32,12 +35,14 @@ TimelineAtmosContentView::TimelineAtmosContentView (Timeline& tl, shared_ptr<Con } + wxColour TimelineAtmosContentView::background_colour () const { return wxColour (149, 121, 232, 255); } + wxColour TimelineAtmosContentView::foreground_colour () const { diff --git a/src/wx/timeline_atmos_content_view.h b/src/wx/timeline_atmos_content_view.h index 05f4352eb..15da14edc 100644 --- a/src/wx/timeline_atmos_content_view.h +++ b/src/wx/timeline_atmos_content_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "timeline_content_view.h" + /** @class TimelineAtmosContentView * @brief Timeline view for AtmosContent. */ @@ -29,9 +31,10 @@ public: TimelineAtmosContentView (Timeline& tl, std::shared_ptr<Content> c); private: - bool active () const { + bool active () const override { return true; } - wxColour background_colour () const; - wxColour foreground_colour () const; + + wxColour background_colour () const override; + wxColour foreground_colour () const override; }; diff --git a/src/wx/timeline_audio_content_view.h b/src/wx/timeline_audio_content_view.h index d5a966ad5..5b8d6cdc2 100644 --- a/src/wx/timeline_audio_content_view.h +++ b/src/wx/timeline_audio_content_view.h @@ -18,8 +18,10 @@ */ + #include "timeline_content_view.h" + /** @class TimelineAudioContentView * @brief Timeline view for AudioContent. */ @@ -29,10 +31,10 @@ public: TimelineAudioContentView (Timeline& tl, std::shared_ptr<Content> c); private: - bool active () const { + bool active () const override { return true; } - wxColour background_colour () const; - wxColour foreground_colour () const; - wxString label () const; + wxColour background_colour () const override; + wxColour foreground_colour () const override; + wxString label () const override; }; diff --git a/src/wx/timeline_content_view.h b/src/wx/timeline_content_view.h index e9b294854..7087e9641 100644 --- a/src/wx/timeline_content_view.h +++ b/src/wx/timeline_content_view.h @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_TIMELINE_CONTENT_VIEW_H #define DCPOMATIC_TIMELINE_CONTENT_VIEW_H + #include "lib/change_signaller.h" #include "lib/types.h" #include "lib/warnings.h" @@ -32,6 +34,7 @@ DCPOMATIC_ENABLE_WARNINGS class Content; + /** @class TimelineContentView * @brief Parent class for views of pieces of content. */ @@ -40,7 +43,7 @@ class TimelineContentView : public TimelineView public: TimelineContentView (Timeline& tl, std::shared_ptr<Content> c); - dcpomatic::Rect<int> bbox () const; + dcpomatic::Rect<int> bbox () const override; void set_selected (bool s); bool selected () const; @@ -60,7 +63,7 @@ protected: private: - void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int> > overlaps); + void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps) override; int y_pos (int t) const; void content_change (ChangeType type, int p); @@ -70,6 +73,8 @@ private: boost::signals2::scoped_connection _content_connection; }; -typedef std::vector<std::shared_ptr<TimelineContentView> > TimelineContentViewList; + +typedef std::vector<std::shared_ptr<TimelineContentView>> TimelineContentViewList; + #endif diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index 5be006b60..975f7cd9d 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,17 +18,19 @@ */ + +#include "content_panel.h" #include "film_editor.h" #include "timeline_dialog.h" #include "wx_util.h" -#include "content_panel.h" -#include "lib/playlist.h" -#include "lib/cross.h" #include "lib/compose.hpp" +#include "lib/cross.h" +#include "lib/playlist.h" #include <wx/graphics.h> #include <iostream> #include <list> + using std::list; using std::cout; using std::string; @@ -38,6 +40,7 @@ using std::weak_ptr; using namespace boost::placeholders; #endif + TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer) : wxDialog ( cp->window(), @@ -81,7 +84,7 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film, weak_pt sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12); #ifdef DCPOMATIC_LINUX - wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE); + auto buttons = CreateSeparatedButtonSizer (wxCLOSE); if (buttons) { sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } @@ -97,6 +100,7 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film, weak_pt _film_changed_connection = film->Change.connect (bind (&TimelineDialog::film_change, this, _1, _2)); } + void TimelineDialog::film_change (ChangeType type, Film::Property p) { @@ -114,23 +118,25 @@ TimelineDialog::film_change (ChangeType type, Film::Property p) } } + void TimelineDialog::set_selection (ContentList selection) { _timeline.set_selection (selection); } + void TimelineDialog::tool_clicked (wxCommandEvent& ev) { - Timeline::Tool t = (Timeline::Tool) ev.GetId(); + Timeline::Tool t = static_cast<Timeline::Tool>(ev.GetId()); _timeline.tool_clicked (t); if (t == Timeline::SNAP) { - _timeline.set_snap (_toolbar->GetToolState ((int) t)); + _timeline.set_snap (_toolbar->GetToolState(static_cast<int>(t))); } else if (t == Timeline::SEQUENCE) { auto film = _film.lock (); if (film) { - film->set_sequence (_toolbar->GetToolState ((int) t)); + film->set_sequence (_toolbar->GetToolState(static_cast<int>(t))); } } } diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h index 97ddca964..17128e108 100644 --- a/src/wx/timeline_dialog.h +++ b/src/wx/timeline_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,11 +18,14 @@ */ + #include <wx/wx.h> #include "timeline.h" + class Playlist; + class TimelineDialog : public wxDialog { public: diff --git a/src/wx/timeline_labels_view.h b/src/wx/timeline_labels_view.h index 2ff1fa6a8..fb80b1bf3 100644 --- a/src/wx/timeline_labels_view.h +++ b/src/wx/timeline_labels_view.h @@ -30,7 +30,7 @@ class TimelineLabelsView : public TimelineView public: explicit TimelineLabelsView (Timeline& tl); - dcpomatic::Rect<int> bbox () const; + dcpomatic::Rect<int> bbox () const override; void set_video_tracks (int n); void set_audio_tracks (int n); @@ -38,7 +38,7 @@ public: void set_atmos (bool s); private: - void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps); + void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps) override; int _width = 0; int _video_tracks = 0; diff --git a/src/wx/timeline_reels_view.h b/src/wx/timeline_reels_view.h index a6c73100f..357fe2ce4 100644 --- a/src/wx/timeline_reels_view.h +++ b/src/wx/timeline_reels_view.h @@ -27,11 +27,11 @@ class TimelineReelsView : public TimelineView public: TimelineReelsView (Timeline& tl, int y); - dcpomatic::Rect<int> bbox () const; + dcpomatic::Rect<int> bbox () const override; void set_y (int y); private: - void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps); + void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps) override; int _y; }; diff --git a/src/wx/timeline_video_content_view.h b/src/wx/timeline_video_content_view.h index 2269a2930..fa8ddf54c 100644 --- a/src/wx/timeline_video_content_view.h +++ b/src/wx/timeline_video_content_view.h @@ -18,8 +18,10 @@ */ + #include "timeline_content_view.h" + /** @class TimelineVideoContentView * @brief Timeline view for VideoContent. */ @@ -29,7 +31,7 @@ public: TimelineVideoContentView (Timeline& tl, std::shared_ptr<Content> c); private: - bool active () const; - wxColour background_colour () const; - wxColour foreground_colour () const; + bool active () const override; + wxColour background_colour () const override; + wxColour foreground_colour () const override; }; diff --git a/src/wx/timeline_view.h b/src/wx/timeline_view.h index c40cf78ff..f3aa4d5e6 100644 --- a/src/wx/timeline_view.h +++ b/src/wx/timeline_view.h @@ -43,13 +43,13 @@ public: TimelineView (TimelineView const&) = delete; TimelineView& operator= (TimelineView const&) = delete; - void paint (wxGraphicsContext* g, std::list<dcpomatic::Rect<int> > overlaps); + void paint (wxGraphicsContext* g, std::list<dcpomatic::Rect<int>> overlaps); void force_redraw (); virtual dcpomatic::Rect<int> bbox () const = 0; protected: - virtual void do_paint (wxGraphicsContext *, std::list<dcpomatic::Rect<int> > overlaps) = 0; + virtual void do_paint (wxGraphicsContext *, std::list<dcpomatic::Rect<int>> overlaps) = 0; int time_x (dcpomatic::DCPTime t) const; diff --git a/src/wx/try_unmount_dialog.cc b/src/wx/try_unmount_dialog.cc index 44d970919..ffa4af535 100644 --- a/src/wx/try_unmount_dialog.cc +++ b/src/wx/try_unmount_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,23 +18,25 @@ */ + #include "try_unmount_dialog.h" #include "wx_util.h" #include "static_text.h" #include <wx/wx.h> + TryUnmountDialog::TryUnmountDialog (wxWindow* parent, wxString description) : wxDialog (parent, wxID_ANY, _("DCP-o-matic Disk Writer")) { - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); - wxStaticText* text = new StaticText (this, wxEmptyString); + auto sizer = new wxBoxSizer (wxVERTICAL); + auto text = new StaticText (this, wxEmptyString); sizer->Add (text, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); text->SetLabelMarkup ( wxString::Format(_("The drive <b>%s</b> is mounted.\n\nIt must be unmounted before DCP-o-matic can write to it.\n\nShould DCP-o-matic try to unmount it now?"), description) ); - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder()); } diff --git a/src/wx/try_unmount_dialog.h b/src/wx/try_unmount_dialog.h index de686f14c..cb01a2afb 100644 --- a/src/wx/try_unmount_dialog.h +++ b/src/wx/try_unmount_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include <wx/wx.h> DCPOMATIC_ENABLE_WARNINGS + class TryUnmountDialog : public wxDialog { public: diff --git a/src/wx/video_waveform_plot.cc b/src/wx/video_waveform_plot.cc index 7293af690..2e45f3493 100644 --- a/src/wx/video_waveform_plot.cc +++ b/src/wx/video_waveform_plot.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,12 +18,13 @@ */ -#include "video_waveform_plot.h" + #include "film_viewer.h" +#include "video_waveform_plot.h" #include "wx_util.h" -#include "lib/image.h" -#include "lib/film.h" #include "lib/dcp_video.h" +#include "lib/film.h" +#include "lib/image.h" #include "lib/player_video.h" #include <dcp/locale_convert.h> #include <dcp/openjpeg_image.h> @@ -32,12 +33,14 @@ #include <boost/bind/bind.hpp> #include <iostream> + using std::cout; -using std::min; +using std::make_shared; using std::max; +using std::min; +using std::shared_ptr; using std::string; using std::weak_ptr; -using std::shared_ptr; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif @@ -52,28 +55,25 @@ int const VideoWaveformPlot::_x_axis_width = 52; VideoWaveformPlot::VideoWaveformPlot (wxWindow* parent, weak_ptr<const Film> film, weak_ptr<FilmViewer> viewer) : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) , _film (film) - , _dirty (true) - , _enabled (false) - , _component (0) - , _contrast (0) { #ifndef __WXOSX__ SetDoubleBuffered (true); #endif - shared_ptr<FilmViewer> fv = viewer.lock (); + auto fv = viewer.lock (); DCPOMATIC_ASSERT (fv); - _viewer_connection = fv->ImageChanged.connect (boost::bind (&VideoWaveformPlot::set_image, this, _1)); + _viewer_connection = fv->ImageChanged.connect (boost::bind(&VideoWaveformPlot::set_image, this, _1)); - Bind (wxEVT_PAINT, boost::bind (&VideoWaveformPlot::paint, this)); - Bind (wxEVT_SIZE, boost::bind (&VideoWaveformPlot::sized, this, _1)); - Bind (wxEVT_MOTION, boost::bind (&VideoWaveformPlot::mouse_moved, this, _1)); + Bind (wxEVT_PAINT, boost::bind(&VideoWaveformPlot::paint, this)); + Bind (wxEVT_SIZE, boost::bind(&VideoWaveformPlot::sized, this, _1)); + Bind (wxEVT_MOTION, boost::bind(&VideoWaveformPlot::mouse_moved, this, _1)); SetMinSize (wxSize (640, 512)); SetBackgroundColour (wxColour (0, 0, 0)); } + void VideoWaveformPlot::paint () { @@ -88,7 +88,7 @@ VideoWaveformPlot::paint () return; } - wxGraphicsContext* gc = wxGraphicsContext::Create (dc); + auto gc = wxGraphicsContext::Create (dc); if (!gc) { return; } @@ -119,7 +119,7 @@ VideoWaveformPlot::paint () } for (int i = 0; i < label_gaps + 1; ++i) { - wxGraphicsPath p = gc->CreatePath (); + auto p = gc->CreatePath (); int const y = _vertical_margin + height - (i * height / label_gaps) - 1; p.MoveToPoint (label_width + 8, y); p.AddLineToPoint (_x_axis_width - 4, y); @@ -133,7 +133,7 @@ VideoWaveformPlot::paint () } else if (n < 1000) { x += extra[2]; } - gc->DrawText (std_to_wx (locale_convert<string> (n)), x, y - (label_height / 2)); + gc->DrawText (std_to_wx(locale_convert<string>(n)), x, y - (label_height / 2)); } wxImage waveform (_waveform->size().width, height, _waveform->data()[0], true); @@ -143,6 +143,7 @@ VideoWaveformPlot::paint () delete gc; } + void VideoWaveformPlot::create_waveform () { @@ -152,9 +153,9 @@ VideoWaveformPlot::create_waveform () return; } - dcp::Size const image_size = _image->size(); + auto const image_size = _image->size(); int const waveform_height = GetSize().GetHeight() - _vertical_margin * 2; - _waveform.reset (new Image (AV_PIX_FMT_RGB24, dcp::Size (image_size.width, waveform_height), true)); + _waveform = make_shared<Image>(AV_PIX_FMT_RGB24, dcp::Size (image_size.width, waveform_height), true); for (int x = 0; x < image_size.width; ++x) { @@ -185,11 +186,6 @@ VideoWaveformPlot::create_waveform () ); } -static void -note () -{ - -} void VideoWaveformPlot::set_image (shared_ptr<PlayerVideo> image) @@ -201,23 +197,26 @@ VideoWaveformPlot::set_image (shared_ptr<PlayerVideo> image) /* We must copy the PlayerVideo here as we will call ::image() on it, potentially with a different pixel_format than was used when ::prepare() was called. */ - _image = DCPVideo::convert_to_xyz (image->shallow_copy(), boost::bind(¬e)); + _image = DCPVideo::convert_to_xyz (image->shallow_copy(), [](dcp::NoteType, string) {}); _dirty = true; Refresh (); } + void VideoWaveformPlot::sized (wxSizeEvent &) { _dirty = true; } + void VideoWaveformPlot::set_enabled (bool e) { _enabled = e; } + void VideoWaveformPlot::set_component (int c) { @@ -226,6 +225,7 @@ VideoWaveformPlot::set_component (int c) Refresh (); } + /** Set `contrast', i.e. a fudge multiplication factor to make low-level signals easier to see, * between 0 and 256. */ @@ -237,6 +237,7 @@ VideoWaveformPlot::set_contrast (int b) Refresh (); } + void VideoWaveformPlot::mouse_moved (wxMouseEvent& ev) { @@ -249,18 +250,18 @@ VideoWaveformPlot::mouse_moved (wxMouseEvent& ev) _dirty = false; } - shared_ptr<const Film> film = _film.lock (); + auto film = _film.lock (); if (!film) { return; } - dcp::Size const full = film->frame_size (); + auto const full = film->frame_size (); - double const xs = static_cast<double> (full.width) / _waveform->size().width; + auto const xs = static_cast<double> (full.width) / _waveform->size().width; int const x1 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width - 0.5) * xs))); int const x2 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width + 0.5) * xs))); - double const ys = static_cast<double> (_pixel_values) / _waveform->size().height; + auto const ys = static_cast<double> (_pixel_values) / _waveform->size().height; int const fy = _waveform->size().height - (ev.GetPosition().y - _vertical_margin); int const y1 = max (0, min (_pixel_values - 1, int (floor (fy - 0.5) * ys))); int const y2 = max (0, min (_pixel_values - 1, int (floor (fy + 0.5) * ys))); diff --git a/src/wx/video_waveform_plot.h b/src/wx/video_waveform_plot.h index 037ff0cbf..36ec63d8a 100644 --- a/src/wx/video_waveform_plot.h +++ b/src/wx/video_waveform_plot.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,12 +18,14 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include <wx/wx.h> DCPOMATIC_ENABLE_WARNINGS #include <boost/signals2.hpp> + namespace dcp { class OpenJPEGImage; } @@ -33,6 +35,7 @@ class Image; class Film; class FilmViewer; + class VideoWaveformPlot : public wxPanel { public: @@ -59,10 +62,10 @@ private: std::weak_ptr<const Film> _film; std::shared_ptr<dcp::OpenJPEGImage> _image; std::shared_ptr<const Image> _waveform; - bool _dirty; - bool _enabled; - int _component; - int _contrast; + bool _dirty = true; + bool _enabled = false; + int _component = 0; + int _contrast = 0; static int const _vertical_margin; static int const _pixel_values; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 8ef32fca3..1a34e5fa8 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -105,6 +105,7 @@ add_label_to_sizer (wxSizer* s, wxWindow* p, wxString t, bool left, int prop, in return m; } + wxStaticText * #ifdef __WXOSX__ add_label_to_sizer (wxSizer* s, wxStaticText* t, bool left, int prop, int flags) @@ -119,6 +120,7 @@ add_label_to_sizer (wxSizer* s, wxStaticText* t, bool, int prop, int flags) return t; } + wxStaticText * add_label_to_sizer (wxGridBagSizer* s, wxWindow* p, wxString t, bool left, wxGBPosition pos, wxGBSpan span) { @@ -131,6 +133,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxWindow* p, wxString t, bool left, wxGBP return m; } + wxStaticText * #ifdef __WXOSX__ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool left, wxGBPosition pos, wxGBSpan span) @@ -146,6 +149,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool, wxGBPosition pos, return t; } + /** Pop up an error dialogue box. * @param parent Parent. * @param m Message. @@ -164,6 +168,7 @@ error_dialog (wxWindow* parent, wxString m, optional<wxString> e) d->Destroy (); } + /** Pop up an error dialogue box. * @param parent Parent. * @param m Message. @@ -176,11 +181,12 @@ message_dialog (wxWindow* parent, wxString m) d->Destroy (); } + /** @return true if the user answered "yes" */ bool confirm_dialog (wxWindow* parent, wxString m) { - wxMessageDialog* d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); + auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); int const r = d->ShowModal (); d->Destroy (); return r == wxID_YES; @@ -193,9 +199,10 @@ confirm_dialog (wxWindow* parent, wxString m) string wx_to_std (wxString s) { - return string (s.ToUTF8 ()); + return string (s.ToUTF8()); } + /** @param s STL string. * @return Corresponding wxWidgets string. */ @@ -205,12 +212,14 @@ std_to_wx (string s) return wxString (s.c_str(), wxConvUTF8); } + string string_client_data (wxClientData* o) { return wx_to_std (dynamic_cast<wxStringClientData*>(o)->GetData()); } + void checked_set (FilePickerCtrl* widget, boost::filesystem::path value) { @@ -225,6 +234,7 @@ checked_set (FilePickerCtrl* widget, boost::filesystem::path value) } } + void checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value) { @@ -239,6 +249,7 @@ checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value) } } + void checked_set (wxSpinCtrl* widget, int value) { @@ -247,6 +258,7 @@ checked_set (wxSpinCtrl* widget, int value) } } + void checked_set (wxSpinCtrlDouble* widget, double value) { @@ -256,6 +268,7 @@ checked_set (wxSpinCtrlDouble* widget, double value) } } + void checked_set (wxChoice* widget, int value) { @@ -264,6 +277,7 @@ checked_set (wxChoice* widget, int value) } } + void checked_set (wxChoice* widget, string value) { @@ -281,15 +295,16 @@ checked_set (wxChoice* widget, string value) } } + void checked_set (wxChoice* widget, vector<pair<string, string> > items) { - vector<pair<string, string> > current; + vector<pair<string, string>> current; for (unsigned int i = 0; i < widget->GetCount(); ++i) { current.push_back ( - make_pair ( - wx_to_std (widget->GetString (i)), - string_client_data (widget->GetClientObject (i)) + make_pair( + wx_to_std(widget->GetString(i)), + string_client_data(widget->GetClientObject(i)) ) ); } @@ -304,6 +319,7 @@ checked_set (wxChoice* widget, vector<pair<string, string> > items) } } + void checked_set (wxTextCtrl* widget, string value) { @@ -312,6 +328,7 @@ checked_set (wxTextCtrl* widget, string value) } } + void checked_set (PasswordEntry* entry, string value) { @@ -320,6 +337,7 @@ checked_set (PasswordEntry* entry, string value) } } + void checked_set (wxTextCtrl* widget, wxString value) { @@ -328,6 +346,7 @@ checked_set (wxTextCtrl* widget, wxString value) } } + void checked_set (wxStaticText* widget, string value) { @@ -336,6 +355,7 @@ checked_set (wxStaticText* widget, string value) } } + void checked_set (wxStaticText* widget, wxString value) { @@ -344,6 +364,7 @@ checked_set (wxStaticText* widget, wxString value) } } + void checked_set (wxCheckBox* widget, bool value) { @@ -352,6 +373,7 @@ checked_set (wxCheckBox* widget, bool value) } } + void checked_set (wxRadioButton* widget, bool value) { @@ -360,6 +382,7 @@ checked_set (wxRadioButton* widget, bool value) } } + void dcpomatic_setup_i18n () { @@ -408,24 +431,28 @@ dcpomatic_setup_i18n () } } + int wx_get (wxSpinCtrl* w) { return w->GetValue (); } + int wx_get (wxChoice* w) { return w->GetSelection (); } + double wx_get (wxSpinCtrlDouble* w) { return w->GetValue (); } + /** @param s String of the form Context|String * @return translation, or String if no translation is available. */ @@ -444,6 +471,7 @@ context_translation (wxString s) return t; } + wxString time_to_timecode (DCPTime t, double fps) { @@ -458,23 +486,24 @@ time_to_timecode (DCPTime t, double fps) return wxString::Format (wxT("%02d:%02d:%02d.%02d"), h, m, s, f); } + void setup_audio_channels_choice (wxChoice* choice, int minimum) { - vector<pair<string, string> > items; + vector<pair<string, string>> items; for (int i = minimum; i <= 16; i += 2) { if (i == 2) { - items.push_back (make_pair (wx_to_std (_("2 - stereo")), locale_convert<string> (i))); + items.push_back (make_pair(wx_to_std(_("2 - stereo")), locale_convert<string>(i))); } else if (i == 4) { - items.push_back (make_pair (wx_to_std (_("4 - L/C/R/Lfe")), locale_convert<string> (i))); + items.push_back (make_pair(wx_to_std(_("4 - L/C/R/Lfe")), locale_convert<string>(i))); } else if (i == 6) { - items.push_back (make_pair (wx_to_std (_("6 - 5.1")), locale_convert<string> (i))); + items.push_back (make_pair(wx_to_std(_("6 - 5.1")), locale_convert<string>(i))); } else if (i == 8) { - items.push_back (make_pair (wx_to_std (_("8 - 5.1/HI/VI")), locale_convert<string> (i))); + items.push_back (make_pair(wx_to_std(_("8 - 5.1/HI/VI")), locale_convert<string>(i))); } else if (i == 12) { - items.push_back (make_pair (wx_to_std (_("12 - 7.1/HI/VI")), locale_convert<string> (i))); + items.push_back (make_pair(wx_to_std(_("12 - 7.1/HI/VI")), locale_convert<string>(i))); } else { - items.push_back (make_pair (locale_convert<string> (i), locale_convert<string> (i))); + items.push_back (make_pair(locale_convert<string> (i), locale_convert<string>(i))); } } @@ -512,6 +541,7 @@ maybe_show_splash () return splash; } + double calculate_mark_interval (double mark_interval) { @@ -616,7 +646,7 @@ bitmap_path (string name) base = resources_path(); #endif - boost::filesystem::path p = base / String::compose("%1.png", name); + auto p = base / String::compose("%1.png", name); return std_to_wx (p.string()); } diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 4131ec0f7..97ddd5151 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ + /** @file src/wx/wx_util.h * @brief Some utility functions and classes. */ + #ifndef DCPOMATIC_WX_UTIL_H #define DCPOMATIC_WX_UTIL_H + #include "lib/dcpomatic_time.h" #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS @@ -35,6 +38,7 @@ DCPOMATIC_ENABLE_WARNINGS #include <boost/thread.hpp> #include <boost/signals2.hpp> + class FilePickerCtrl; class wxDirPickerCtrl; class wxSpinCtrl; @@ -43,6 +47,7 @@ class wxGridBagSizer; class wxSplashScreen; class PasswordEntry; + #define DCPOMATIC_SIZER_X_GAP 8 #define DCPOMATIC_SIZER_Y_GAP 8 #define DCPOMATIC_SIZER_GAP 8 @@ -65,12 +70,14 @@ class PasswordEntry; #define DCPOMATIC_RTAUDIO_API RtAudio::MACOSX_CORE #endif + /** i18n macro to support strings like Context|String * so that `String' can be translated to different things * in different contexts. */ #define S_(x) context_translation(x) + extern void error_dialog (wxWindow *, wxString, boost::optional<wxString> e = boost::optional<wxString>()); extern void message_dialog (wxWindow *, wxString); extern bool confirm_dialog (wxWindow *, wxString); @@ -93,6 +100,7 @@ extern bool report_errors_from_last_job (wxWindow* parent); extern wxString bitmap_path (std::string name); extern wxSize small_button_size (wxWindow* parent, wxString text); + struct Offset { Offset (wxString n, int h, int m) @@ -132,4 +140,5 @@ extern double wx_get (wxSpinCtrlDouble* widget); #define DCPOMATIC_USE_OWN_PICKER #endif + #endif |
