Extract dpi_scale_factor() to a function.
authorCarl Hetherington <cth@carlh.net>
Sat, 20 Nov 2021 21:35:48 +0000 (22:35 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 20 Nov 2021 21:35:48 +0000 (22:35 +0100)
src/wx/film_viewer.cc
src/wx/wx_util.cc
src/wx/wx_util.h

index 392c68d70610444ea62ca085855c8080758782b5..259e2bc16a4a02b5ca078add1d95a8251b4851cb 100644 (file)
@@ -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;
index 47b381562aa375a93e02bcc2b731b9099f8023e2..266989a4dd275f9fc139ddaacffe21eb2f4bd2ca 100644 (file)
@@ -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
+
index 3fa2ebe258b4426e0ff9b5e44b26c856054eb756..cd9a06a4fc5b2851443e0ec55f24a9ed7d49c69f 100644 (file)
@@ -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