Guess UI scale for copy-config dialog

This dialog shows before the new user wizard,
where a user would configure HDPI/UI scaling.
This commit is contained in:
Robin Gareus 2023-09-25 17:07:15 +02:00
parent 9f475d5427
commit d7c611e025
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
5 changed files with 54 additions and 38 deletions

View file

@ -642,6 +642,40 @@ ARDOUR_UI_UTILS::key_is_legal_for_numeric_entry (guint keyval)
return false;
}
int
ARDOUR_UI_UTILS::guess_default_ui_scale ()
{
gint width = 0;
gint height = 0;
GdkScreen* screen = gdk_display_get_screen (gdk_display_get_default (), 0);
gint n_monitors = gdk_screen_get_n_monitors (screen);
if (!screen) {
return 100;
}
for (gint i = 0; i < n_monitors; ++i) {
GdkRectangle rect;
gdk_screen_get_monitor_geometry (screen, i, &rect);
width = std::max (width, rect.width);
height = std::max (height, rect.height);
}
float wx = width / 1920.f;
float hx = height / 1080.f;
float sx = std::min (wx, hx);
if (sx < 1.25) {
return 100;
} else if (sx < 1.6) {
return 150;
} else if (sx < 2.1) {
return 200;
} else {
return 250;
}
}
void
ARDOUR_UI_UTILS::resize_window_to_proportion_of_monitor (Gtk::Window* window, int max_width, int max_height)
{