From: Christophe CURIS <christophe.cu...@free.fr>

In order to keep compatibility for the WINGs public API:

- created new function instead of changing the parameters of the legacy
function;

- swapped arguments to use the logical order (width / height) instead of
the reverse

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 WINGs/WINGs/WINGs.h |  7 ++++++-
 WINGs/wpixmap.c     | 18 ++++++++++++------
 src/dialog.c        |  8 +++++---
 src/dockedapp.c     |  2 +-
 4 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h
index aa95844..3004d2d 100644
--- a/WINGs/WINGs/WINGs.h
+++ b/WINGs/WINGs/WINGs.h
@@ -839,7 +839,12 @@ WMPixmap* WMCreateBlendedPixmapFromRImage(WMScreen 
*scrPtr, RImage *image,
                                           const RColor *color);
 
 WMPixmap* WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, const char *fileName,
-                                        const RColor *color, unsigned wHeight, 
unsigned wWidth);
+                                        const RColor *color);
+
+WMPixmap* WMCreateScaledBlendedPixmapFromFile(WMScreen *scrPtr, const char 
*fileName,
+                                              const RColor *color,
+                                              unsigned int width,
+                                              unsigned int height);
 
 void WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y);
 
diff --git a/WINGs/wpixmap.c b/WINGs/wpixmap.c
index 5511a13..d5800a4 100644
--- a/WINGs/wpixmap.c
+++ b/WINGs/wpixmap.c
@@ -117,8 +117,13 @@ WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * 
scrPtr, RImage * image, con
        return pixPtr;
 }
 
-WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, const char 
*fileName, const RColor * color,
-                                       unsigned wHeight, unsigned wWidth)
+WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, const char 
*fileName, const RColor * color)
+{
+       return WMCreateScaledBlendedPixmapFromFile(scrPtr, fileName, color, 0, 
0);
+}
+
+WMPixmap *WMCreateScaledBlendedPixmapFromFile(WMScreen *scrPtr, const char 
*fileName, const RColor *color,
+                                              unsigned int width, unsigned int 
height)
 {
        WMPixmap *pixPtr;
        RImage *image;
@@ -127,14 +132,15 @@ WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * 
scrPtr, const char *fileName,
        if (!image)
                return NULL;
 
-       /* scale it if requested to fit in the widget */
-       if (wHeight > 0 && wWidth > 0 && (image->height > wHeight || 
image->width > wWidth)) {
+       /* scale it if needed to fit in the specified box */
+       if ((width > 0) && (height > 0) && ((image->width > width) || 
(image->height > height))) {
                RImage *tmp;
+
                tmp = image;
                if (image->width > image->height)
-                       image = RScaleImage(tmp, wWidth, image->height * 
wHeight / image->width);
+                       image = RScaleImage(tmp, width, image->height * height 
/ image->width);
                else
-                       image = RScaleImage(tmp, image->width * wWidth / 
image->height, wHeight);
+                       image = RScaleImage(tmp, image->width * width / 
image->height, height);
                RReleaseImage(tmp);
        }
 
diff --git a/src/dialog.c b/src/dialog.c
index 5218866..fd43cfb 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -619,7 +619,7 @@ static void setViewedImage(IconPanel *panel, const char 
*file)
        color.green = 0xaa;
        color.blue = 0xae;
        color.alpha = 0;
-       pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), 
file, &color, 75, 75);
+       pixmap = 
WMCreateScaledBlendedPixmapFromFile(WMWidgetScreen(panel->win), file, &color, 
75, 75);
 
        if (!pixmap) {
                WMSetButtonEnabled(panel->okButton, False);
@@ -650,7 +650,9 @@ static void listCallback(void *self, void *data)
                path = item->text;
 
                WMSetTextFieldText(panel->fileField, path);
+
                WMSetLabelImage(panel->iconView, NULL);
+
                WMSetButtonEnabled(panel->okButton, False);
 
                WMClearList(panel->iconList);
@@ -741,7 +743,7 @@ static void drawIconProc(WMList * lPtr, int index, Drawable 
d, char *text, int s
        color.blue = WMBlueComponentOfColor(back) >> 8;
        color.alpha = WMGetColorAlpha(back) >> 8;
 
-       pixmap = WMCreateBlendedPixmapFromFile(wmscr, file, &color, 0, 0);
+       pixmap = WMCreateBlendedPixmapFromFile(wmscr, file, &color);
        wfree(file);
 
        if (!pixmap) {
@@ -1523,7 +1525,7 @@ static WMPixmap *getWindowMakerIconImage(WMScreen *scr)
                gray.blue = 0xae;
                gray.alpha = 0;
 
-               pix = WMCreateBlendedPixmapFromFile(scr, path, &gray, 0, 0);
+               pix = WMCreateBlendedPixmapFromFile(scr, path, &gray);
                wfree(path);
        }
 
diff --git a/src/dockedapp.c b/src/dockedapp.c
index 502c830..63a4864 100644
--- a/src/dockedapp.c
+++ b/src/dockedapp.c
@@ -103,7 +103,7 @@ static void updateSettingsPanelIcon(AppSettingsPanel * 
panel)
                        color.green = 0xaa;
                        color.blue = 0xae;
                        color.alpha = 0;
-                       pixmap = 
WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color, 64, 64);
+                       pixmap = 
WMCreateScaledBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color, 
64, 64);
                        if (!pixmap) {
                                WMSetLabelImage(panel->iconLabel, NULL);
                        } else {
-- 
1.8.5.3


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to