From 01b646169ca1a5f3a7abe5840c62eb251dcbe37f Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Fri, 11 Feb 2011 14:37:27 -0500 Subject: [PATCH] Fix fuzziness for application icons - Center the icon texture in the area allocated for it, and always give the nominal size - avoid off-by-one scaling if the parent allocated a little less or more size than we wanted. - Use Math.floor() when centering horizontally to avoid allocation at a half pixel. https://bugzilla.gnome.org/show_bug.cgi?id=642124 --- js/ui/iconGrid.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js index 4bd6485df..91cc0c3f4 100644 --- a/js/ui/iconGrid.js +++ b/js/ui/iconGrid.js @@ -63,6 +63,7 @@ BaseIcon.prototype = { let iconSize = availHeight; let [iconMinHeight, iconNatHeight] = this._iconBin.get_preferred_height(-1); + let [iconMinWidth, iconNatWidth] = this._iconBin.get_preferred_width(-1); let preferredHeight = iconNatHeight; let childBox = new Clutter.ActorBox(); @@ -82,12 +83,10 @@ BaseIcon.prototype = { this._name.allocate(childBox, flags); } - let iconPadding = (availWidth - iconSize) / 2; - - childBox.x1 = iconPadding; - childBox.y1 = 0; - childBox.x2 = availWidth - iconPadding; - childBox.y2 = iconSize; + childBox.x1 = Math.floor((availWidth - iconNatWidth) / 2); + childBox.y1 = Math.floor((iconSize - iconNatHeight) / 2); + childBox.x2 = childBox.x1 + iconNatWidth; + childBox.y2 = childBox.y1 + iconNatHeight; this._iconBin.allocate(childBox, flags); },