[gnome-shell/gnome-3-36] iconGrid: Account for non-icon content and padding/spacing when scaling



commit 6b86b6a3e2d06941d88fe51d9ed1367549924eb4
Author: Sebastian Keller <skeller gnome org>
Date:   Sun Jul 19 14:41:18 2020 +0200

    iconGrid: Account for non-icon content and padding/spacing when scaling
    
    _updateIconSizes() was assuming that the icon is the only content of
    an item when scaling the icon size to ensure the item size matches
    _fixedHItemSize/_fixedVItemSize. However the icon may have padding and
    there might be a label and spacing between the icon and the label. This
    resulted in items being larger than their slots.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2234

 js/ui/iconGrid.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 25cd140992..6e691c58ad 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -845,8 +845,10 @@ var IconGrid = GObject.registerClass({
     // Note that this is ICON_SIZE as used by BaseIcon, not elsewhere in IconGrid; it's a bit messed up
     _updateIconSizes() {
         this._updateIconSizesLaterId = 0;
-        let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize, 
this._vItemSize);
-        let newIconSize = Math.floor(ICON_SIZE * scale);
+        let extraWidth = Math.max(0, this._hItemSize - ICON_SIZE);
+        let extraHeight = Math.max(0, this._vItemSize - ICON_SIZE);
+        let newIconSize = Math.min(this._fixedHItemSize - extraWidth,
+                                   this._fixedVItemSize - extraHeight);
         for (let i in this._items)
             this._items[i].icon.setIconSize(newIconSize);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]