From 834231bc8e76aea27cc898361e168864301a6450 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 10 Mar 2026 23:21:30 +0100 Subject: Fix updating of crop guess rectangle from the auto-crop dialog. Before the change in the dialog would raise an ImageChanged which would reset the crop again, making it unchangeable. --- src/wx/film_viewer.cc | 2 +- src/wx/gl_video_view.cc | 20 ++++++++++++++++++++ src/wx/gl_video_view.h | 2 ++ src/wx/simple_video_view.cc | 7 +++++++ src/wx/simple_video_view.h | 1 + src/wx/video_view.h | 2 ++ 6 files changed, 33 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index dbda1d7f1..b01498fc8 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -890,7 +890,7 @@ FilmViewer::set_crop_guess(dcpomatic::Rect crop) { if (crop != _crop_guess) { _crop_guess = crop; - _video_view->update(); + _video_view->update_crop_guess(); } } diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 0e115977d..a04cb3000 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -135,6 +135,15 @@ GLVideoView::check_for_butler_errors() } +void +GLVideoView::update_crop_guess() +{ + /* Assume at least one update() has happened before now */ + request(Request::SET_CROP_GUESS_AND_DRAW); + rethrow(); +} + + /** Called from the UI thread */ void GLVideoView::update() @@ -952,6 +961,12 @@ try } else if (_pending_request == Request::SET_IMAGE_AND_DRAW) { _pending_request = Request::NONE; set_image_and_draw(); + } else if (_pending_request == Request::SET_CROP_GUESS_AND_DRAW) { + _pending_request = Request::NONE; + if (auto pv = player_video().first) { + set_image(pv); + } + draw(); } boost::this_thread::interruption_point(); @@ -980,6 +995,11 @@ GLVideoView::display_next_frame(bool non_blocking) void GLVideoView::request(Request request) { + if (_pending_request == Request::SET_IMAGE_AND_DRAW) { + /* Don't replace this; it's a superset of other requests */ + return; + } + boost::mutex::scoped_lock lm(_playing_mutex); _pending_request = request; _thread_work_condition.notify_all(); diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h index 830156dd9..35f4aeeda 100644 --- a/src/wx/gl_video_view.h +++ b/src/wx/gl_video_view.h @@ -80,6 +80,7 @@ public: return _canvas; } void update() override; + void update_crop_guess() override; void start() override; void stop() override; @@ -97,6 +98,7 @@ private: enum class Request { NONE, SET_IMAGE_AND_DRAW, + SET_CROP_GUESS_AND_DRAW, }; void set_image(std::shared_ptr pv); diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index 2d2cbb3b6..7953e89b0 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -213,6 +213,13 @@ SimpleVideoView::display_next_frame(bool non_blocking) } +void +SimpleVideoView::update_crop_guess() +{ + refresh_panel(); +} + + void SimpleVideoView::update() { diff --git a/src/wx/simple_video_view.h b/src/wx/simple_video_view.h index a9d3f4982..36e0e0689 100644 --- a/src/wx/simple_video_view.h +++ b/src/wx/simple_video_view.h @@ -44,6 +44,7 @@ public: } void update() override; + void update_crop_guess() override; void start() override; NextFrameResult display_next_frame(bool non_blocking) override; diff --git a/src/wx/video_view.h b/src/wx/video_view.h index 6a4c2225e..6de53530a 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -59,6 +59,8 @@ public: virtual wxWindow* get() const = 0; /** Re-make and display the image from the current _player_video */ virtual void update() = 0; + /** Re-draw after changes to the FilmViewer's crop_guess() */ + virtual void update_crop_guess() = 0; /** Called when playback starts */ virtual void start(); /** Called when playback stops */ -- cgit v1.2.3