diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-11-11 22:15:47 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-11-14 00:27:31 +0100 |
| commit | 081525ef1c392465fc5a0bb4be79af8e84655bc4 (patch) | |
| tree | 4ac5aae3462f7d55f1df983a7c876fd74bfe48db /src/wx | |
| parent | e1cbceca253ebf16f49e5bc78e3f1d0157c37bee (diff) | |
Account for DPI scale factors when calculating some sizes (#2118).v2.15.173
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/film_viewer.cc | 10 | ||||
| -rw-r--r-- | src/wx/gl_video_view.cc | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 2c90b8609..a93b4226e 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -283,17 +283,21 @@ FilmViewer::calculate_sizes () auto const container = _film->container (); - auto const view_ratio = float(_video_view->get()->GetSize().x) / _video_view->get()->GetSize().y; + auto const dpi_scale_factor = _video_view->get()->GetDPIScaleFactor(); + int const video_view_width = std::round(_video_view->get()->GetSize().x * dpi_scale_factor); + int const video_view_height = std::round(_video_view->get()->GetSize().y * dpi_scale_factor); + + auto const view_ratio = float(video_view_width) / video_view_height; auto const film_ratio = container ? container->ratio () : 1.78; dcp::Size out_size; if (view_ratio < film_ratio) { /* panel is less widscreen than the film; clamp width */ - out_size.width = _video_view->get()->GetSize().x; + out_size.width = video_view_width; out_size.height = lrintf (out_size.width / film_ratio); } else { /* panel is more widescreen than the film; clamp height */ - out_size.height = _video_view->get()->GetSize().y; + out_size.height = video_view_height; out_size.width = lrintf (out_size.height * film_ratio); } diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 877cd5125..559cff413 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -103,12 +103,15 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent) void GLVideoView::size_changed (wxSizeEvent const& ev) { - _canvas_size = ev.GetSize (); + auto const scale = _canvas->GetDPIScaleFactor(); + int const width = std::round(ev.GetSize().GetWidth() * scale); + int const height = std::round(ev.GetSize().GetHeight() * scale); + _canvas_size = { width, height }; + LOG_GENERAL("GLVideoView canvas size changed to %1x%2", width, height); Sized (); } - GLVideoView::~GLVideoView () { boost::this_thread::disable_interruption dis; |
