Configure UI scale as first start step
authorRobin Gareus <robin@gareus.org>
Sun, 6 Oct 2019 18:56:34 +0000 (20:56 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 6 Oct 2019 18:56:34 +0000 (20:56 +0200)
This also includes some simple heuristic to guess initial scaling
depending on the largest screen's geometry.

gtk2_ardour/startup.cc
gtk2_ardour/startup.h

index b3e741011f38d71b261b5f7aaff6c7234bf72a7a..9e04a305d9354bb080970c2dd3e3e1037c3ed10d 100644 (file)
@@ -57,6 +57,7 @@
 
 #include "startup.h"
 #include "opts.h"
+#include "ui_config.h"
 #include "pbd/i18n.h"
 #include "utils.h"
 
@@ -149,16 +150,44 @@ using the program.</span> \
        foomatic->set_justify (JUSTIFY_FILL);
        foomatic->set_line_wrap ();
 
+       VBox* vbox = manage (new VBox);
+       vbox->set_border_width (24);
+       vbox->pack_start (*foomatic, true, true, 12);
+
+#ifndef __APPLE__
+       Label* barmatic = manage (new Label);
+       barmatic->set_text (_("GUI and Font scaling:"));
+
+       Label* bazmatic = manage (new Label);
+       bazmatic->set_markup (_("<small><i>This can later be changed in Preferences &gt; Appearance.</i></small>"));
+
+       ui_font_scale.append_text (_("100%"));
+       ui_font_scale.append_text (_("150%"));
+       ui_font_scale.append_text (_("200%"));
+       ui_font_scale.append_text (_("250%"));
+       ui_font_scale.set_active_text (_("100%"));
+
        HBox* hbox = manage (new HBox);
-       HBox* vbox = manage (new HBox);
+       HBox* cbox = manage (new HBox);
 
-       vbox->set_border_width (24);
+       hbox->pack_start (*barmatic, false, false);
+       hbox->pack_start (ui_font_scale, false, false);
+       cbox->pack_start (*hbox, true, false);
 
-       hbox->pack_start (*foomatic, true, true);
-       vbox->pack_start (*hbox, true, true);
+       vbox->pack_start (*cbox, false, false, 2);
+       vbox->pack_start (*bazmatic, false, false);
 
-       foomatic->show ();
+       ui_font_scale.show ();
+       barmatic->show ();
+       bazmatic->show ();
        hbox->show ();
+       cbox->show ();
+
+       guess_default_ui_scale ();
+       ui_font_scale.signal_changed ().connect (sigc::mem_fun (*this, &ArdourStartup::rescale_ui));
+#endif
+
+       foomatic->show ();
        vbox->show ();
 
        new_user_page_index = append_page (*vbox);
@@ -168,6 +197,53 @@ using the program.</span> \
        set_page_complete (*vbox, true);
 }
 
+void
+ArdourStartup::rescale_ui ()
+{
+       int rn = ui_font_scale.get_active_row_number ();
+       if (rn < 0 ) {
+               return;
+       }
+       float ui_scale = 100 + rn * 50;
+       UIConfiguration::instance ().set_font_scale (1024 * ui_scale);
+       UIConfiguration::instance ().reset_dpi ();
+}
+
+void
+ArdourStartup::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
 ArdourStartup::default_dir_changed ()
 {
index 6717163e681af9da7546f1232660a73c548f975e..721557a10d26ca9afeb418f74b29399a2a993f6a 100644 (file)
@@ -30,6 +30,7 @@
 #include <gtkmm/box.h>
 #include <gtkmm/radiobutton.h>
 #include <gtkmm/filechooserbutton.h>
+#include <gtkmm/comboboxtext.h>
 
 #include "ardour/utils.h"
 
@@ -68,6 +69,11 @@ private:
        void setup_first_time_config_page ();
        void config_changed ();
 
+       /* Welcome */
+       Gtk::ComboBoxText ui_font_scale;
+       void rescale_ui ();
+       void guess_default_ui_scale ();
+
        /* first page */
        Gtk::FileChooserButton* default_dir_chooser;
        void default_dir_changed();