diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-07 22:15:01 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-07 22:15:01 +0200 |
| commit | 7bc2134d658778e04f1756c255e604b4ab5a5831 (patch) | |
| tree | b5ba51f2534604a6528fbbb130fd0cfca7d6fb70 /src/wx | |
| parent | a771a806291243760552988a1a7a5742bc007ee2 (diff) | |
Assorted C++11/formatting cleanups.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/content_view.cc | 36 | ||||
| -rw-r--r-- | src/wx/content_view.h | 7 | ||||
| -rw-r--r-- | src/wx/job_manager_view.cc | 31 | ||||
| -rw-r--r-- | src/wx/job_manager_view.h | 3 | ||||
| -rw-r--r-- | src/wx/recipients_panel.cc | 47 | ||||
| -rw-r--r-- | src/wx/recipients_panel.h | 9 | ||||
| -rw-r--r-- | src/wx/timeline_labels_view.cc | 16 | ||||
| -rw-r--r-- | src/wx/timeline_labels_view.h | 7 |
8 files changed, 97 insertions, 59 deletions
diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc index b3a66a7be..8055e2f2d 100644 --- a/src/wx/content_view.cc +++ b/src/wx/content_view.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 "content_view.h" #include "wx_util.h" #include "lib/dcpomatic_assert.h" @@ -32,15 +33,18 @@ #include <boost/optional.hpp> #include <wx/progdlg.h> -using std::string; + using std::cout; +using std::dynamic_pointer_cast; using std::list; +using std::make_shared; using std::shared_ptr; +using std::string; using std::weak_ptr; using boost::optional; -using std::dynamic_pointer_cast; using namespace dcpomatic; + ContentView::ContentView (wxWindow* parent) : wxListCtrl (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER) { @@ -51,18 +55,20 @@ ContentView::ContentView (wxWindow* parent) AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580); } + shared_ptr<Content> ContentView::selected () const { long int s = GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (s == -1) { - return shared_ptr<Content>(); + return {}; } DCPOMATIC_ASSERT (s < int(_content.size())); return _content[s]; } + void ContentView::update () { @@ -70,29 +76,29 @@ ContentView::update () DeleteAllItems (); _content.clear (); - optional<path> dir = Config::instance()->player_content_directory(); + auto dir = Config::instance()->player_content_directory(); if (!dir || !boost::filesystem::is_directory(*dir)) { dir = home_directory (); } wxProgressDialog progress (_("DCP-o-matic"), _("Reading content directory")); - JobManager* jm = JobManager::instance (); + auto jm = JobManager::instance (); - list<shared_ptr<ExamineContentJob> > jobs; + list<shared_ptr<ExamineContentJob>> jobs; - for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) { + for (auto i: directory_iterator(*dir)) { try { progress.Pulse (); shared_ptr<Content> content; - if (is_directory(*i) && (is_regular_file(*i / "ASSETMAP") || is_regular_file(*i / "ASSETMAP.xml"))) { - content.reset (new DCPContent(*i)); - } else if (i->path().extension() == ".mp4" || i->path().extension() == ".ecinema") { - content = content_factory(*i).front(); + if (is_directory(i) && (is_regular_file(i / "ASSETMAP") || is_regular_file(i / "ASSETMAP.xml"))) { + content.reset (new DCPContent(i)); + } else if (i.path().extension() == ".mp4" || i.path().extension() == ".ecinema") { + content = content_factory(i).front(); } if (content) { - shared_ptr<ExamineContentJob> job(new ExamineContentJob(shared_ptr<Film>(), content)); + auto job = make_shared<ExamineContentJob>(shared_ptr<Film>(), content); jm->add (job); jobs.push_back (job); } @@ -125,6 +131,7 @@ ContentView::update () } } + void ContentView::add (shared_ptr<Content> content) { @@ -152,6 +159,7 @@ ContentView::add (shared_ptr<Content> content) SetItem(it); } + shared_ptr<Content> ContentView::get (string digest) const { @@ -161,5 +169,5 @@ ContentView::get (string digest) const } } - return shared_ptr<Content>(); + return {}; } diff --git a/src/wx/content_view.h b/src/wx/content_view.h index 0bbfffaa7..1ad7c541a 100644 --- a/src/wx/content_view.h +++ b/src/wx/content_view.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,6 +18,7 @@ */ + #include "lib/content_store.h" #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS @@ -25,9 +26,11 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <vector> + class Content; class Film; + class ContentView : public wxListCtrl, public ContentStore { public: @@ -42,5 +45,5 @@ private: void add (std::shared_ptr<Content> content); std::weak_ptr<Film> _film; - std::vector<std::shared_ptr<Content> > _content; + std::vector<std::shared_ptr<Content>> _content; }; diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index 6b341307d..19243393c 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_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. @@ -16,12 +16,15 @@ 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/>. + */ + /** @file src/job_manager_view.cc * @brief Class generating a GTK widget to show the progress of jobs. */ + #include "job_manager_view.h" #include "batch_job_view.h" #include "normal_job_view.h" @@ -33,6 +36,7 @@ #include "lib/compose.hpp" #include <iostream> + using std::string; using std::list; using std::map; @@ -45,6 +49,7 @@ using boost::bind; using namespace boost::placeholders; #endif + /** @param parent Parent window. * @param batch true to use BatchJobView, false to use NormalJobView. * @@ -55,7 +60,7 @@ JobManagerView::JobManagerView (wxWindow* parent, bool batch) , _batch (batch) { _panel = new wxPanel (this); - wxSizer* sizer = new wxBoxSizer (wxVERTICAL); + auto sizer = new wxBoxSizer (wxVERTICAL); sizer->Add (_panel, 1, wxEXPAND); SetSizer (sizer); @@ -66,24 +71,25 @@ JobManagerView::JobManagerView (wxWindow* parent, bool batch) SetScrollRate (0, 32); EnableScrolling (false, true); - Bind (wxEVT_TIMER, boost::bind (&JobManagerView::periodic, this)); + Bind (wxEVT_TIMER, boost::bind(&JobManagerView::periodic, this)); _timer.reset (new wxTimer (this)); _timer->Start (1000); - JobManager::instance()->JobAdded.connect (bind (&JobManagerView::job_added, this, _1)); - JobManager::instance()->JobsReordered.connect (bind (&JobManagerView::replace, this)); + JobManager::instance()->JobAdded.connect (bind(&JobManagerView::job_added, this, _1)); + JobManager::instance()->JobsReordered.connect (bind(&JobManagerView::replace, this)); } + void JobManagerView::job_added (weak_ptr<Job> j) { - shared_ptr<Job> job = j.lock (); + auto job = j.lock (); if (job) { shared_ptr<JobView> v; if (_batch) { - v.reset (new BatchJobView (job, this, _panel, _table)); + v.reset (new BatchJobView(job, this, _panel, _table)); } else { - v.reset (new NormalJobView (job, this, _panel, _table)); + v.reset (new NormalJobView(job, this, _panel, _table)); } v->setup (); _job_records.push_back (v); @@ -93,20 +99,22 @@ JobManagerView::job_added (weak_ptr<Job> j) job_list_changed (); } + void JobManagerView::periodic () { - for (list<shared_ptr<JobView> >::iterator i = _job_records.begin(); i != _job_records.end(); ++i) { - (*i)->maybe_pulse (); + for (auto i: _job_records) { + i->maybe_pulse (); } } + void JobManagerView::replace () { /* Make a new version of _job_records which reflects the order in JobManager's job list */ - list<shared_ptr<JobView> > new_job_records; + list<shared_ptr<JobView>> new_job_records; for (auto i: JobManager::instance()->get()) { /* Find this job's JobView */ @@ -131,6 +139,7 @@ JobManagerView::replace () job_list_changed (); } + void JobManagerView::job_list_changed () { diff --git a/src/wx/job_manager_view.h b/src/wx/job_manager_view.h index 392d7504c..e960bc2f6 100644 --- a/src/wx/job_manager_view.h +++ b/src/wx/job_manager_view.h @@ -18,6 +18,7 @@ */ + /** @file src/job_manager_view.h * @brief Class which is a wxPanel for showing the progress of jobs. */ @@ -54,5 +55,5 @@ private: std::shared_ptr<wxTimer> _timer; bool _batch; - std::list<std::shared_ptr<JobView> > _job_records; + std::list<std::shared_ptr<JobView>> _job_records; }; diff --git a/src/wx/recipients_panel.cc b/src/wx/recipients_panel.cc index e59293fe7..58a986ca4 100644 --- a/src/wx/recipients_panel.cc +++ b/src/wx/recipients_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2020 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 "recipients_panel.h" #include "wx_util.h" #include "recipient_dialog.h" @@ -26,21 +27,23 @@ #include <list> #include <iostream> -using std::list; -using std::pair; + using std::cout; -using std::map; -using std::string; +using std::list; using std::make_pair; +using std::map; +using std::pair; using std::shared_ptr; +using std::string; using boost::optional; using namespace dcpomatic; + RecipientsPanel::RecipientsPanel (wxWindow* parent) : wxPanel (parent, wxID_ANY) , _ignore_selection_change (false) { - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + auto sizer = new wxBoxSizer (wxVERTICAL); #ifdef __WXGTK3__ int const height = 30; @@ -55,13 +58,13 @@ RecipientsPanel::RecipientsPanel (wxWindow* parent) #endif sizer->Add (_search, 0, wxBOTTOM, DCPOMATIC_SIZER_GAP); - wxBoxSizer* targets = new wxBoxSizer (wxHORIZONTAL); + auto targets = new wxBoxSizer (wxHORIZONTAL); _targets = new wxTreeCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT | wxTR_MULTIPLE | wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT); targets->Add (_targets, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_GAP); add_recipients (); - wxBoxSizer* target_buttons = new wxBoxSizer (wxVERTICAL); + auto target_buttons = new wxBoxSizer (wxVERTICAL); _add_recipient = new Button (this, _("Add...")); target_buttons->Add (_add_recipient, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); @@ -122,9 +125,9 @@ RecipientsPanel::add_recipient (shared_ptr<DKDMRecipient> r) void RecipientsPanel::add_recipient_clicked () { - RecipientDialog* d = new RecipientDialog (GetParent(), _("Add recipient")); + auto d = new RecipientDialog (GetParent(), _("Add recipient")); if (d->ShowModal() == wxID_OK) { - shared_ptr<DKDMRecipient> r (new DKDMRecipient(d->name(), d->notes(), d->recipient(), d->emails(), d->utc_offset_hour(), d->utc_offset_minute())); + auto r = std::make_shared<DKDMRecipient>(d->name(), d->notes(), d->recipient(), d->emails(), d->utc_offset_hour(), d->utc_offset_minute()); Config::instance()->add_dkdm_recipient (r); add_recipient (r); } @@ -140,9 +143,9 @@ RecipientsPanel::edit_recipient_clicked () return; } - pair<wxTreeItemId, shared_ptr<DKDMRecipient> > c = *_selected.begin(); + auto c = *_selected.begin(); - RecipientDialog* d = new RecipientDialog ( + auto d = new RecipientDialog ( GetParent(), _("Edit recipient"), c.second->name, c.second->notes, c.second->emails, c.second->utc_offset_hour, c.second->utc_offset_minute, c.second->recipient ); @@ -163,22 +166,22 @@ RecipientsPanel::edit_recipient_clicked () void RecipientsPanel::remove_recipient_clicked () { - for (RecipientMap::iterator i = _selected.begin(); i != _selected.end(); ++i) { - Config::instance()->remove_dkdm_recipient (i->second); - _targets->Delete (i->first); + for (auto const& i: _selected) { + Config::instance()->remove_dkdm_recipient (i.second); + _targets->Delete (i.first); } selection_changed (); } -list<shared_ptr<DKDMRecipient> > +list<shared_ptr<DKDMRecipient>> RecipientsPanel::recipients () const { - list<shared_ptr<DKDMRecipient> > r; + list<shared_ptr<DKDMRecipient>> r; - for (RecipientMap::const_iterator i = _selected.begin(); i != _selected.end(); ++i) { - r.push_back (i->second); + for (auto const& i: _selected) { + r.push_back (i.second); } r.sort (); @@ -240,10 +243,10 @@ RecipientsPanel::search_changed () _ignore_selection_change = true; - for (RecipientMap::const_iterator i = _selected.begin(); i != _selected.end(); ++i) { + for (auto const& i: _selected) { /* The wxTreeItemIds will now be different, so we must search by recipient */ - RecipientMap::const_iterator j = _recipients.begin (); - while (j != _recipients.end() && j->second != i->second) { + auto j = _recipients.begin (); + while (j != _recipients.end() && j->second != i.second) { ++j; } diff --git a/src/wx/recipients_panel.h b/src/wx/recipients_panel.h index d224eed1b..aacfccd9a 100644 --- a/src/wx/recipients_panel.h +++ b/src/wx/recipients_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2020 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 "lib/dkdm_recipient.h" #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS @@ -29,8 +30,10 @@ DCPOMATIC_ENABLE_WARNINGS #include <list> #include <map> + class DKDMRecipient; + class RecipientsPanel : public wxPanel { public: @@ -39,7 +42,7 @@ public: void setup_sensitivity (); - std::list<std::shared_ptr<DKDMRecipient> > recipients () const; + std::list<std::shared_ptr<DKDMRecipient>> recipients () const; boost::signals2::signal<void ()> RecipientsChanged; private: @@ -59,7 +62,7 @@ private: wxButton* _remove_recipient; wxTreeItemId _root; - typedef std::map<wxTreeItemId, std::shared_ptr<DKDMRecipient> > RecipientMap; + typedef std::map<wxTreeItemId, std::shared_ptr<DKDMRecipient>> RecipientMap; RecipientMap _recipients; RecipientMap _selected; diff --git a/src/wx/timeline_labels_view.cc b/src/wx/timeline_labels_view.cc index b0bd8acbb..4450fef05 100644 --- a/src/wx/timeline_labels_view.cc +++ b/src/wx/timeline_labels_view.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. @@ -24,9 +24,11 @@ #include <wx/wx.h> #include <wx/graphics.h> + using std::list; -using std::min; using std::max; +using std::min; + TimelineLabelsView::TimelineLabelsView (Timeline& tl) : TimelineView (tl) @@ -47,17 +49,19 @@ TimelineLabelsView::TimelineLabelsView (Timeline& tl) _width += 24; } + dcpomatic::Rect<int> TimelineLabelsView::bbox () const { return dcpomatic::Rect<int> (0, 0, _width, _timeline.tracks() * _timeline.pixels_per_track()); } + void -TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> >) +TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>>) { int const h = _timeline.pixels_per_track (); - gc->SetFont (gc->CreateFont(wxNORMAL_FONT->Bold(), wxColour (0, 0, 0))); + gc->SetFont (gc->CreateFont(wxNORMAL_FONT->Bold(), wxColour(0, 0, 0))); int fy = 0; if (_video_tracks) { @@ -84,24 +88,28 @@ TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> > } } + void TimelineLabelsView::set_video_tracks (int n) { _video_tracks = n; } + void TimelineLabelsView::set_audio_tracks (int n) { _audio_tracks = n; } + void TimelineLabelsView::set_text_tracks (int n) { _text_tracks = n; } + void TimelineLabelsView::set_atmos (bool s) { diff --git a/src/wx/timeline_labels_view.h b/src/wx/timeline_labels_view.h index 88094f2c4..2ff1fa6a8 100644 --- a/src/wx/timeline_labels_view.h +++ b/src/wx/timeline_labels_view.h @@ -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,10 +18,13 @@ */ + #include "timeline_view.h" + class wxWindow; + class TimelineLabelsView : public TimelineView { public: @@ -35,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); int _width = 0; int _video_tracks = 0; |
