Way of the Monkey
February 2007
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28
Donate!
Projects
Tango Portfolio
Cool People
Anna Dirks
Andreas Nilsson
Andy Fitzsimmon
Frédéric Bellaiche
Hylke Bons
Jakub Steiner
Josef Vybiral
Olivier Charavel
Ryan Collier
Sebastian Kraft
Simon Pascal Klein
Steven Garrity
Tuomas Kuosmanen
Vinicius Depizzol
Recent Music
Icon Scaling for n00bs Tue, 13 Feb 2007 12:15:29 -0500

Recently, I had worked on a patch to fix the scaling of icons, in resapplet. I just filed a bug, and submitted that patch upstream, as well, as #407523. This patch implements the following algorithm, and removes the block of code that would call gdk_pixbuf_scale_simple to scale the image down a pixel or two in most cases:

+	if (panel_h < 22)
+	  icon_size = 16;
+	else if (panel_h >= 22 && panel_h < 32)
+	  icon_size = 22;
+	else if (panel_h >= 32 && panel_h < 48)
+	  icon_size = 32;
+	else if (panel_h >= 48)
+	  icon_size = panel_h;

This is basically The Right Way (TM) to do icon size selection for panel applets. If all applets did things this way, then the icon sizes would be the same for all applets on a panel. It would also mean that we could guarantee sharpness for reasonable panel sizes.

Jakub asked me to blog about this, so developers, fix your applets. Panel applets and tray icons are also not the only places where this makes sense. Anywhere that you may need to scale icons to fill different allocation sizes for widgets, it makes sense to use this algorithm.




Ninja Monkey icon based on face-monkey icon from The Tango Project