Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: icons.c icons.h Log Message: Provide iconbox icon fallback if normal methods fail. =================================================================== RCS file: /cvs/e/e16/e/src/icons.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- icons.c 11 Jul 2008 18:49:27 -0000 1.20 +++ icons.c 11 Jul 2008 19:26:46 -0000 1.21 @@ -24,6 +24,7 @@ #include "E.h" #include "eimage.h" #include "ewins.h" +#include "iclass.h" #include "icons.h" #include "windowmatch.h" #include "xwin.h" @@ -66,11 +67,38 @@ return k; } +static void +IB_IconGetSize(int ww, int hh, int size, int scale, int *pw, int *ph) +{ + int w, h; + + w = h = size; + w *= scale; + h *= scale; + + if (ww > hh) + h = (w * hh) / ww; + else + w = (h * ww) / hh; + if (w < 4) + w = 4; + if (h < 4) + h = 4; + if (w > ww || h > hh) + { + w = ww; + h = hh; + } + + *pw = w; + *ph = h; +} + static EImage * IB_SnapEWin(EWin * ewin, int size) { /* Make snapshot of window */ - int w, h, ww, hh, scale; + int w, h, ww, hh; EImage *im; Drawable draw; @@ -86,26 +114,8 @@ EwinInstantUnShade(ewin); EwinRaise(ewin); - w = h = size; - /* Oversample for nicer snapshots */ - scale = 4; - w *= scale; - h *= scale; - - if (ww > hh) - h = (w * hh) / ww; - else - w = (h * ww) / hh; - if (w < 4) - w = 4; - if (h < 4) - h = 4; - if (w > ww || h > hh) - { - w = ww; - h = hh; - } + IB_IconGetSize(ww, hh, size, 4, &w, &h); draw = EoGetPixmap(ewin); if (draw != None) @@ -185,14 +195,42 @@ return im; } +static EImage * +IB_GetFallbackIcon(EWin * ewin, int size) +{ + int w, h, ww, hh; + ImageClass *ic; + EImage *im; + + ww = EoGetW(ewin); + hh = EoGetH(ewin); + if (ww <= 0) + ww = 1; + if (hh <= 0) + hh = 1; + + IB_IconGetSize(ww, hh, size, 1, &w, &h); + + ic = ImageclassFind("ICONBOX_HORIZONTAL", 1); + im = ImageclassGetImageBlended(ic, EoGetWin(ewin), w, h, 0, 0, + STATE_NORMAL, ST_SOLID); + + return im; +} + #define N_MODES 5 -#define N_TYPES 3 +#define N_TYPES 4 static const char ewin_icon_modes[N_MODES][N_TYPES] = { - {EWIN_ICON_TYPE_SNAP, EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG}, - {EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_SNAP}, - {EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_SNAP, EWIN_ICON_TYPE_APP}, - {EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_NONE}, - {EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_NONE}, + {EWIN_ICON_TYPE_SNAP, EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, + EWIN_ICON_TYPE_FB}, + {EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_SNAP, + EWIN_ICON_TYPE_FB}, + {EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_SNAP, EWIN_ICON_TYPE_APP, + EWIN_ICON_TYPE_FB}, + {EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_NONE, + EWIN_ICON_TYPE_NONE}, + {EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_NONE, + EWIN_ICON_TYPE_NONE}, }; EImage * @@ -207,8 +245,6 @@ for (i = 0; i < N_TYPES; i++) { type = ewin_icon_modes[mode][i]; - if (type >= N_TYPES) - continue; switch (type) { @@ -225,6 +261,10 @@ case EWIN_ICON_TYPE_IMG: im = IB_GetEIcon(ewin); + break; + + case EWIN_ICON_TYPE_FB: + im = IB_GetFallbackIcon(ewin, size); break; } if (im) =================================================================== RCS file: /cvs/e/e16/e/src/icons.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- icons.h 23 Mar 2008 11:54:23 -0000 1.6 +++ icons.h 11 Jul 2008 19:26:46 -0000 1.7 @@ -25,13 +25,13 @@ #define _ICONS_H_ #include "eimage.h" +#include "ewins.h" -typedef enum { - EWIN_ICON_TYPE_APP, - EWIN_ICON_TYPE_IMG, - EWIN_ICON_TYPE_SNAP, - EWIN_ICON_TYPE_NONE, -} ewin_icon_e; +#define EWIN_ICON_TYPE_NONE 0 +#define EWIN_ICON_TYPE_APP 1 +#define EWIN_ICON_TYPE_IMG 2 +#define EWIN_ICON_TYPE_SNAP 3 +#define EWIN_ICON_TYPE_FB 4 EImage *EwinIconImageGet(EWin * ewin, int size, int mode); ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs