Some use of BOOST_FOREACH.
authorCarl Hetherington <cth@carlh.net>
Mon, 7 Sep 2015 14:02:08 +0000 (15:02 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 Sep 2015 09:21:13 +0000 (10:21 +0100)
src/lib/film.cc
src/lib/playlist.cc
src/wx/content_menu.cc
src/wx/content_panel.cc
src/wx/dolby_certificate_dialog.cc
src/wx/hints_dialog.cc
src/wx/subtitle_panel.cc
src/wx/timeline.cc
src/wx/timing_panel.cc
src/wx/video_panel.cc
src/wx/video_panel.h

index 231ac92e19daf13affba40b10a2d66650c323e19..e48b08f3b70b7216b6035c7750b22df3cdbcd942 100644 (file)
@@ -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<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i);
+               BOOST_FOREACH (shared_ptr<Content> i, content ()) {
+                       shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (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<int> mapped;
-               for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) {
-                       shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (*i);
+               BOOST_FOREACH (shared_ptr<Content> i, content ()) {
+                       shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (i);
                        if (ac) {
                                list<int> c = ac->audio_mapping().mapped_output_channels ();
                                copy (c.begin(), c.end(), back_inserter (mapped));
index 89421097cd26829647ebf079e3805dcd4916a08d..a1b209a1199cafc94c4fa1544160615f446d7526 100644 (file)
@@ -32,6 +32,7 @@
 #include <libcxml/cxml.h>
 #include <libxml++/libxml++.h>
 #include <boost/shared_ptr.hpp>
+#include <boost/foreach.hpp>
 
 #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<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, _content) {
+               shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (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<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i);
-               shared_ptr<const SubtitleContent> sc = dynamic_pointer_cast<const SubtitleContent> (*i);
+       BOOST_FOREACH (shared_ptr<const Content> i, _content) {
+               shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (i);
+               shared_ptr<const SubtitleContent> sc = dynamic_pointer_cast<const SubtitleContent> (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<const Film> film, cxml::ConstNodePtr node, int version, list<string>& notes)
 {
-       list<cxml::NodePtr> c = node->node_children ("Content");
-       for (list<cxml::NodePtr>::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<const Film> 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<Content> i, _content) {
+               i->as_xml (node->add_child ("Content"));
        }
 }
 
@@ -178,9 +178,9 @@ Playlist::remove (shared_ptr<Content> c)
 void
 Playlist::remove (ContentList c)
 {
-       for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+       BOOST_FOREACH (shared_ptr<Content> 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<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*j);
+               BOOST_FOREACH (shared_ptr<Content> j, _content) {
+                       shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (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<const Content> 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<Content> 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<const VideoContent> (*i)) {
-                       end = max (end, (*i)->end ());
+       BOOST_FOREACH (shared_ptr<Content> i, _content) {
+               if (dynamic_pointer_cast<const VideoContent> (i)) {
+                       end = max (end, i->end ());
                }
        }
 
@@ -344,17 +344,17 @@ void
 Playlist::repeat (ContentList c, int n)
 {
        pair<DCPTime, DCPTime> 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<Content> 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<Content> copy = (*i)->clone ();
+               BOOST_FOREACH (shared_ptr<Content> j, c) {
+                       shared_ptr<Content> copy = j->clone ();
                        copy->set_position (pos + copy->position() - range.first);
                        _content.push_back (copy);
                }
index a1d412b62ea6344a61c3e6d6d1b5b20aeb266e36..56504c9920c8eabc94b63d23a9e621dcec5d511b 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/ffmpeg_content.h"
 #include <wx/wx.h>
 #include <wx/dirdlg.h>
+#include <boost/foreach.hpp>
 
 using std::cout;
 using std::vector;
@@ -88,8 +89,8 @@ ContentMenu::popup (weak_ptr<Film> 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<FFmpegContent> (*i)) {
+       BOOST_FOREACH (shared_ptr<Content> i, _content) {
+               if (dynamic_pointer_cast<FFmpegContent> (i)) {
                        ++n;
                }
        }
@@ -140,8 +141,8 @@ void
 ContentMenu::join ()
 {
        vector<shared_ptr<Content> > fc;
-       for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
-               shared_ptr<FFmpegContent> f = dynamic_pointer_cast<FFmpegContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, _content) {
+               shared_ptr<FFmpegContent> f = dynamic_pointer_cast<FFmpegContent> (i);
                if (f) {
                        fc.push_back (f);
                }
@@ -156,8 +157,8 @@ ContentMenu::join ()
 
        try {
                shared_ptr<FFmpegContent> joined (new FFmpegContent (film, fc));
-               for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
-                       film->remove_content (*i);
+               BOOST_FOREACH (shared_ptr<Content> 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<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (*i);
+               BOOST_FOREACH (shared_ptr<Content> i, _content) {
+                       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (i);
                        if (!fc) {
                                continue;
                        }
@@ -192,9 +193,9 @@ ContentMenu::remove ()
                        shared_ptr<TimelineVideoContentView> video;
                        shared_ptr<TimelineAudioContentView> audio;
 
-                       for (TimelineContentViewList::iterator i = _views.begin(); i != _views.end(); ++i) {
-                               shared_ptr<TimelineVideoContentView> v = dynamic_pointer_cast<TimelineVideoContentView> (*i);
-                               shared_ptr<TimelineAudioContentView> a = dynamic_pointer_cast<TimelineAudioContentView> (*i);
+                       BOOST_FOREACH (shared_ptr<TimelineContentView> j, _views) {
+                               shared_ptr<TimelineVideoContentView> v = dynamic_pointer_cast<TimelineVideoContentView> (j);
+                               shared_ptr<TimelineAudioContentView> a = dynamic_pointer_cast<TimelineAudioContentView> (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<Content> i, _content) {
+               film->examine_content (i);
        }
 }
 
index 65fdf588cefb8f2faa7884ffa1dd99eb49733766..066c3e93cadba2a126868391f0213daa7ec73e87 100644 (file)
 
 */
 
-#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"
 #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 <wx/wx.h>
 #include <wx/notebook.h>
 #include <wx/listctrl.h>
 #include <boost/filesystem.hpp>
+#include <boost/foreach.hpp>
 
 #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<VideoContent> t = dynamic_pointer_cast<VideoContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
+               shared_ptr<VideoContent> t = dynamic_pointer_cast<VideoContent> (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<AudioContent> t = dynamic_pointer_cast<AudioContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
+               shared_ptr<AudioContent> t = dynamic_pointer_cast<AudioContent> (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<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
+               shared_ptr<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (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<FFmpegContent> t = dynamic_pointer_cast<FFmpegContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
+               shared_ptr<FFmpegContent> t = dynamic_pointer_cast<FFmpegContent> (i);
                if (t) {
                        sc.push_back (t);
                }
@@ -219,8 +216,8 @@ ContentPanel::film_changed (Film::Property p)
                break;
        }
 
-       for (list<ContentSubPanel*>::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<ContentSubPanel*>::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<ContentSubPanel*>::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<ContentSubPanel*>::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<string> proposed;
-       for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
-               bool const valid = (*i)->paths_valid ();
+       BOOST_FOREACH (shared_ptr<Content> 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<Content> i, content) {
                int const t = _content->GetItemCount ();
-               bool const valid = (*i)->paths_valid ();
-               shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (*i);
+               bool const valid = i->paths_valid ();
+               shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (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);
                }
 
index 49c2f01d755ee18ec3288c9c053d771a05a33e41..72a70b7e103fa573128375a88c4a6133c9a8c76d 100644 (file)
 
 */
 
-#include <boost/algorithm/string.hpp>
-#include <curl/curl.h>
+#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 <curl/curl.h>
+#include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
 
 using std::list;
 using std::string;
@@ -86,10 +87,9 @@ DolbyCertificateDialog::setup_countries ()
 void
 DolbyCertificateDialog::finish_setup_countries ()
 {
-       list<string> const countries = get_dir ("");
        _country->Clear ();
-       for (list<string>::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<string> const cinemas = get_dir (wx_to_std (_country->GetStringSelection()));
        _cinema->Clear ();
-       for (list<string>::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<string> const zips = get_dir (dir);
 
        _serial->Clear ();
-       for (list<string>::const_iterator i = zips.begin(); i != zips.end(); ++i) {
+       BOOST_FOREACH (string i, get_dir (dir)) {
                vector<string> 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)));
                }
        }
 }
index 36c9eb6c8e54f4ddefc311a19b5620d124c58a04..66a53c5594a9cb14f61c40b567c7313accc35308 100644 (file)
@@ -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<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i);
+       BOOST_FOREACH (shared_ptr<const Content> i, content) {
+               shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (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<const Content> 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<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i);
+       BOOST_FOREACH (shared_ptr<const Content> i, content) {
+               shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (i);
                if (vc && vc->video_frame_type() != VIDEO_FRAME_TYPE_2D) {
                        ++three_d;
                }
index d99b545587393104aeb1f0731d1a8b0f3b3ebd42..40a48a5a283496bcd2b7b6679c85de9459ef9467 100644 (file)
@@ -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<SubtitleContent> 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<SubtitleContent> 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<SubtitleContent> 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<SubtitleContent> 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<SubtitleContent> 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<SubtitleContent> i, _parent->selected_subtitle ()) {
+               i->set_subtitle_language (wx_to_std (_language->GetValue()));
        }
 }
 
index 9a9dfc26d764ec08efb038e1f27427d83b165672..12fd738eb5807963c407ab005e77808d57d3cd76 100644 (file)
@@ -32,6 +32,7 @@
 #include "lib/subtitle_content.h"
 #include <wx/graphics.h>
 #include <boost/weak_ptr.hpp>
+#include <boost/foreach.hpp>
 #include <list>
 
 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<VideoContent> (*i)) {
-                       _views.push_back (shared_ptr<TimelineView> (new TimelineVideoContentView (*this, *i)));
+       BOOST_FOREACH (shared_ptr<Content> i, film->content ()) {
+               if (dynamic_pointer_cast<VideoContent> (i)) {
+                       _views.push_back (shared_ptr<TimelineView> (new TimelineVideoContentView (*this, i)));
                }
 
-               shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (*i);
+               shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i);
                if (ac && !ac->audio_mapping().mapped_output_channels().empty ()) {
-                       _views.push_back (shared_ptr<TimelineView> (new TimelineAudioContentView (*this, *i)));
+                       _views.push_back (shared_ptr<TimelineView> (new TimelineAudioContentView (*this, i)));
                }
 
-               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (*i);
+               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (i);
                if (sc && sc->has_subtitles ()) {
                        _views.push_back (shared_ptr<TimelineView> (new TimelineSubtitleContentView (*this, sc)));
                }
index 53e1092248d3d0dfc44a74d4153d49f8e1954b0a..1497c23229badf153aa24e06404fe28ac4b96d5c 100644 (file)
@@ -147,15 +147,13 @@ TimingPanel::TimingPanel (ContentPanel* p, FilmViewer* viewer)
 void
 TimingPanel::update_full_length ()
 {
-       ContentList cl = _parent->selected ();
-
        set<DCPTime> check;
-       for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
-               check.insert ((*i)->full_length ());
+       BOOST_FOREACH (shared_ptr<const Content> 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<DCPTime> check;
-       for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
-               check.insert ((*i)->length_after_trim ());
+       BOOST_FOREACH (shared_ptr<const Content> 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<DCPTime> check;
-               for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
-                       check.insert ((*i)->position ());
+               BOOST_FOREACH (shared_ptr<const Content> 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<ContentTime> check;
-               for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
-                       check.insert ((*i)->trim_start ());
+               BOOST_FOREACH (shared_ptr<const Content> 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<ContentTime> check;
-               for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
-                       check.insert ((*i)->trim_end ());
+               BOOST_FOREACH (shared_ptr<const Content> 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<double> check;
-               shared_ptr<VideoContent> vc;
-               for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
-                       shared_ptr<VideoContent> t = dynamic_pointer_cast<VideoContent> (*i);
+               shared_ptr<const VideoContent> vc;
+               BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
+                       shared_ptr<const VideoContent> t = dynamic_pointer_cast<const VideoContent> (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<ImageContent> ic = dynamic_pointer_cast<ImageContent> (*i);
+       BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
+               shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (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<Content> 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<ImageContent> ic = dynamic_pointer_cast<ImageContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+               shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (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<Content> 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<Content> 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<Content> 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<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i);
+       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+               shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (i);
                if (vc) {
                        vc->set_video_frame_rate (raw_convert<double> (wx_to_std (_video_frame_rate->GetValue ())));
                }
index 68ff7c3693b50d1a2d0d2eeaae2c10f3e7bdb834..f85fdae7be81fdba325d39644291e6b94a235426 100644 (file)
@@ -210,10 +210,9 @@ VideoPanel::VideoPanel (ContentPanel* p)
        _right_crop->wrapped()->SetRange (0, 1024);
        _bottom_crop->wrapped()->SetRange (0, 1024);
 
-       vector<VideoContentScale> scales = VideoContentScale::all ();
        _scale->wrapped()->Clear ();
-       for (vector<VideoContentScale>::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<Frame> check;
-               for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) {
-                       check.insert ((*i)->fade_in ());
+               BOOST_FOREACH (shared_ptr<const VideoContent> 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<Frame> check;
-               for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) {
-                       check.insert ((*i)->fade_out ());
+               BOOST_FOREACH (shared_ptr<const VideoContent> 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<VideoContent> 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<VideoContent> 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));
        }
 }
index d90612fdda0fe7d8a37118e5d4998682c877f3aa..b4b4c77662f1fcff662f8d1db2b986ffbef12580 100644 (file)
@@ -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;