From b16fa5f0de631821a7acc994645a291bc7aa90c9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 17 Jun 2015 16:21:01 +0100 Subject: [PATCH] Final tweaks and removal of Film::playlist(). --- src/lib/film.cc | 18 ++++++++++++------ src/lib/film.h | 5 +++-- src/wx/content_menu.cc | 8 ++++---- src/wx/timeline.cc | 18 ++++++++++-------- src/wx/timeline.h | 19 ++++++++++--------- test/frame_rate_test.cc | 32 ++++++++++++++++---------------- 6 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index 769ef72b6..f41371892 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -916,12 +916,6 @@ Film::set_key (dcp::Key key) signal_changed (KEY); } -shared_ptr -Film::playlist () const -{ - return _playlist; -} - ContentList Film::content () const { @@ -1226,3 +1220,15 @@ Film::audio_output_names () const return vector (n.begin(), n.begin() + audio_channels ()); } + +void +Film::repeat_content (ContentList c, int n) +{ + _playlist->repeat (c, n); +} + +void +Film::remove_content (ContentList c) +{ + _playlist->remove (c); +} diff --git a/src/lib/film.h b/src/lib/film.h index da1c09d2f..f268bc5b7 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -101,8 +101,6 @@ public: std::vector cpls () const; - boost::shared_ptr playlist () const; - int audio_frame_rate () const; uint64_t required_disk_space () const; @@ -141,6 +139,8 @@ public: void make_audio_mapping_default (AudioMapping & mapping) const; std::vector audio_output_names () const; + void repeat_content (ContentList, int); + /** Identifiers for the parts of our state; used for signalling changes. */ @@ -256,6 +256,7 @@ public: void examine_and_add_content (boost::shared_ptr); void add_content (boost::shared_ptr); void remove_content (boost::shared_ptr); + void remove_content (ContentList); void move_content_earlier (boost::shared_ptr); void move_content_later (boost::shared_ptr); void set_dcp_content_type (DCPContentType const *); diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index daadab7d7..2e9fe43fe 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -122,12 +122,12 @@ ContentMenu::repeat () return; } - shared_ptr film = _film.lock (); + shared_ptr film = _film.lock (); if (!film) { return; } - film->playlist()->repeat (_content, d->number ()); + film->repeat_content (_content, d->number ()); d->Destroy (); _content.clear (); @@ -170,7 +170,7 @@ ContentMenu::remove () return; } - shared_ptr film = _film.lock (); + shared_ptr film = _film.lock (); if (!film) { return; } @@ -210,7 +210,7 @@ ContentMenu::remove () } if (!handled) { - film->playlist()->remove (_content); + film->remove_content (_content); } _content.clear (); diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index b0197ad3d..3929cf1c2 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -64,12 +64,12 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film) Bind (wxEVT_MOTION, boost::bind (&Timeline::mouse_moved, this, _1)); Bind (wxEVT_SIZE, boost::bind (&Timeline::resized, this)); - playlist_changed (); + film_changed (Film::CONTENT); SetMinSize (wxSize (640, tracks() * track_height() + 96)); - _playlist_changed_connection = film->playlist()->Changed.connect (bind (&Timeline::playlist_changed, this)); - _playlist_content_changed_connection = film->playlist()->ContentChanged.connect (bind (&Timeline::playlist_content_changed, this, _2)); + _film_changed_connection = film->Changed.connect (bind (&Timeline::film_changed, this, _1)); + _film_content_changed_connection = film->ContentChanged.connect (bind (&Timeline::film_content_changed, this, _2)); } void @@ -90,10 +90,12 @@ Timeline::paint () } void -Timeline::playlist_changed () +Timeline::film_changed (Film::Property p) { - ensure_ui_thread (); - recreate_views (); + if (p == Film::CONTENT) { + ensure_ui_thread (); + recreate_views (); + } } void @@ -107,7 +109,7 @@ Timeline::recreate_views () _views.clear (); _views.push_back (_time_axis_view); - ContentList content = fl->playlist()->content (); + ContentList content = fl->content (); for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { if (dynamic_pointer_cast (*i)) { @@ -131,7 +133,7 @@ Timeline::recreate_views () } void -Timeline::playlist_content_changed (int property) +Timeline::film_content_changed (int property) { ensure_ui_thread (); diff --git a/src/wx/timeline.h b/src/wx/timeline.h index cab0ea0e0..2afd0d194 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -17,14 +17,15 @@ */ +#include "content_menu.h" +#include "timeline_content_view.h" +#include "lib/util.h" +#include "lib/rect.h" +#include "lib/film.h" +#include #include #include #include -#include -#include "lib/util.h" -#include "lib/rect.h" -#include "content_menu.h" -#include "timeline_content_view.h" class Film; class ContentPanel; @@ -78,8 +79,8 @@ private: void left_up (wxMouseEvent &); void right_down (wxMouseEvent &); void mouse_moved (wxMouseEvent &); - void playlist_changed (); - void playlist_content_changed (int); + void film_changed (Film::Property); + void film_content_changed (int); void resized (); void assign_tracks (); void set_position_from_event (wxMouseEvent &); @@ -105,6 +106,6 @@ private: ContentMenu _menu; bool _snap; - boost::signals2::scoped_connection _playlist_changed_connection; - boost::signals2::scoped_connection _playlist_content_changed_connection; + boost::signals2::scoped_connection _film_changed_connection; + boost::signals2::scoped_connection _film_content_changed_connection; }; diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc index 39a64504d..cf3dc2612 100644 --- a/test/frame_rate_test.cc +++ b/test/frame_rate_test.cc @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) Config::instance()->set_allowed_dcp_frame_rates (afr); content->_video_frame_rate = 60; - int best = film->playlist()->best_dcp_frame_rate (); + int best = film->best_video_frame_rate (); FrameRateChange frc = FrameRateChange (60, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, true); @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 50; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (50, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, true); @@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 48; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (48, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, true); @@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 30; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (30, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, false); @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 29.97; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (29.97, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, false); @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 30 / 29.97, 0.1); content->_video_frame_rate = 25; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (25, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, false); @@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 24; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (24, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, false); @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 14.5; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (14.5, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, false); @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 15 / 14.5, 0.1); content->_video_frame_rate = 12.6; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (12.6, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, false); @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 25 / 25.2, 0.1); content->_video_frame_rate = 12.4; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (12.4, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, false); @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 25 / 24.8, 0.1); content->_video_frame_rate = 12; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (12, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, false); @@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) Config::instance()->set_allowed_dcp_frame_rates (afr); content->_video_frame_rate = 60; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (60, best); BOOST_CHECK_EQUAL (best, 60); BOOST_CHECK_EQUAL (frc.skip, false); @@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 50; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (50, best); BOOST_CHECK_EQUAL (best, 50); BOOST_CHECK_EQUAL (frc.skip, false); @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 48; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (48, best); BOOST_CHECK_EQUAL (best, 48); BOOST_CHECK_EQUAL (frc.skip, false); @@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) Config::instance()->set_allowed_dcp_frame_rates (afr); content->_video_frame_rate = 25; - best = film->playlist()->best_dcp_frame_rate (); + best = film->best_video_frame_rate (); frc = FrameRateChange (25, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, false); @@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_double) A->_video_frame_rate = 30; B->_video_frame_rate = 24; - BOOST_CHECK_EQUAL (film->playlist()->best_dcp_frame_rate(), 25); + BOOST_CHECK_EQUAL (film->best_video_frame_rate(), 25); } BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) -- 2.30.2