diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 4f61d365e0..2cd247d6cd 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -215,6 +215,10 @@ static const gchar *_record_mode_strings[] = { static bool ask_about_configuration_copy (string const & old_dir, string const & new_dir, int version) { + /* guess screen scaling */ + UIConfiguration::instance ().set_font_scale (1024 * guess_default_ui_scale ()); + UIConfiguration::instance ().reset_dpi (); + ArdourMessageDialog msg (string_compose ( _("%1 %2.x has discovered configuration files from %1 %3.x.\n\n" "Would you like these files to be copied and used for %1 %2.x?\n\n" @@ -367,6 +371,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) record_mode_strings = I18N (_record_mode_strings); if (ARDOUR::handle_old_configuration_files (boost::bind (ask_about_configuration_copy, _1, _2, _3))) { + { /* "touch" the been-here-before path now that config has been migrated */ PBD::ScopedFileDescriptor fout (g_open (been_here_before_path ().c_str(), O_CREAT|O_TRUNC|O_RDWR, 0666)); diff --git a/gtk2_ardour/new_user_wizard.cc b/gtk2_ardour/new_user_wizard.cc index f7544a2ac7..8ddcb37a86 100644 --- a/gtk2_ardour/new_user_wizard.cc +++ b/gtk2_ardour/new_user_wizard.cc @@ -171,7 +171,18 @@ using the program. \ hbox->show (); cbox->show (); - guess_default_ui_scale (); + int ui_scale = guess_default_ui_scale (); + if (ui_scale <= 100) { + ui_font_scale.set_active (0); // 100% + } else if (ui_scale <= 150) { + ui_font_scale.set_active (1); // 150% + } else if (ui_scale <= 200) { + ui_font_scale.set_active (2); // 200% + } else { + ui_font_scale.set_active (3); // 250% + } + rescale_ui (); + ui_font_scale.signal_changed ().connect (sigc::mem_fun (*this, &NewUserWizard::rescale_ui)); #endif @@ -189,7 +200,7 @@ void NewUserWizard::rescale_ui () { int rn = ui_font_scale.get_active_row_number (); - if (rn < 0 ) { + if (rn < 0) { return; } float ui_scale = 100 + rn * 50; @@ -197,41 +208,6 @@ NewUserWizard::rescale_ui () UIConfiguration::instance ().reset_dpi (); } -void -NewUserWizard::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; - } - - 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) { - ui_font_scale.set_active (0); // 100% - } else if (sx < 1.6) { - ui_font_scale.set_active (1); // 150% - } else if (sx < 2.1) { - ui_font_scale.set_active (2); // 200% - } else { - ui_font_scale.set_active (3); // 250% - } - rescale_ui (); -} - void NewUserWizard::default_dir_changed () { diff --git a/gtk2_ardour/new_user_wizard.h b/gtk2_ardour/new_user_wizard.h index 0b4327eb2a..e5e46bc250 100644 --- a/gtk2_ardour/new_user_wizard.h +++ b/gtk2_ardour/new_user_wizard.h @@ -77,7 +77,6 @@ private: /* Welcome */ Gtk::ComboBoxText ui_font_scale; void rescale_ui (); - void guess_default_ui_scale (); /* first page */ Gtk::FileChooserButton* default_dir_chooser; diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 291790dae8..772dc1941a 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -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) { diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h index ad04066b55..714478ee4e 100644 --- a/gtk2_ardour/utils.h +++ b/gtk2_ardour/utils.h @@ -95,6 +95,8 @@ const char* const *get_xpm_data (std::string path); std::string longest (std::vector&); bool key_is_legal_for_numeric_entry (guint keyval); +int guess_default_ui_scale (); + void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int); std::string escape_underscores (std::string const &);