From 4dbbd2f754bd5b9d68c2dee0a0c1b65ed0ab7620 Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Sun, 25 Dec 2022 17:08:16 +0100 Subject: [PATCH 1/2] Fractional scaling for most button icons based on DPI **Motivation / Previous State:** Currently, GTK uses integer scaling factors for the scaling of button icons and everything else: 96 DPI = 100%, 192 DPI = 200%, 3*96 GPI = 300%, ..., but nothing inbetween. This is particularly annoying on screens that have about 1.5 * 96 DPI (e.g. 4K 30inch, or FullHD with 13" notebooks), where you get tiny icons (1x scaling) or with workarounds you can change them to very large icons (2x scaling), but nothing inbetween. Only the toolbars can currently be adjusted but not the dialogs. (2x scaling can be enabled, on Linux by setting GDK_SCALE=2 GDK_DPI_SCALE=0.5. Note that on GNOME, GTK_SCALE has no effect and you instead have to switch your display from "100%" to "200%". On Windows you don't need any environment variables, just change the system settings from 150% to 200% sizing. In all cases, Inkscape needs a restart.). **Change:** Scale most icons continuously depending on the DPI, so that the icon size grows proportional to the UI font size. For example, at 1.5*96 DPI, a default (16px logical GTK size) button icon will be scaled to 1.5*16 physical device pixels. At 2*96DPI, the icons will have the usual size as before (2 * 16 px for default button icons). At 2.3*96, the size will be 2.3*16px, split into a factor 2 done implicitly by GTK (1 GTK pixel = 2 screen pixels due to GTK_SCALE) and a factor done by this code (GTK screen_get_resolution will return 2.3/2*96 DPI, and we accordingly scale the icon to ceil(16*2.3/2) logical GTK pixels, approximately 16*2.3 physical device pixels. ). **How to test:** Start inkscape with the configuration of GDK_DPI_SCALE=1.9 (for a more extreme effect, increase this to a value of 3) and observe that most icons grow proportional to the text size, e.g. in the align and distribute and layers dialog. If text does not scale, this is a separate issue. If icons do not scale, then this code should be improved. For a more realistic test, try different PCs with different DPI configurations. On Windows change the Display scaling setting to "odd" sizes like 150% or 175% and compare the size of Inkscape to other applications. During testing you may have to clear your inkscape settings or you have to ignore some other bugs (toolbar needs manual resizing because it remembers old width values). **Future work / Open issues:** - Adjustment using a configuration option is not yet implemented but could be added easily. - Resizing the icons on DPI change is not implemented, this currently needs a restart. - The scaling should be applied to further details of the UI (menu entries, CMS preview button near the scrollbar, ...). - Detailed testing in many OS and theme configurations. - Maybe upstream to GTK (just hijack the point where the icon sizes are looked up and return a scaled value.) **Related issues:** I couldn't find an exact matching issue, but there are many similar problems: - Dialog icons are too small and not adjustable https://gitlab.com/inkscape/inbox/-/issues/6491 - Generic "Icons are too small" issues https://gitlab.com/inkscape/inbox/-/issues/7847 - Scaling on 2K monitors not optimal https://gitlab.com/inkscape/inbox/-/issues/7283 - Some system icons are rendered too large (colud be 'accidentally' solved in all places where we force a pixel size) https://gitlab.com/inkscape/inkscape/-/issues/431 --- src/ui/dialog/align-and-distribute.cpp | 4 + src/ui/dialog/dialog-container.cpp | 3 +- src/ui/dialog/layer-properties.cpp | 6 +- src/ui/dialog/objects.cpp | 5 -- src/ui/dialog/tile.cpp | 5 +- src/ui/dialog/xml-tree.cpp | 4 + src/ui/icon-loader.cpp | 14 ++-- src/ui/themes.cpp | 111 +++++++++++++++++++++++++ src/ui/themes.h | 12 +++ src/ui/widget/color-palette.cpp | 16 ++-- src/ui/widget/imagetoggler.cpp | 8 +- src/ui/widget/imagetoggler.h | 3 +- src/ui/widget/paint-selector.cpp | 2 +- src/widgets/toolbox.cpp | 4 +- 14 files changed, 170 insertions(+), 27 deletions(-) diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 1bb2d5a06d..b6af330cb8 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -27,6 +27,7 @@ #include "actions/actions-tools.h" // Tool switching. #include "io/resource.h" #include "ui/dialog/dialog-base.h" // Tool switching. +#include "ui/themes.h" // Icon scaling namespace Inkscape { namespace UI { @@ -171,6 +172,9 @@ AlignAndDistribute::AlignAndDistribute(Inkscape::UI::Dialog::DialogBase* dlg) } } + // ------------ Apply icon scaling ---------------- + ThemeContext::applyIconScaling(this); + // ------------ Set initial values ------------ diff --git a/src/ui/dialog/dialog-container.cpp b/src/ui/dialog/dialog-container.cpp index 6735ff1ac8..cb011b2688 100644 --- a/src/ui/dialog/dialog-container.cpp +++ b/src/ui/dialog/dialog-container.cpp @@ -60,6 +60,7 @@ #include "ui/dialog/xml-tree.h" #include "ui/icon-names.h" #include "ui/widget/canvas-grid.h" +#include "ui/themes.h" namespace Inkscape { namespace UI { @@ -169,7 +170,7 @@ Gtk::Widget *DialogContainer::create_notebook_tab(Glib::ustring label_str, Glib: Gtk::Label *label = Gtk::manage(new Gtk::Label(label_str)); Gtk::Image *image = Gtk::manage(new Gtk::Image()); Gtk::Button *close = Gtk::manage(new Gtk::Button()); - image->set_from_icon_name(image_str, Gtk::ICON_SIZE_MENU); + image->set_from_icon_name(image_str, ThemeContext::getScaledIconSize(Gtk::ICON_SIZE_MENU)); Gtk::Box *tab = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 2)); close->set_image_from_icon_name("window-close"); close->set_halign(Gtk::ALIGN_END); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 9ea78e4cf6..5476168bcd 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later /** * @file - * Dialog for renaming layers. + * Dialog for selecting a layer in certain actions. + * This dialog (LayerPropertiesDialog) is only used in few places, e.g. in the menu action "move to layer". + * This dialog is NOT used for "Objects and Layers" that you usually see in the GUI, see ObjectsPanel instead. */ /* Author: * Bryce W. Harrington @@ -299,6 +301,8 @@ void LayerPropertiesDialog::_setup_layers_controls() int nameColNum = _tree.append_column("Name", *_text_renderer) - 1; Gtk::TreeView::Column *_name_column = _tree.get_column(nameColNum); _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel); + _name_column->set_expand(true); + _tree.set_expander_column(*_tree.get_column(nameColNum)); _tree.signal_key_press_event().connect([=](GdkEventKey *ev) {return _handleKeyEvent(ev);}, false); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index dfd5751cca..338690eed0 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -707,10 +707,8 @@ ObjectsPanel::ObjectsPanel() : _is_editing = false; }); - const int icon_col_width = 24; auto icon_renderer = Gtk::manage(new Inkscape::UI::Widget::CellRendererItemIcon()); icon_renderer->property_xpad() = 2; - icon_renderer->property_width() = icon_col_width; _tree.append_column(*_name_column); _name_column->set_expand(true); _name_column->pack_start(*icon_renderer, false); @@ -731,7 +729,6 @@ ObjectsPanel::ObjectsPanel() : col->add_attribute(_item_state_toggler->property_active_icon(), _model->_colItemState); col->add_attribute(_item_state_toggler->property_cell_background_rgba(), _model->_colBgColor); col->add_attribute(_item_state_toggler->property_activatable(), _model->_colHover); - col->set_fixed_width(icon_col_width); _blend_mode_column = col; } @@ -830,7 +827,6 @@ ObjectsPanel::ObjectsPanel() : eye->add_attribute(eyeRenderer->property_cell_background_rgba(), _model->_colBgColor); eye->add_attribute(eyeRenderer->property_activatable(), _model->_colHover); eye->add_attribute(eyeRenderer->property_gossamer(), _model->_colAncestorInvisible); - eye->set_fixed_width(icon_col_width); _eye_column = eye; } @@ -843,7 +839,6 @@ ObjectsPanel::ObjectsPanel() : lock->add_attribute(lockRenderer->property_cell_background_rgba(), _model->_colBgColor); lock->add_attribute(lockRenderer->property_activatable(), _model->_colHover); lock->add_attribute(lockRenderer->property_gossamer(), _model->_colAncestorLocked); - lock->set_fixed_width(icon_col_width); _lock_column = lock; } diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 661c4f663f..68aeaed65b 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -23,15 +23,16 @@ #include "ui/dialog/polar-arrange-tab.h" #include "ui/dialog/align-and-distribute.h" #include "ui/icon-names.h" +#include "ui/icon-loader.h" namespace Inkscape { namespace UI { namespace Dialog { Gtk::Box& create_tab_label(const char* label_text, const char* icon_name) { + // TODO deduplicate with FillAndStroke::_createPageTabLabel and posibly others auto box = Gtk::make_managed(Gtk::ORIENTATION_HORIZONTAL, 4); - auto image = Gtk::make_managed(); - image->set_from_icon_name(icon_name, Gtk::ICON_SIZE_MENU); + auto image = Gtk::manage(sp_get_icon_image(icon_name, Gtk::ICON_SIZE_MENU)); auto label = Gtk::make_managed(label_text, true); box->pack_start(*image, false, true); box->pack_start(*label, false, true); diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 2dfad025cb..460288df07 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -46,6 +46,7 @@ #include "ui/icon-loader.h" #include "ui/icon-names.h" #include "ui/tools/tool-base.h" +#include "ui/themes.h" #include "widgets/sp-xmlview-tree.h" @@ -204,6 +205,9 @@ XmlTree::XmlTree() static_cast(item)->signal_activate().connect([=](){ set_layout(layout); }); } + // apply DPI-dependent icon scaling + ThemeContext::applyIconScaling(this); + _layout = static_cast(prefs->getIntLimited("/dialogs/xml/layout", Auto, Auto, Vertical)); static_cast(menu_items.at(_layout))->set_active(); set_layout(_layout); diff --git a/src/ui/icon-loader.cpp b/src/ui/icon-loader.cpp index f524028ce2..16f6139377 100644 --- a/src/ui/icon-loader.cpp +++ b/src/ui/icon-loader.cpp @@ -16,6 +16,7 @@ #include "io/resource.h" #include "svg/svg-color.h" #include "widgets/toolbox.h" +#include "ui/themes.h" #include #include @@ -26,31 +27,32 @@ Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size) { Gtk::Image *icon = new Gtk::Image(); icon->set_from_icon_name(icon_name, Gtk::IconSize(Gtk::ICON_SIZE_BUTTON)); - icon->set_pixel_size(size); + icon->set_pixel_size(Inkscape::UI::ThemeContext::getScaledIconSize(size)); return icon; } Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::IconSize icon_size) { - Gtk::Image *icon = new Gtk::Image(); - icon->set_from_icon_name(icon_name, icon_size); - return icon; + int width, height; + Gtk::IconSize::lookup(icon_size, width, height); + return sp_get_icon_image(icon_name, width); } Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size) { Gtk::Image *icon = new Gtk::Image(); - icon->set_from_icon_name(icon_name, icon_size); + icon->set_from_icon_name(icon_name, Inkscape::UI::ThemeContext::getScaledIconSize(icon_size)); return icon; } GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size) { - return gtk_image_new_from_icon_name(icon_name.c_str(), icon_size); + return gtk_image_new_from_icon_name(icon_name.c_str(), Inkscape::UI::ThemeContext::getScaledIconSize(icon_size)); } Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) { + size = Inkscape::UI::ThemeContext::getScaledIconSize(size); // SP_ACTIVE_DESKTOP is not always available when we want icons (see start screen) auto window = SP_ACTIVE_DESKTOP ? SP_ACTIVE_DESKTOP->getToplevel() : nullptr; diff --git a/src/ui/themes.cpp b/src/ui/themes.cpp index bb58245755..27e802a670 100644 --- a/src/ui/themes.cpp +++ b/src/ui/themes.cpp @@ -25,6 +25,7 @@ #include #include #include "svg/css-ostringstream.h" +#include "src/widgets/spw-utilities.h" // sp_traverse_widget namespace Inkscape { namespace UI { @@ -531,6 +532,116 @@ void ThemeContext::adjust_global_font_scale(double factor) { Gtk::StyleContext::add_provider_for_screen(screen, _fontsizeprovider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - 1); } + +/** + * Apply fractional scaling to icon size. + * + * Gtk natively only uses integer scaling (e.g. factor 2 for screens with >= 2 * 96 DPI). + * Therefore we need to do fractional scaling (e.g. factor 1.5 for 1.5 * 96 DPI) on our own. + * This function multiplies the raw icon size (e.g., 16) by a fractional factor. + * The integer part of the scaling factor is ignored because Gtk does this transparently. + * For example, for 2.5 * 96 DPI Gtk will scale all logical pixels by factor 2. + * so Inkscape itself needs to handle the remaining factor 1.25. + * + * @param window current window + * @param icon_size_px original icon size in logical Gtk pixels + * @return scaled icon size in logical Gtk pixels + */ +guint ThemeContext::getScaledIconSize(Glib::RefPtr window, guint icon_size_px) { + Glib::RefPtr screen; + if (window) { + screen = window->get_screen(); + } else { + g_debug("getScaledIconSize called with nullptr window. Falling back to default window."); + Glib::RefPtr display = Gdk::Display::get_default(); + screen = display->get_default_screen(); + } + if (!screen) { + g_warning("failed to get default screen"); + return icon_size_px; + } + double dpi = screen->get_resolution(); + if (dpi < 96) { + dpi = 96; + } + return ceil(icon_size_px * dpi / 96.); +} + +guint ThemeContext::getScaledIconSize(guint iconSizePx) { + // FIXME suppress warning + // TODO DOC + // Limitation: this doesn't get the actual screen of the window, just the default screen + return ThemeContext::getScaledIconSize(Glib::RefPtr(), iconSizePx); +} + + +/** + * Apply fractional scaling to icon size. + * + * This variant of the function operates on predefined icon sizes and gets the next-best predefined size. + * + * @see ThemeContext::getScaledIconSize(Gtk::Window *window, guint icon_size_px) +*/ +Gtk::BuiltinIconSize ThemeContext::getScaledIconSize(Glib::RefPtr window, Gtk::BuiltinIconSize icon_size) { + int width, height; + Gtk::IconSize::lookup(icon_size, width, height); + int scaled_width = ThemeContext::getScaledIconSize(window, width); + if (scaled_width == width) { + return icon_size; + } else if (scaled_width >= (48 * 0.9)) { + return Gtk::BuiltinIconSize::ICON_SIZE_DIALOG; // 48px + } else if (scaled_width >= (32 * 0.9)) { + return Gtk::BuiltinIconSize::ICON_SIZE_DND; // 32px + } else if (scaled_width >= (24 * 0.9)) { + return Gtk::BuiltinIconSize::ICON_SIZE_LARGE_TOOLBAR; // 24px + } else { + return icon_size; // 16px - return unchanged + } +} + +Gtk::BuiltinIconSize ThemeContext::getScaledIconSize(Gtk::BuiltinIconSize icon_size) { + // TODO DOC + // For limitations, see other getScaledIconSize implementations + return ThemeContext::getScaledIconSize(Glib::RefPtr(), icon_size); +} + + +GtkIconSize ThemeContext::getScaledIconSize(GtkIconSize icon_size) { + return static_cast(ThemeContext::getScaledIconSize(static_cast(icon_size))); +} + +/** + * For each button icon in all sub-widgets, update the icon size to apply fractional DPI scaling. + * TODO: also add a configurable user scale factor + * TODO: support further widget types +*/ +void ThemeContext::applyIconScaling(Gtk::Widget *widget) { + sp_traverse_widget_tree(widget, [=](Gtk::Widget* subwidget){ + // For each button: + auto button = dynamic_cast(subwidget); + if (!button) { + return false; + } + // For each image inside the button ... + auto image = dynamic_cast(button->get_image()); + if (!image) { + return false; + } + // ... that has the icon-size property set (e.g. GTK_ICON_SIZE_BUTTON): + int icon_size = image->property_icon_size(); + if (icon_size <= 0) { + return false; + } + // determine scaled icon size + int width, height; + Gtk::IconSize::lookup(Gtk::IconSize(icon_size), width, height); + int scaled_width = ThemeContext::getScaledIconSize(image->get_window(), width); + // and apply it + image->set_pixel_size(scaled_width); + return false; + }); +} + } // UI } // Inkscape diff --git a/src/ui/themes.h b/src/ui/themes.h index a99cd3ea13..5258eadf5e 100644 --- a/src/ui/themes.h +++ b/src/ui/themes.h @@ -58,6 +58,18 @@ bool isCurrentThemeDark(Gtk::Container *window); static std::vector getHighlightColors(Gtk::Window *window); +static guint getScaledIconSize(guint iconSizePx); + +static guint getScaledIconSize(Glib::RefPtr window, guint iconSizePx); + +static Gtk::BuiltinIconSize getScaledIconSize(Gtk::BuiltinIconSize icon_size); + +static GtkIconSize getScaledIconSize(GtkIconSize icon_size); + +static void applyIconScaling(Gtk::Widget *widget); + +static Gtk::BuiltinIconSize getScaledIconSize(Glib::RefPtr window, Gtk::BuiltinIconSize icon_size); + private: // user change theme sigc::signal _signal_change_theme; diff --git a/src/ui/widget/color-palette.cpp b/src/ui/widget/color-palette.cpp index cb01c1536d..cfe86167f1 100644 --- a/src/ui/widget/color-palette.cpp +++ b/src/ui/widget/color-palette.cpp @@ -13,6 +13,8 @@ #include "color-palette.h" #include "ui/builder-utils.h" +#include "ui/themes.h" + namespace Inkscape { namespace UI { @@ -455,18 +457,20 @@ void ColorPalette::set_up_scrolling() { } int ColorPalette::get_tile_size(bool horz) const { - if (_stretch_tiles) return _size; double aspect = horz ? _aspect : -_aspect; - if (aspect > 0) { - return static_cast(round((1.0 + aspect) * _size)); + if (_stretch_tiles) { + aspect = 0; } - else if (aspect < 0) { - return static_cast(round((1.0 / (1.0 - aspect)) * _size)); + + int scaled_size = ThemeContext::getScaledIconSize(this->get_window(), _size); + + if (aspect >= 0) { + return static_cast(round((1.0 + aspect) * scaled_size)); } else { - return _size; + return static_cast(round((1.0 / (1.0 - aspect)) * scaled_size)); } } diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp index 829c470eaf..518a01843e 100644 --- a/src/ui/widget/imagetoggler.cpp +++ b/src/ui/widget/imagetoggler.cpp @@ -15,6 +15,7 @@ #include "ui/icon-loader.h" #include "ui/icon-names.h" +#include "ui/themes.h" namespace Inkscape { namespace UI { @@ -33,7 +34,8 @@ ImageToggler::ImageToggler( char const* on, char const* off) : _property_pixbuf_off(*this, "pixbuf_off", Glib::RefPtr(nullptr)) { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; - Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, _size, _size); + Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, _icon_size_raw, _icon_size_raw); + _size = ThemeContext::getScaledIconSize(_icon_size_raw); } void ImageToggler::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -61,8 +63,8 @@ void ImageToggler::render_vfunc( const Cairo::RefPtr& cr, // Lazy/late pixbuf rendering to get access to scale factor from widget. if(!_property_pixbuf_on.get_value()) { int scale = widget.get_scale_factor(); - _property_pixbuf_on = sp_get_icon_pixbuf(_pixOnName, _size * scale); - _property_pixbuf_off = sp_get_icon_pixbuf(_pixOffName, _size * scale); + _property_pixbuf_on = sp_get_icon_pixbuf(_pixOnName, _icon_size_raw * scale); + _property_pixbuf_off = sp_get_icon_pixbuf(_pixOffName, _icon_size_raw * scale); } std::string icon_name = _property_active_icon.get_value(); diff --git a/src/ui/widget/imagetoggler.h b/src/ui/widget/imagetoggler.h index 579f6b9ff9..a6ed2d5138 100644 --- a/src/ui/widget/imagetoggler.h +++ b/src/ui/widget/imagetoggler.h @@ -60,7 +60,8 @@ protected: private: - int _size; + int _size; /// size after applying fractional icon size scaling (ThemeContext::getScaledIconSize()) + int _icon_size_raw; /// size before applying fractional icon size scaling (e.g. 16 pixels) Glib::ustring _pixOnName; Glib::ustring _pixOffName; bool _active = false; diff --git a/src/ui/widget/paint-selector.cpp b/src/ui/widget/paint-selector.cpp index 450493bec6..acda306acb 100644 --- a/src/ui/widget/paint-selector.cpp +++ b/src/ui/widget/paint-selector.cpp @@ -186,7 +186,7 @@ PaintSelector::PaintSelector(FillOrStroke kind) _evenodd->set_tooltip_text( _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)")); _evenodd->set_fillrule(PaintSelector::FILLRULE_EVENODD); - auto w = sp_get_icon_image("fill-rule-even-odd", GTK_ICON_SIZE_MENU); + auto w = sp_get_icon_image("fill-rule-even-odd", GTK_ICON_SIZE_MENU); // TODO make scalable gtk_container_add(GTK_CONTAINER(_evenodd->gobj()), w); _fillrulebox->pack_start(*_evenodd, false, false, 0); _evenodd->signal_toggled().connect( diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 907e9e178e..b66b649381 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -40,6 +40,7 @@ #include "ui/widget/style-swatch.h" #include "widgets/spw-utilities.h" // sp_traverse_widget_tree() #include "widgets/widget-sizes.h" +#include "ui/themes.h" #include "ui/toolbar/arc-toolbar.h" #include "ui/toolbar/box3d-toolbar.h" @@ -89,6 +90,7 @@ enum BarId { #define BAR_ID_KEY "BarIdValue" #define HANDLE_POS_MARK "x-inkscape-pos" + int ToolboxFactory::prefToPixelSize(Glib::ustring const& path) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int size = prefs->getIntLimited(path, 16, 16, 48); @@ -99,7 +101,7 @@ void ToolboxFactory::set_icon_size(GtkWidget* toolbox, int pixel_size) { sp_traverse_widget_tree(Glib::wrap(toolbox), [=](Gtk::Widget* widget) { if (auto ico = dynamic_cast(widget)) { ico->set_from_icon_name(ico->get_icon_name(), static_cast(Gtk::ICON_SIZE_BUTTON)); - ico->set_pixel_size(pixel_size); + ico->set_pixel_size(ThemeContext::getScaledIconSize(widget->get_window(), pixel_size)); } return false; }); -- GitLab From 8f7f9b3a1a5d6a38add735305256c91f54b6a54c Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Sun, 1 Jan 2023 15:08:53 +0100 Subject: [PATCH 2/2] icon scaling for LPE Tiling pattern editor --- src/ui/widget/pattern-editor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ui/widget/pattern-editor.cpp b/src/ui/widget/pattern-editor.cpp index d9a52aab9d..ddba3b1787 100644 --- a/src/ui/widget/pattern-editor.cpp +++ b/src/ui/widget/pattern-editor.cpp @@ -34,6 +34,7 @@ #include "preferences.h" #include "util/units.h" #include "widgets/spw-utilities.h" +#include "ui/themes.h" namespace Inkscape { namespace UI { @@ -271,6 +272,9 @@ PatternEditor::PatternEditor(const char* prefs, Inkscape::PatternManager& manage update_scale_link(); pack_start(_main_grid); + + // scale icons (fractionally) according to DPI + ThemeContext::applyIconScaling(this); } PatternEditor::~PatternEditor() noexcept {} -- GitLab