diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-11-20 22:35:48 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-11-20 22:35:48 +0100 |
| commit | dff4de9f29435fe1222a6b039ca3231064f6bcd9 (patch) | |
| tree | e548773c412a988ae1c8beac5e7fe7e1ef0e56f8 /src | |
| parent | 6f322eec31ef03f73e47564f20c39795b6bb9155 (diff) | |
Extract dpi_scale_factor() to a function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/film_viewer.cc | 10 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 15 | ||||
| -rw-r--r-- | src/wx/wx_util.h | 1 |
3 files changed, 19 insertions, 7 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 392c68d70..259e2bc16 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -283,13 +283,9 @@ FilmViewer::calculate_sizes () auto const container = _film->container (); -#if wxCHECK_VERSION(3,1,0) - auto const dpi_scale_factor = _video_view->get()->GetDPIScaleFactor(); -#else - auto const dpi_scale_factor = 1; -#endif - 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 scale = dpi_scale_factor (_video_view->get()); + int const video_view_width = std::round(_video_view->get()->GetSize().x * scale); + int const video_view_height = std::round(_video_view->get()->GetSize().y * scale); auto const view_ratio = float(video_view_width) / video_view_height; auto const film_ratio = container ? container->ratio () : 1.78; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 47b381562..266989a4d 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -673,3 +673,18 @@ gui_is_dark () #endif } + +#if wxCHECK_VERSION(3,1,0) +double +dpi_scale_factor (wxWindow* window) +{ + return window->GetDPIScaleFactor(); +} +#else +double +dpi_scale_factor (wxWindow*) +{ + return 1; +} +#endif + diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 3fa2ebe25..cd9a06a4f 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -120,6 +120,7 @@ extern bool report_errors_from_last_job (wxWindow* parent); extern wxString bitmap_path (std::string name); extern wxSize small_button_size (wxWindow* parent, wxString text); extern bool gui_is_dark (); +extern double dpi_scale_factor (wxWindow* window); struct Offset |
