From: Christophe CURIS <christophe.cu...@free.fr> In order to keep compatibility for the WINGs public API:
- created a new function instead of changing the parameters of the legacy function as done in commit 0c3b76a0c92beb3891891dbfd23d3b34dee4bd05; - restore use of legacy function WMCreateBlendedPixmapFromFile where the new function is not needed; - 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 ++++++++++++------ WPrefs.app/MouseSettings.c | 2 +- WPrefs.app/WPrefs.c | 4 ++-- src/dialog.c | 8 +++++--- src/dockedapp.c | 2 +- 6 files changed, 27 insertions(+), 14 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/WPrefs.app/MouseSettings.c b/WPrefs.app/MouseSettings.c index b2f685e..31d467d 100644 --- a/WPrefs.app/MouseSettings.c +++ b/WPrefs.app/MouseSettings.c @@ -446,7 +446,7 @@ static void createPanel(Panel * p) WMSetLabelImagePosition(panel->speedL, WIPImageOnly); path = LocateImage(SPEED_ICON_FILE); if (path) { - icon = WMCreateBlendedPixmapFromFile(scr, path, &color, 0, 0); + icon = WMCreateBlendedPixmapFromFile(scr, path, &color); if (icon) { WMSetLabelImage(panel->speedL, icon); WMReleasePixmap(icon); diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c index b80e099..31192aa 100644 --- a/WPrefs.app/WPrefs.c +++ b/WPrefs.app/WPrefs.c @@ -456,7 +456,7 @@ void SetButtonAlphaImage(WMScreen *scr, WMButton *bPtr, const char *file) color.blue = 0xae; color.alpha = 0; if (iconPath) { - icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color, 0, 0); + icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color); if (!icon) wwarning(_("could not load icon file %s"), iconPath); } else { @@ -470,7 +470,7 @@ void SetButtonAlphaImage(WMScreen *scr, WMButton *bPtr, const char *file) color.blue = 0xff; color.alpha = 0; if (iconPath) { - icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color, 0, 0); + icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color); if (!icon) wwarning(_("could not load icon file %s"), iconPath); } else { 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.9.1 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.