>From 6478ff8a4b65fbe4f18a1e1237768e48e34d15f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sun, 15 Jul 2012 15:25:10 +0200
Subject: [PATCH 4/5] Better icon scale

The icons should be scaled if their size is "max_size - ~3 pixels".
Tipically, max_size is 64 pixels. With the current wIconValidateIconSize
the max size for an icon is "64 pixels", then the icon don't have border
and is ugly. This problem is in the dock icons and in the switchpanel.

The new wIconValidateIconSize function don't use the fixel value of 64
pixels, uses the argument max_size to get the final icon size. The icon
is scaled holding the aspect ratio and reserve ~2 or ~3 pixels to hold
left space to the icon border. Now the icon is inside the icon space,
with border.

This patch removes the preprocessor option of DONT_SCALE_ICONS, because
all the icons should be scaled if needed, to hold a beatiful interface.
---
 src/icon.c       |   19 +++++++++----------
 src/wconfig.h.in |    3 ---
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 6537ece..8772f2c 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -50,6 +50,7 @@ extern WPreferences wPreferences;
 
 #define MOD_MASK wPreferences.modifier_mask
 #define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
+#define ICON_BORDER 3
 
 extern Cursor wCursor[WCUR_LAST];
 
@@ -337,23 +338,21 @@ void wIconChangeTitle(WIcon * icon, char *new_title)
        wIconPaint(icon);
 }
 
-RImage *wIconValidateIconSize(WScreen * scr, RImage * icon, int max_size)
+RImage *wIconValidateIconSize(WScreen *scr, RImage *icon, int max_size)
 {
-       RImage *tmp;
-       int w, h;
+       RImage *nimage;
 
        if (!icon)
                return NULL;
-#ifndef DONT_SCALE_ICONS
-       if (max_size != 64) {
-               w = max_size * icon->width / 64;
-               h = max_size * icon->height / 64;
 
-               tmp = RScaleImage(icon, w, h);
+       /* We should hold "ICON_BORDER" (~2) pixels to include the icon border 
*/
+       if ((icon->width - max_size) > -ICON_BORDER ||
+           (icon->height - max_size) > -ICON_BORDER) {
+               nimage = RScaleImage(icon, max_size - ICON_BORDER,
+                                    (icon->height * (max_size - ICON_BORDER) / 
icon->width));
                RReleaseImage(icon);
-               icon = tmp;
+               icon = nimage;
        }
-#endif
 
        return icon;
 }
diff --git a/src/wconfig.h.in b/src/wconfig.h.in
index 4bda5e6..0046863 100644
--- a/src/wconfig.h.in
+++ b/src/wconfig.h.in
@@ -99,9 +99,6 @@
  */
 #undef IGNORE_PPOSITION
 
-/* Do not scale application icon and miniwindow icon images */
-#undef DONT_SCALE_ICONS
-
 /*
  * The following options WILL NOT BE MADE RUN-TIME. Please do not request.
  * They will only add unneeded bloat.
-- 
1.7.10.4

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 6478ff8a4b65fbe4f18a1e1237768e48e34d15f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sun, 15 Jul 2012 15:25:10 +0200
Subject: [PATCH 4/5] Better icon scale

The icons should be scaled if their size is "max_size - ~3 pixels".
Tipically, max_size is 64 pixels. With the current wIconValidateIconSize
the max size for an icon is "64 pixels", then the icon don't have border
and is ugly. This problem is in the dock icons and in the switchpanel.

The new wIconValidateIconSize function don't use the fixel value of 64
pixels, uses the argument max_size to get the final icon size. The icon
is scaled holding the aspect ratio and reserve ~2 or ~3 pixels to hold
left space to the icon border. Now the icon is inside the icon space,
with border.

This patch removes the preprocessor option of DONT_SCALE_ICONS, because
all the icons should be scaled if needed, to hold a beatiful interface.
---
 src/icon.c       |   19 +++++++++----------
 src/wconfig.h.in |    3 ---
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 6537ece..8772f2c 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -50,6 +50,7 @@ extern WPreferences wPreferences;
 
 #define MOD_MASK wPreferences.modifier_mask
 #define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
+#define ICON_BORDER 3
 
 extern Cursor wCursor[WCUR_LAST];
 
@@ -337,23 +338,21 @@ void wIconChangeTitle(WIcon * icon, char *new_title)
 	wIconPaint(icon);
 }
 
-RImage *wIconValidateIconSize(WScreen * scr, RImage * icon, int max_size)
+RImage *wIconValidateIconSize(WScreen *scr, RImage *icon, int max_size)
 {
-	RImage *tmp;
-	int w, h;
+	RImage *nimage;
 
 	if (!icon)
 		return NULL;
-#ifndef DONT_SCALE_ICONS
-	if (max_size != 64) {
-		w = max_size * icon->width / 64;
-		h = max_size * icon->height / 64;
 
-		tmp = RScaleImage(icon, w, h);
+	/* We should hold "ICON_BORDER" (~2) pixels to include the icon border */
+	if ((icon->width - max_size) > -ICON_BORDER ||
+	    (icon->height - max_size) > -ICON_BORDER) {
+		nimage = RScaleImage(icon, max_size - ICON_BORDER,
+				     (icon->height * (max_size - ICON_BORDER) / icon->width));
 		RReleaseImage(icon);
-		icon = tmp;
+		icon = nimage;
 	}
-#endif
 
 	return icon;
 }
diff --git a/src/wconfig.h.in b/src/wconfig.h.in
index 4bda5e6..0046863 100644
--- a/src/wconfig.h.in
+++ b/src/wconfig.h.in
@@ -99,9 +99,6 @@
  */
 #undef IGNORE_PPOSITION
 
-/* Do not scale application icon and miniwindow icon images */
-#undef DONT_SCALE_ICONS
-
 /*
  * The following options WILL NOT BE MADE RUN-TIME. Please do not request.
  * They will only add unneeded bloat.
-- 
1.7.10.4

Reply via email to