From 4704d088ae03ab2b5f73ceed577fd84935ad0640 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 7 Sep 2015 15:02:08 +0100 Subject: [PATCH] Some use of BOOST_FOREACH. --- src/lib/film.cc | 10 ++-- src/lib/playlist.cc | 56 ++++++++++----------- src/wx/content_menu.cc | 27 +++++----- src/wx/content_panel.cc | 69 ++++++++++++------------- src/wx/dolby_certificate_dialog.cc | 26 +++++----- src/wx/hints_dialog.cc | 12 ++--- src/wx/subtitle_panel.cc | 30 +++++------ src/wx/timeline.cc | 15 +++--- src/wx/timing_panel.cc | 81 +++++++++++++----------------- src/wx/video_panel.cc | 23 ++++----- src/wx/video_panel.h | 1 + 11 files changed, 162 insertions(+), 188 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index 231ac92e1..e48b08f3b 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -558,15 +558,13 @@ Film::isdcf_name (bool if_created_now) const d << "_" << container()->isdcf_name(); } - ContentList cl = content (); - /* XXX: this uses the first bit of content only */ /* The standard says we don't do this for trailers, for some strange reason */ if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) { Ratio const * content_ratio = 0; - for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { - shared_ptr vc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, content ()) { + shared_ptr vc = dynamic_pointer_cast (i); if (vc) { /* Here's the first piece of video content */ if (vc->scale().ratio ()) { @@ -617,8 +615,8 @@ Film::isdcf_name (bool if_created_now) const } } else { list mapped; - for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { - shared_ptr ac = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, content ()) { + shared_ptr ac = dynamic_pointer_cast (i); if (ac) { list c = ac->audio_mapping().mapped_output_channels (); copy (c.begin(), c.end(), back_inserter (mapped)); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 89421097c..a1b209a11 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include "i18n.h" @@ -87,8 +88,8 @@ Playlist::maybe_sequence_video () DCPTime next_left; DCPTime next_right; - for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - shared_ptr vc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _content) { + shared_ptr vc = dynamic_pointer_cast (i); if (!vc) { continue; } @@ -112,9 +113,9 @@ Playlist::video_identifier () const { string t; - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - shared_ptr vc = dynamic_pointer_cast (*i); - shared_ptr sc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _content) { + shared_ptr vc = dynamic_pointer_cast (i); + shared_ptr sc = dynamic_pointer_cast (i); if (vc) { t += vc->identifier (); } else if (sc && sc->burn_subtitles ()) { @@ -131,9 +132,8 @@ Playlist::video_identifier () const void Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, int version, list& notes) { - list c = node->node_children ("Content"); - for (list::iterator i = c.begin(); i != c.end(); ++i) { - _content.push_back (content_factory (film, *i, version, notes)); + BOOST_FOREACH (cxml::NodePtr i, node->node_children ("Content")) { + _content.push_back (content_factory (film, i, version, notes)); } sort (_content.begin(), _content.end(), ContentSorter ()); @@ -145,8 +145,8 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in void Playlist::as_xml (xmlpp::Node* node) { - for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - (*i)->as_xml (node->add_child ("Content")); + BOOST_FOREACH (shared_ptr i, _content) { + i->as_xml (node->add_child ("Content")); } } @@ -178,9 +178,9 @@ Playlist::remove (shared_ptr c) void Playlist::remove (ContentList c) { - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { + BOOST_FOREACH (shared_ptr i, c) { ContentList::iterator j = _content.begin (); - while (j != _content.end() && *j != *i) { + while (j != _content.end() && *j != i) { ++j; } @@ -232,8 +232,8 @@ Playlist::best_dcp_frame_rate () const while (i != candidates.end()) { float this_error = 0; - for (ContentList::const_iterator j = _content.begin(); j != _content.end(); ++j) { - shared_ptr vc = dynamic_pointer_cast (*j); + BOOST_FOREACH (shared_ptr j, _content) { + shared_ptr vc = dynamic_pointer_cast (j); if (!vc) { continue; } @@ -267,8 +267,8 @@ DCPTime Playlist::length () const { DCPTime len; - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - len = max (len, (*i)->end()); + BOOST_FOREACH (shared_ptr i, _content) { + len = max (len, i->end()); } return len; @@ -283,8 +283,8 @@ Playlist::reconnect () _content_connections.clear (); - for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2, _3))); + BOOST_FOREACH (shared_ptr i, _content) { + _content_connections.push_back (i->Changed.connect (bind (&Playlist::content_changed, this, _1, _2, _3))); } } @@ -292,9 +292,9 @@ DCPTime Playlist::video_end () const { DCPTime end; - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - if (dynamic_pointer_cast (*i)) { - end = max (end, (*i)->end ()); + BOOST_FOREACH (shared_ptr i, _content) { + if (dynamic_pointer_cast (i)) { + end = max (end, i->end ()); } } @@ -344,17 +344,17 @@ void Playlist::repeat (ContentList c, int n) { pair range (DCPTime::max (), DCPTime ()); - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - range.first = min (range.first, (*i)->position ()); - range.second = max (range.second, (*i)->position ()); - range.first = min (range.first, (*i)->end ()); - range.second = max (range.second, (*i)->end ()); + BOOST_FOREACH (shared_ptr i, c) { + range.first = min (range.first, i->position ()); + range.second = max (range.second, i->position ()); + range.first = min (range.first, i->end ()); + range.second = max (range.second, i->end ()); } DCPTime pos = range.second; for (int i = 0; i < n; ++i) { - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr copy = (*i)->clone (); + BOOST_FOREACH (shared_ptr j, c) { + shared_ptr copy = j->clone (); copy->set_position (pos + copy->position() - range.first); _content.push_back (copy); } diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index a1d412b62..56504c992 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -34,6 +34,7 @@ #include "lib/ffmpeg_content.h" #include #include +#include using std::cout; using std::vector; @@ -88,8 +89,8 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _repeat->Enable (!_content.empty ()); int n = 0; - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - if (dynamic_pointer_cast (*i)) { + BOOST_FOREACH (shared_ptr i, _content) { + if (dynamic_pointer_cast (i)) { ++n; } } @@ -140,8 +141,8 @@ void ContentMenu::join () { vector > fc; - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - shared_ptr f = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _content) { + shared_ptr f = dynamic_pointer_cast (i); if (f) { fc.push_back (f); } @@ -156,8 +157,8 @@ ContentMenu::join () try { shared_ptr joined (new FFmpegContent (film, fc)); - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - film->remove_content (*i); + BOOST_FOREACH (shared_ptr i, _content) { + film->remove_content (i); } film->add_content (joined); } catch (JoinError& e) { @@ -183,8 +184,8 @@ ContentMenu::remove () /* Special case: we only remove FFmpegContent if its video view is selected; if not, and its audio view is selected, we unmap the audio. */ - for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - shared_ptr fc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _content) { + shared_ptr fc = dynamic_pointer_cast (i); if (!fc) { continue; } @@ -192,9 +193,9 @@ ContentMenu::remove () shared_ptr video; shared_ptr audio; - for (TimelineContentViewList::iterator i = _views.begin(); i != _views.end(); ++i) { - shared_ptr v = dynamic_pointer_cast (*i); - shared_ptr a = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr j, _views) { + shared_ptr v = dynamic_pointer_cast (j); + shared_ptr a = dynamic_pointer_cast (j); if (v && v->content() == fc) { video = v; } else if (a && a->content() == fc) { @@ -283,8 +284,8 @@ ContentMenu::re_examine () return; } - for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - film->examine_content (*i); + BOOST_FOREACH (shared_ptr i, _content) { + film->examine_content (i); } } diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 65fdf588c..066c3e93c 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -17,14 +17,6 @@ */ -#include "lib/audio_content.h" -#include "lib/subtitle_content.h" -#include "lib/video_content.h" -#include "lib/ffmpeg_content.h" -#include "lib/content_factory.h" -#include "lib/image_content.h" -#include "lib/dcp_content.h" -#include "lib/playlist.h" #include "content_panel.h" #include "wx_util.h" #include "video_panel.h" @@ -33,10 +25,19 @@ #include "timing_panel.h" #include "timeline_dialog.h" #include "image_sequence_dialog.h" +#include "lib/audio_content.h" +#include "lib/subtitle_content.h" +#include "lib/video_content.h" +#include "lib/ffmpeg_content.h" +#include "lib/content_factory.h" +#include "lib/image_content.h" +#include "lib/dcp_content.h" +#include "lib/playlist.h" #include #include #include #include +#include #include "lib/image_filename_sorter.cc" @@ -147,11 +148,10 @@ ContentPanel::selected () VideoContentList ContentPanel::selected_video () { - ContentList c = selected (); VideoContentList vc; - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr t = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, selected ()) { + shared_ptr t = dynamic_pointer_cast (i); if (t) { vc.push_back (t); } @@ -163,11 +163,10 @@ ContentPanel::selected_video () AudioContentList ContentPanel::selected_audio () { - ContentList c = selected (); AudioContentList ac; - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr t = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, selected ()) { + shared_ptr t = dynamic_pointer_cast (i); if (t) { ac.push_back (t); } @@ -179,11 +178,10 @@ ContentPanel::selected_audio () SubtitleContentList ContentPanel::selected_subtitle () { - ContentList c = selected (); SubtitleContentList sc; - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr t = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, selected ()) { + shared_ptr t = dynamic_pointer_cast (i); if (t) { sc.push_back (t); } @@ -195,11 +193,10 @@ ContentPanel::selected_subtitle () FFmpegContentList ContentPanel::selected_ffmpeg () { - ContentList c = selected (); FFmpegContentList sc; - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr t = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, selected ()) { + shared_ptr t = dynamic_pointer_cast (i); if (t) { sc.push_back (t); } @@ -219,8 +216,8 @@ ContentPanel::film_changed (Film::Property p) break; } - for (list::iterator i = _panels.begin(); i != _panels.end(); ++i) { - (*i)->film_changed (p); + BOOST_FOREACH (ContentSubPanel* i, _panels) { + i->film_changed (p); } } @@ -229,8 +226,8 @@ ContentPanel::selection_changed () { setup_sensitivity (); - for (list::iterator i = _panels.begin(); i != _panels.end(); ++i) { - (*i)->content_selection_changed (); + BOOST_FOREACH (ContentSubPanel* i, _panels) { + i->content_selection_changed (); } } @@ -372,8 +369,8 @@ ContentPanel::set_general_sensitivity (bool s) _timeline->Enable (s); /* Set the panels in the content notebook */ - for (list::iterator i = _panels.begin(); i != _panels.end(); ++i) { - (*i)->Enable (s); + BOOST_FOREACH (ContentSubPanel* i, _panels) { + i->Enable (s); } } @@ -417,8 +414,8 @@ ContentPanel::film_content_changed (int property) setup (); } - for (list::iterator i = _panels.begin(); i != _panels.end(); ++i) { - (*i)->film_content_changed (property); + BOOST_FOREACH (ContentSubPanel* i, _panels) { + i->film_content_changed (property); } } @@ -438,10 +435,10 @@ ContentPanel::setup () } vector proposed; - for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { - bool const valid = (*i)->paths_valid (); + BOOST_FOREACH (shared_ptr i, content) { + bool const valid = i->paths_valid (); - string s = (*i)->summary (); + string s = i->summary (); if (!valid) { s = _("MISSING: ") + s; } @@ -463,13 +460,13 @@ ContentPanel::setup () _content->DeleteAllItems (); - for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { + BOOST_FOREACH (shared_ptr i, content) { int const t = _content->GetItemCount (); - bool const valid = (*i)->paths_valid (); - shared_ptr dcp = dynamic_pointer_cast (*i); + bool const valid = i->paths_valid (); + shared_ptr dcp = dynamic_pointer_cast (i); bool const needs_kdm = dcp && !dcp->can_be_played (); - string s = (*i)->summary (); + string s = i->summary (); if (!valid) { s = _("MISSING: ") + s; @@ -481,7 +478,7 @@ ContentPanel::setup () _content->InsertItem (t, std_to_wx (s)); - if ((*i)->summary() == selected_summary) { + if (i->summary() == selected_summary) { _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); } diff --git a/src/wx/dolby_certificate_dialog.cc b/src/wx/dolby_certificate_dialog.cc index 49c2f01d7..72a70b7e1 100644 --- a/src/wx/dolby_certificate_dialog.cc +++ b/src/wx/dolby_certificate_dialog.cc @@ -17,13 +17,14 @@ */ -#include -#include +#include "dolby_certificate_dialog.h" +#include "wx_util.h" #include "lib/compose.hpp" #include "lib/internet.h" #include "lib/signal_manager.h" -#include "dolby_certificate_dialog.h" -#include "wx_util.h" +#include +#include +#include using std::list; using std::string; @@ -86,10 +87,9 @@ DolbyCertificateDialog::setup_countries () void DolbyCertificateDialog::finish_setup_countries () { - list const countries = get_dir (""); _country->Clear (); - for (list::const_iterator i = countries.begin(); i != countries.end(); ++i) { - _country->Append (std_to_wx (*i)); + BOOST_FOREACH (string i, get_dir ("")) { + _country->Append (std_to_wx (i)); } } @@ -109,10 +109,9 @@ DolbyCertificateDialog::country_selected () void DolbyCertificateDialog::finish_country_selected () { - list const cinemas = get_dir (wx_to_std (_country->GetStringSelection())); _cinema->Clear (); - for (list::const_iterator i = cinemas.begin(); i != cinemas.end(); ++i) { - _cinema->Append (std_to_wx (*i)); + BOOST_FOREACH (string i, get_dir (wx_to_std (_country->GetStringSelection()))) { + _cinema->Append (std_to_wx (i)); } } @@ -133,14 +132,13 @@ void DolbyCertificateDialog::finish_cinema_selected () { string const dir = String::compose ("%1/%2", wx_to_std (_country->GetStringSelection()), wx_to_std (_cinema->GetStringSelection())); - list const zips = get_dir (dir); _serial->Clear (); - for (list::const_iterator i = zips.begin(); i != zips.end(); ++i) { + BOOST_FOREACH (string i, get_dir (dir)) { vector a; - split (a, *i, is_any_of ("-_")); + split (a, i, is_any_of ("-_")); if (a.size() >= 4) { - _serial->Append (std_to_wx (a[3]), new wxStringClientData (std_to_wx (*i))); + _serial->Append (std_to_wx (a[3]), new wxStringClientData (std_to_wx (i))); } } } diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc index 36c9eb6c8..66a53c559 100644 --- a/src/wx/hints_dialog.cc +++ b/src/wx/hints_dialog.cc @@ -109,8 +109,8 @@ HintsDialog::film_changed () int flat_or_narrower = 0; int scope = 0; - for (ContentList::const_iterator i = content.begin(); i != content.end(); ++i) { - shared_ptr vc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, content) { + shared_ptr vc = dynamic_pointer_cast (i); if (vc) { Ratio const * r = vc->scale().ratio (); if (r && r->id() == "239") { @@ -146,8 +146,8 @@ HintsDialog::film_changed () } int vob = 0; - for (ContentList::const_iterator i = content.begin(); i != content.end(); ++i) { - if (boost::algorithm::starts_with ((*i)->path(0).filename().string(), "VTS_")) { + BOOST_FOREACH (shared_ptr i, content) { + if (boost::algorithm::starts_with (i->path(0).filename().string(), "VTS_")) { ++vob; } } @@ -159,8 +159,8 @@ HintsDialog::film_changed () } int three_d = 0; - for (ContentList::const_iterator i = content.begin(); i != content.end(); ++i) { - shared_ptr vc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, content) { + shared_ptr vc = dynamic_pointer_cast (i); if (vc && vc->video_frame_type() != VIDEO_FRAME_TYPE_2D) { ++three_d; } diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index d99b54558..40a48a5a2 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -184,18 +184,16 @@ SubtitlePanel::film_content_changed (int property) void SubtitlePanel::use_toggled () { - SubtitleContentList c = _parent->selected_subtitle (); - for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_use_subtitles (_use->GetValue()); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->set_use_subtitles (_use->GetValue()); } } void SubtitlePanel::burn_toggled () { - SubtitleContentList c = _parent->selected_subtitle (); - for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_burn_subtitles (_burn->GetValue()); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->set_burn_subtitles (_burn->GetValue()); } } @@ -267,18 +265,16 @@ SubtitlePanel::stream_changed () void SubtitlePanel::x_offset_changed () { - SubtitleContentList c = _parent->selected_subtitle (); - for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_subtitle_x_offset (_x_offset->GetValue() / 100.0); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->set_subtitle_x_offset (_x_offset->GetValue() / 100.0); } } void SubtitlePanel::y_offset_changed () { - SubtitleContentList c = _parent->selected_subtitle (); - for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_subtitle_y_offset (_y_offset->GetValue() / 100.0); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->set_subtitle_y_offset (_y_offset->GetValue() / 100.0); } } @@ -294,18 +290,16 @@ SubtitlePanel::x_scale_changed () void SubtitlePanel::y_scale_changed () { - SubtitleContentList c = _parent->selected_subtitle (); - for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_subtitle_y_scale (_y_scale->GetValue() / 100.0); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->set_subtitle_y_scale (_y_scale->GetValue() / 100.0); } } void SubtitlePanel::language_changed () { - SubtitleContentList c = _parent->selected_subtitle (); - for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_subtitle_language (wx_to_std (_language->GetValue())); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->set_subtitle_language (wx_to_std (_language->GetValue())); } } diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 9a9dfc26d..12fd738eb 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -32,6 +32,7 @@ #include "lib/subtitle_content.h" #include #include +#include #include using std::list; @@ -111,19 +112,17 @@ Timeline::recreate_views () _views.clear (); _views.push_back (_time_axis_view); - ContentList content = film->content (); - - for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { - if (dynamic_pointer_cast (*i)) { - _views.push_back (shared_ptr (new TimelineVideoContentView (*this, *i))); + BOOST_FOREACH (shared_ptr i, film->content ()) { + if (dynamic_pointer_cast (i)) { + _views.push_back (shared_ptr (new TimelineVideoContentView (*this, i))); } - shared_ptr ac = dynamic_pointer_cast (*i); + shared_ptr ac = dynamic_pointer_cast (i); if (ac && !ac->audio_mapping().mapped_output_channels().empty ()) { - _views.push_back (shared_ptr (new TimelineAudioContentView (*this, *i))); + _views.push_back (shared_ptr (new TimelineAudioContentView (*this, i))); } - shared_ptr sc = dynamic_pointer_cast (*i); + shared_ptr sc = dynamic_pointer_cast (i); if (sc && sc->has_subtitles ()) { _views.push_back (shared_ptr (new TimelineSubtitleContentView (*this, sc))); } diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 53e109224..1497c2322 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -147,15 +147,13 @@ TimingPanel::TimingPanel (ContentPanel* p, FilmViewer* viewer) void TimingPanel::update_full_length () { - ContentList cl = _parent->selected (); - set check; - for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) { - check.insert ((*i)->full_length ()); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + check.insert (i->full_length ()); } if (check.size() == 1) { - _full_length->set (cl.front()->full_length (), _parent->film()->video_frame_rate ()); + _full_length->set (_parent->selected().front()->full_length (), _parent->film()->video_frame_rate ()); } else { _full_length->clear (); } @@ -164,15 +162,13 @@ TimingPanel::update_full_length () void TimingPanel::update_play_length () { - ContentList cl = _parent->selected (); - set check; - for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) { - check.insert ((*i)->length_after_trim ()); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + check.insert (i->length_after_trim ()); } if (check.size() == 1) { - _play_length->set (cl.front()->length_after_trim (), _parent->film()->video_frame_rate ()); + _play_length->set (_parent->selected().front()->length_after_trim (), _parent->film()->video_frame_rate ()); } else { _play_length->clear (); } @@ -181,7 +177,6 @@ TimingPanel::update_play_length () void TimingPanel::film_content_changed (int property) { - ContentList cl = _parent->selected (); int const film_video_frame_rate = _parent->film()->video_frame_rate (); /* Here we check to see if we have exactly one different value of various @@ -191,12 +186,12 @@ TimingPanel::film_content_changed (int property) if (property == ContentProperty::POSITION) { set check; - for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) { - check.insert ((*i)->position ()); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + check.insert (i->position ()); } if (check.size() == 1) { - _position->set (cl.front()->position(), film_video_frame_rate); + _position->set (_parent->selected().front()->position(), film_video_frame_rate); } else { _position->clear (); } @@ -212,12 +207,12 @@ TimingPanel::film_content_changed (int property) } else if (property == ContentProperty::TRIM_START) { set check; - for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) { - check.insert ((*i)->trim_start ()); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + check.insert (i->trim_start ()); } if (check.size() == 1) { - _trim_start->set (cl.front()->trim_start (), film_video_frame_rate); + _trim_start->set (_parent->selected().front()->trim_start (), film_video_frame_rate); } else { _trim_start->clear (); } @@ -225,12 +220,12 @@ TimingPanel::film_content_changed (int property) } else if (property == ContentProperty::TRIM_END) { set check; - for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) { - check.insert ((*i)->trim_end ()); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + check.insert (i->trim_end ()); } if (check.size() == 1) { - _trim_end->set (cl.front()->trim_end (), film_video_frame_rate); + _trim_end->set (_parent->selected().front()->trim_end (), film_video_frame_rate); } else { _trim_end->clear (); } @@ -249,9 +244,9 @@ TimingPanel::film_content_changed (int property) if (property == VideoContentProperty::VIDEO_FRAME_RATE) { set check; - shared_ptr vc; - for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) { - shared_ptr t = dynamic_pointer_cast (*i); + shared_ptr vc; + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + shared_ptr t = dynamic_pointer_cast (i); if (t) { check.insert (t->video_frame_rate ()); vc = t; @@ -267,8 +262,8 @@ TimingPanel::film_content_changed (int property) } bool have_still = false; - for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) { - shared_ptr ic = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + shared_ptr ic = dynamic_pointer_cast (i); if (ic && ic->still ()) { have_still = true; } @@ -282,18 +277,16 @@ TimingPanel::film_content_changed (int property) void TimingPanel::position_changed () { - ContentList c = _parent->selected (); - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_position (_position->get (_parent->film()->video_frame_rate ())); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + i->set_position (_position->get (_parent->film()->video_frame_rate ())); } } void TimingPanel::full_length_changed () { - ContentList c = _parent->selected (); - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr ic = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + shared_ptr ic = dynamic_pointer_cast (i); if (ic && ic->still ()) { int const vfr = _parent->film()->video_frame_rate (); ic->set_video_length (_full_length->get (vfr).frames_round (vfr)); @@ -304,9 +297,8 @@ TimingPanel::full_length_changed () void TimingPanel::trim_start_changed () { - ContentList c = _parent->selected (); - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_trim_start (_trim_start->get (_parent->film()->video_frame_rate ())); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + i->set_trim_start (_trim_start->get (_parent->film()->video_frame_rate ())); } } @@ -314,21 +306,19 @@ TimingPanel::trim_start_changed () void TimingPanel::trim_end_changed () { - ContentList c = _parent->selected (); - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - (*i)->set_trim_end (_trim_end->get (_parent->film()->video_frame_rate ())); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + i->set_trim_end (_trim_end->get (_parent->film()->video_frame_rate ())); } } void TimingPanel::play_length_changed () { - ContentList c = _parent->selected (); - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - FrameRateChange const frc = _parent->film()->active_frame_rate_change ((*i)->position ()); - (*i)->set_trim_end ( - ContentTime ((*i)->full_length() - _play_length->get (_parent->film()->video_frame_rate()), frc) - - (*i)->trim_start () + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + FrameRateChange const frc = _parent->film()->active_frame_rate_change (i->position ()); + i->set_trim_end ( + ContentTime (i->full_length() - _play_length->get (_parent->film()->video_frame_rate()), frc) + - i->trim_start () ); } } @@ -342,9 +332,8 @@ TimingPanel::video_frame_rate_changed () void TimingPanel::set_video_frame_rate () { - ContentList c = _parent->selected (); - for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr vc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + shared_ptr vc = dynamic_pointer_cast (i); if (vc) { vc->set_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); } diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 68ff7c369..f85fdae7b 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -210,10 +210,9 @@ VideoPanel::VideoPanel (ContentPanel* p) _right_crop->wrapped()->SetRange (0, 1024); _bottom_crop->wrapped()->SetRange (0, 1024); - vector scales = VideoContentScale::all (); _scale->wrapped()->Clear (); - for (vector::iterator i = scales.begin(); i != scales.end(); ++i) { - _scale->wrapped()->Append (std_to_wx (i->name ())); + BOOST_FOREACH (VideoContentScale const & i, VideoContentScale::all ()) { + _scale->wrapped()->Append (std_to_wx (i.name ())); } _frame_type->wrapped()->Append (_("2D")); @@ -296,8 +295,8 @@ VideoPanel::film_content_changed (int property) } } else if (property == VideoContentProperty::VIDEO_FADE_IN) { set check; - for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) { - check.insert ((*i)->fade_in ()); + BOOST_FOREACH (shared_ptr i, vc) { + check.insert (i->fade_in ()); } if (check.size() == 1) { @@ -307,8 +306,8 @@ VideoPanel::film_content_changed (int property) } } else if (property == VideoContentProperty::VIDEO_FADE_OUT) { set check; - for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) { - check.insert ((*i)->fade_out ()); + BOOST_FOREACH (shared_ptr i, vc) { + check.insert (i->fade_out ()); } if (check.size() == 1) { @@ -423,19 +422,17 @@ VideoPanel::content_selection_changed () void VideoPanel::fade_in_changed () { - VideoContentList vc = _parent->selected_video (); - for (VideoContentList::const_iterator i = vc.begin(); i != vc.end(); ++i) { + BOOST_FOREACH (shared_ptr i, _parent->selected_video ()) { int const vfr = _parent->film()->video_frame_rate (); - (*i)->set_fade_in (_fade_in->get (vfr).frames_round (vfr)); + i->set_fade_in (_fade_in->get (vfr).frames_round (vfr)); } } void VideoPanel::fade_out_changed () { - VideoContentList vc = _parent->selected_video (); - for (VideoContentList::const_iterator i = vc.begin(); i != vc.end(); ++i) { + BOOST_FOREACH (shared_ptr i, _parent->selected_video ()) { int const vfr = _parent->film()->video_frame_rate (); - (*i)->set_fade_out (_fade_out->get (vfr).frames_round (vfr)); + i->set_fade_out (_fade_out->get (vfr).frames_round (vfr)); } } diff --git a/src/wx/video_panel.h b/src/wx/video_panel.h index d90612fdd..b4b4c7766 100644 --- a/src/wx/video_panel.h +++ b/src/wx/video_panel.h @@ -24,6 +24,7 @@ #include "content_sub_panel.h" #include "content_widget.h" #include "timecode.h" +#include "lib/video_content_scale.h" #include "lib/film.h" class wxChoice; -- 2.30.2