From: Carl Hetherington Date: Sun, 19 Aug 2018 12:55:46 +0000 (+0100) Subject: Similar pending/done for Film::Change. X-Git-Tag: v2.13.43~13 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=4408e6eea87ce9630e71e4a7d40e2dade091b0ee;p=dcpomatic.git Similar pending/done for Film::Change. --- diff --git a/src/lib/film.cc b/src/lib/film.cc index 846e8ac51..eaaa611af 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -938,19 +938,28 @@ Film::signal_changed (Property p) { _dirty = true; + Change (CHANGE_TYPE_PENDING, p); + bool changed = false; + switch (p) { case Film::CONTENT: set_video_frame_rate (_playlist->best_video_frame_rate ()); + changed = true; break; case Film::VIDEO_FRAME_RATE: case Film::SEQUENCE: _playlist->maybe_sequence (); + changed = true; break; default: break; } - emit (boost::bind (boost::ref (Changed), p)); + if (changed) { + emit (boost::bind (boost::ref (Change), CHANGE_TYPE_DONE, p)); + } else { + Change (CHANGE_TYPE_CANCELLED, p); + } } void diff --git a/src/lib/film.h b/src/lib/film.h index c6c8403cb..649768c7a 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -323,8 +323,8 @@ public: void set_reel_length (int64_t); void set_upload_after_make_dcp (bool); - /** Emitted when some property has of the Film has changed */ - mutable boost::signals2::signal Changed; + /** Emitted when some property has of the Film is about to change or has changed */ + mutable boost::signals2::signal Change; /** Emitted when some property of our content has changed */ mutable boost::signals2::signal, int, bool)> ContentChange; diff --git a/src/lib/player.cc b/src/lib/player.cc index 0c3aea028..dae0d23d6 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -97,12 +97,12 @@ Player::Player (shared_ptr film, shared_ptr playlist , _audio_merger (_film->audio_frame_rate()) , _shuffler (0) { - _film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1)); + _film_changed_connection = _film->Change.connect (bind (&Player::film_change, this, _1, _2)); _playlist_change_connection = _playlist->Change.connect (bind (&Player::playlist_change, this, _1)); _playlist_content_change_connection = _playlist->ContentChange.connect (bind(&Player::playlist_content_change, this, _1, _3, _4)); set_video_container_size (_film->frame_size ()); - film_changed (Film::AUDIO_PROCESSOR); + film_change (CHANGE_TYPE_DONE, Film::AUDIO_PROCESSOR); setup_pieces (); seek (DCPTime (), true); @@ -268,7 +268,7 @@ Player::playlist_change (ChangeType type) } void -Player::film_changed (Film::Property p) +Player::film_change (ChangeType type, Film::Property p) { /* Here we should notice Film properties that affect our output, and alert listeners that our output now would be different to how it was @@ -276,22 +276,25 @@ Player::film_changed (Film::Property p) */ if (p == Film::CONTAINER) { - Change (CHANGE_TYPE_PENDING, PlayerProperty::FILM_CONTAINER, false); + Change (type, PlayerProperty::FILM_CONTAINER, false); } else if (p == Film::VIDEO_FRAME_RATE) { /* Pieces contain a FrameRateChange which contains the DCP frame rate, so we need new pieces here. */ - /* XXX: missing PENDING! */ - setup_pieces (); - Change (CHANGE_TYPE_DONE, PlayerProperty::FILM_VIDEO_FRAME_RATE, false); + if (type == CHANGE_TYPE_DONE) { + setup_pieces (); + } + Change (type, PlayerProperty::FILM_VIDEO_FRAME_RATE, false); } else if (p == Film::AUDIO_PROCESSOR) { - if (_film->audio_processor ()) { + if (type == CHANGE_TYPE_DONE && _film->audio_processor ()) { boost::mutex::scoped_lock lm (_mutex); _audio_processor = _film->audio_processor()->clone (_film->audio_frame_rate ()); } } else if (p == Film::AUDIO_CHANNELS) { - boost::mutex::scoped_lock lm (_mutex); - _audio_merger.clear (); + if (type == CHANGE_TYPE_DONE) { + boost::mutex::scoped_lock lm (_mutex); + _audio_merger.clear (); + } } } diff --git a/src/lib/player.h b/src/lib/player.h index 165820799..e17456cf2 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -112,7 +112,7 @@ private: void setup_pieces (); void setup_pieces_unlocked (); void flush (); - void film_changed (Film::Property); + void film_change (ChangeType, Film::Property); void playlist_change (ChangeType); void playlist_content_change (ChangeType, int, bool); std::list transform_bitmap_texts (std::list) const; diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 6972b35c4..7ae6b1c72 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -434,7 +434,7 @@ public: if (_film->directory()) { Config::instance()->add_to_history (_film->directory().get()); } - _film->Changed.connect (boost::bind (&DOMFrame::set_menu_sensitivity, this)); + _film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1)); } shared_ptr film () const { @@ -443,6 +443,13 @@ public: private: + void film_change (ChangeType type) + { + if (type == CHANGE_TYPE_DONE) { + set_menu_sensitivity (); + } + } + void file_changed (boost::filesystem::path f) { string s = wx_to_std (_("DCP-o-matic")); diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 1c1c02f5b..cbdbe0f36 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -68,8 +68,12 @@ FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer) * @param p Property of the Film that has changed. */ void -FilmEditor::film_changed (Film::Property p) +FilmEditor::film_change (ChangeType type, Film::Property p) { + if (type != CHANGE_TYPE_DONE) { + return; + } + ensure_ui_thread (); if (!_film) { @@ -121,7 +125,7 @@ FilmEditor::set_film (shared_ptr film) _dcp_panel->set_film (_film); if (_film) { - _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1)); + _film->Change.connect (bind (&FilmEditor::film_change, this, _1, _2)); _film->ContentChange.connect (bind (&FilmEditor::film_content_change, this, _1, _3)); } diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index cd2180b3c..cbc8f92be 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -56,7 +56,7 @@ public: } /* Handle changes to the model */ - void film_changed (Film::Property); + void film_change (ChangeType, Film::Property); void film_content_change (ChangeType type, int); void set_general_sensitivity (bool); diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 463854992..a5e1577fe 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -224,7 +224,7 @@ FilmViewer::set_film (shared_ptr film) _player->set_always_burn_open_subtitles (); _player->set_play_referenced (); - _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1)); + _film->Change.connect (boost::bind (&FilmViewer::film_change, this, _1, _2)); _player->Change.connect (boost::bind (&FilmViewer::player_change, this, _1, _2, _3)); /* Keep about 1 second's worth of history samples */ @@ -720,8 +720,12 @@ FilmViewer::setup_sensitivity () } void -FilmViewer::film_changed (Film::Property p) +FilmViewer::film_change (ChangeType type, Film::Property p) { + if (type != CHANGE_TYPE_DONE) { + return; + } + if (p == Film::CONTENT || p == Film::THREE_D) { setup_sensitivity (); } else if (p == Film::AUDIO_CHANNELS) { diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index d6d9a99a8..0e7da10b1 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -105,7 +105,7 @@ private: void seek (DCPTime t, bool accurate); void refresh_panel (); void setup_sensitivity (); - void film_changed (Film::Property); + void film_change (ChangeType, Film::Property); DCPTime nudge_amount (wxKeyboardState &); void timecode_clicked (); void frame_number_clicked (); diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc index 3872ea8ae..cbd48ec36 100644 --- a/src/wx/hints_dialog.cc +++ b/src/wx/hints_dialog.cc @@ -75,8 +75,8 @@ HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr film, bool ok) boost::shared_ptr locked_film = _film.lock (); if (locked_film) { - _film_changed_connection = locked_film->Changed.connect (boost::bind (&HintsDialog::film_changed, this)); - _film_content_changed_connection = locked_film->ContentChange.connect (boost::bind (&HintsDialog::film_content_change, this, _1)); + _film_change_connection = locked_film->Change.connect (boost::bind (&HintsDialog::film_change, this, _1)); + _film_content_change_connection = locked_film->ContentChange.connect (boost::bind (&HintsDialog::film_content_change, this, _1)); } _hints->Hint.connect (bind (&HintsDialog::hint, this, _1)); @@ -84,12 +84,16 @@ HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr film, bool ok) _hints->Pulse.connect (bind (&HintsDialog::pulse, this)); _hints->Finished.connect (bind (&HintsDialog::finished, this)); - film_changed (); + film_change (CHANGE_TYPE_DONE); } void -HintsDialog::film_changed () +HintsDialog::film_change (ChangeType type) { + if (type != CHANGE_TYPE_DONE) { + return; + } + _text->Clear (); _current.clear (); @@ -109,9 +113,7 @@ HintsDialog::film_changed () void HintsDialog::film_content_change (ChangeType type) { - if (type == CHANGE_TYPE_DONE) { - film_changed (); - } + film_change (type); } void diff --git a/src/wx/hints_dialog.h b/src/wx/hints_dialog.h index 83510643a..2755c70fd 100644 --- a/src/wx/hints_dialog.h +++ b/src/wx/hints_dialog.h @@ -33,7 +33,7 @@ public: HintsDialog (wxWindow* parent, boost::weak_ptr, bool ok); private: - void film_changed (); + void film_change (ChangeType); void film_content_change (ChangeType type); void shut_up (wxCommandEvent& ev); void update (); @@ -49,6 +49,6 @@ private: boost::shared_ptr _hints; std::list _current; - boost::signals2::scoped_connection _film_changed_connection; - boost::signals2::scoped_connection _film_content_changed_connection; + boost::signals2::scoped_connection _film_change_connection; + boost::signals2::scoped_connection _film_content_change_connection; }; diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 7353baf82..0231bc400 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -105,11 +105,11 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film) _main_canvas->Bind (wxEVT_SCROLLWIN_PAGEDOWN, boost::bind (&Timeline::scrolled, this, _1)); _main_canvas->Bind (wxEVT_SCROLLWIN_THUMBTRACK, boost::bind (&Timeline::scrolled, this, _1)); - film_changed (Film::CONTENT); + film_change (CHANGE_TYPE_DONE, Film::CONTENT); SetMinSize (wxSize (640, 4 * pixels_per_track() + 96)); - _film_changed_connection = film->Changed.connect (bind (&Timeline::film_changed, this, _1)); + _film_changed_connection = film->Change.connect (bind (&Timeline::film_change, this, _1, _2)); _film_content_change_connection = film->ContentChange.connect (bind (&Timeline::film_content_change, this, _1, _3, _4)); setup_scrollbars (); @@ -197,8 +197,12 @@ Timeline::paint_main () } void -Timeline::film_changed (Film::Property p) +Timeline::film_change (ChangeType type, Film::Property p) { + if (type != CHANGE_TYPE_DONE) { + return; + } + if (p == Film::CONTENT || p == Film::REEL_TYPE || p == Film::REEL_LENGTH) { ensure_ui_thread (); recreate_views (); diff --git a/src/wx/timeline.h b/src/wx/timeline.h index 9f3a4a47b..89fd94179 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -91,7 +91,7 @@ private: void mouse_moved (wxMouseEvent &); void mouse_moved_select (wxMouseEvent &); void mouse_moved_zoom (wxMouseEvent &); - void film_changed (Film::Property); + void film_change (ChangeType type, Film::Property); void film_content_change (ChangeType type, int, bool frequent); void resized (); void assign_tracks (); diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index d2194f5c7..050f90053 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -87,9 +87,9 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film) sizer->SetSizeHints (this); _toolbar->ToggleTool ((int) Timeline::SNAP, _timeline.snap ()); - film_changed (Film::SEQUENCE); + film_change (CHANGE_TYPE_DONE, Film::SEQUENCE); - _film_changed_connection = film->Changed.connect (bind (&TimelineDialog::film_changed, this, _1)); + _film_changed_connection = film->Change.connect (bind (&TimelineDialog::film_change, this, _1, _2)); } wxString @@ -100,8 +100,12 @@ TimelineDialog::bitmap_path (string name) } void -TimelineDialog::film_changed (Film::Property p) +TimelineDialog::film_change (ChangeType type, Film::Property p) { + if (type != CHANGE_TYPE_DONE) { + return; + } + shared_ptr film = _film.lock (); if (!film) { return; diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h index b7aaba14d..1aff36c8c 100644 --- a/src/wx/timeline_dialog.h +++ b/src/wx/timeline_dialog.h @@ -33,7 +33,7 @@ public: void set_selection (ContentList selection); private: - void film_changed (Film::Property); + void film_change (ChangeType type, Film::Property); void tool_clicked (wxCommandEvent& id); wxString bitmap_path (std::string name);