Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/src
Modified Files:
container.c container.h iconify.c
Log Message:
Refactor iconbox animation code.
===================================================================
RCS file: /cvs/e/e16/e/src/container.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- container.c 5 Oct 2006 19:04:23 -0000 1.2
+++ container.c 24 Dec 2006 15:00:48 -0000 1.3
@@ -48,6 +48,8 @@
static void ContainerEventArrow2Win(Win win, XEvent * ev, void *prm);
static void ContainerEventIconWin(Win win, XEvent * ev, void *prm);
+ContainerCfg Conf_containers;
+
Ecore_List *container_list = NULL;
static int
@@ -1485,7 +1487,7 @@
static char tmp_ib_scrollbar_hide;
static char tmp_ib_cover_hide;
static int tmp_ib_autoresize_anchor;
-static char tmp_ib_animate;
+static char tmp_ib_anim_mode;
static void
CB_ConfigureContainer(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
@@ -1512,7 +1514,7 @@
ct->scrollbar_hide = tmp_ib_scrollbar_hide;
ct->cover_hide = tmp_ib_cover_hide;
ct->auto_resize_anchor = tmp_ib_autoresize_anchor;
- ct->animate = tmp_ib_animate;
+ ct->anim_mode = tmp_ib_anim_mode;
ContainerReconfigure(ct);
ContainerRedraw(ct);
@@ -1555,7 +1557,7 @@
tmp_ib_scrollbar_hide = ct->scrollbar_hide;
tmp_ib_cover_hide = ct->cover_hide;
tmp_ib_autoresize_anchor = ct->auto_resize_anchor;
- tmp_ib_animate = ct->animate;
+ tmp_ib_anim_mode = ct->anim_mode;
if (tmp_ib_name)
Efree(tmp_ib_name);
tmp_ib_name = Estrdup(ct->name);
@@ -1690,7 +1692,7 @@
di = DialogAddItem(table, DITEM_CHECKBUTTON);
DialogItemSetText(di, _("Animate when iconifying to this Iconbox"));
- DialogItemCheckButtonSetPtr(di, &tmp_ib_animate);
+ DialogItemCheckButtonSetPtr(di, &tmp_ib_anim_mode);
di = DialogAddItem(table, DITEM_SEPARATOR);
@@ -1833,13 +1835,13 @@
if (ct)
ct->cover_hide = (char)atoi(s2);
break;
- case CONFIG_RESIZE_ANCHOR: /* __COVER_HIDE 0-1024 */
+ case CONFIG_RESIZE_ANCHOR: /* __RESIZE_ANCHOR 0-1024 */
if (ct)
ct->auto_resize_anchor = atoi(s2);
break;
- case CONFIG_IB_ANIMATE: /* __COVER_HIDE 0-1024 */
+ case CONFIG_IB_ANIMATE: /* __ICONBOX_ANIMATE [ 0 | 1 | 2 ] */
if (ct)
- ct->animate = (char)atoi(s2);
+ ct->anim_mode = atoi(s2);
break;
default:
Eprintf("Warning: Iconbox configuration, ignoring: %s\n", s);
@@ -1882,7 +1884,7 @@
fprintf(fs, "2009 %i\n", ct->scrollbar_hide);
fprintf(fs, "2010 %i\n", ct->cover_hide);
fprintf(fs, "2011 %i\n", ct->auto_resize_anchor);
- fprintf(fs, "2012 %i\n", ct->animate);
+ fprintf(fs, "2012 %i\n", ct->anim_mode);
fprintf(fs, "1000\n");
}
@@ -2007,15 +2009,14 @@
};
#define N_IPC_FUNCS (sizeof(ContainersIpcArray)/sizeof(IpcItem))
-#if 0
/*
* Configuration items
*/
static const CfgItem ContainersCfgItems[] = {
- CFG_ITEM_BOOL(Conf.iconboxes, enable, 1),
+ CFG_ITEM_INT(Conf_containers, anim_time, 250),
+ CFG_ITEM_INT(Conf_containers, anim_step, 10),
};
#define N_CFG_ITEMS (sizeof(ContainersCfgItems)/sizeof(CfgItem))
-#endif
/*
* Module descriptor
@@ -2024,5 +2025,5 @@
"iconboxes", "ibox",
ContainersSighan,
{N_IPC_FUNCS, ContainersIpcArray},
- {0, NULL}
+ {N_CFG_ITEMS, ContainersCfgItems}
};
===================================================================
RCS file: /cvs/e/e16/e/src/container.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- container.h 28 Aug 2006 22:32:48 -0000 1.1
+++ container.h 24 Dec 2006 15:00:48 -0000 1.2
@@ -30,6 +30,12 @@
typedef struct
{
+ unsigned int anim_time; /* Animation run time (ms) */
+ unsigned int anim_step; /* Animation time step (ms) */
+} ContainerCfg;
+
+typedef struct
+{
void *obj;
int xo, yo, wo, ho; /* Outer */
int xi, yi, wi, hi; /* Inner */
@@ -58,19 +64,19 @@
char *name;
char type;
char orientation;
- char animate;
char scrollbar_side;
char arrow_side;
- char shownames;
char nobg;
int iconsize;
- int icon_mode;
-
char auto_resize;
char draw_icon_base;
char scrollbar_hide;
char cover_hide;
int auto_resize_anchor;
+ /* Iconbox specific */
+ char shownames;
+ int anim_mode;
+ int icon_mode;
/* internally set stuff */
EWin *ewin;
@@ -111,6 +117,8 @@
/* State flags */
char do_update;
};
+
+extern ContainerCfg Conf_containers;
void ContainerRedraw(Container * ct);
===================================================================
RCS file: /cvs/e/e16/e/src/iconify.c,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -3 -r1.219 -r1.220
--- iconify.c 28 Aug 2006 22:32:48 -0000 1.219
+++ iconify.c 24 Dec 2006 15:00:48 -0000 1.220
@@ -40,29 +40,154 @@
/* Silly hack to avoid name clash warning when using -Wshadow */
#define y1 y1_
-#define IB_ANIM_TIME 0.25
+#define IB_ANIM_TIME Conf_containers.anim_time
+#define IB_ANIM_STEP Conf_containers.anim_step
static void
-IB_Animate(char iconify, EWin * from, EWin * to)
+IB_Animate_Sleep(double t0, double a)
{
- double t1, t2, t, i, spd, ii;
- int x, y, x1, y1, x2, y2, x3, y3, x4, y4, w, h, fx, fy, fw,
- fh, dx, dy, dw, dh;
+ double t, dt;
+
+ t = GetTime();
+ dt = t - t0 - a * 1e-3 * IB_ANIM_TIME;
+ dt = 1e-3 * IB_ANIM_STEP - dt;
+ if (dt > 0)
+ usleep((unsigned long)(1e6 * dt));
+}
+
+static void
+IB_Animate_A(char iconify, EWin * ewin, EWin * ibox)
+{
+ EWin *fr, *to;
+ double a, aa, spd, t0;
+ int x, y, x1, y1, x2, y2, x3, y3, x4, y4, w, h;
+ int fx, fy, fw, fh, tx, ty, tw, th;
Window root = VRoot.xwin;
GC gc;
XGCValues gcv;
- Desk *dskf, *dskt;
- if (Mode.wm.startup)
- return;
+ /* Window: Extents, Iconbox: Center */
+ if (iconify)
+ {
+ fr = ewin;
+ to = ibox;
+ fw = EoGetW(fr) + 4;
+ fh = EoGetH(fr) + 4;
+ fx = EoGetX(fr) - 2;
+ fy = EoGetY(fr) - 2;
+ tw = 4;
+ th = 4;
+ tx = EoGetX(to) + EoGetW(to) / 2 - 2;
+ ty = EoGetY(to) + EoGetH(to) / 2 - 2;
+ }
+ else
+ {
+ fr = ibox;
+ to = ewin;
+ fw = 4;
+ fh = 4;
+ fx = EoGetX(fr) + EoGetW(fr) / 2 - 2;
+ fy = EoGetY(fr) + EoGetH(fr) / 2 - 2;
+ tw = EoGetW(to) + 4;
+ th = EoGetH(to) + 4;
+ tx = EoGetX(to) + 2;
+ ty = EoGetY(to) + 2;
+ }
+ fx += EoGetX(EoGetDesk(fr));
+ fy += EoGetY(EoGetDesk(fr));
+ tx += EoGetX(EoGetDesk(to));
+ ty += EoGetY(EoGetDesk(to));
+
+ gcv.subwindow_mode = IncludeInferiors;
+ gcv.function = GXxor;
+ gcv.line_width = 2;
+ gcv.foreground = WhitePixel(disp, VRoot.scr);
+ if (gcv.foreground == 0)
+ gcv.foreground = BlackPixel(disp, VRoot.scr);
+ gc = EXCreateGC(root,
+ GCFunction | GCForeground | GCSubwindowMode | GCLineWidth,
+ &gcv);
- dskf = EoGetDesk(from);
- dskt = EoGetDesk(to);
+ spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;
- EobjsRepaint();
- EGrabServer();
+ t0 = GetTime();
+ for (a = 0.0; a < 1.0; a += spd)
+ {
+ aa = 1.0 - a;
+
+ x = (fx * aa) + (tx * a);
+ y = (fy * aa) + (ty * a);
+ w = (fw * aa) + (tw * a);
+ h = (fh * aa) + (th * a);
+
+ x = (2 * x + w) / 2; /* x middle */
+ y = (2 * y + h) / 2; /* y middle */
+ w /= 2; /* width/2 */
+ h /= 2; /* height/2 */
+
+ x1 = x + w * (1 - .5 * sin(3.14159 + a * 6.2831853072));
+ y1 = y + h * cos(a * 6.2831853072);
+ x2 = x + w * (1 - .5 * sin(a * 6.2831853072));
+ y2 = y - h * cos(a * 6.2831853072);
+ x3 = x - w * (1 - .5 * sin(3.14159 + a * 6.2831853072));
+ y3 = y - h * cos(a * 6.2831853072);
+ x4 = x - w * (1 - .5 * sin(a * 6.2831853072));
+ y4 = y + h * cos(a * 6.2831853072);
+
+ XDrawLine(disp, root, gc, x1, y1, x2, y2);
+ XDrawLine(disp, root, gc, x2, y2, x3, y3);
+ XDrawLine(disp, root, gc, x3, y3, x4, y4);
+ XDrawLine(disp, root, gc, x4, y4, x1, y1);
+
+ ESync();
+ IB_Animate_Sleep(t0, a);
+
+ XDrawLine(disp, root, gc, x1, y1, x2, y2);
+ XDrawLine(disp, root, gc, x2, y2, x3, y3);
+ XDrawLine(disp, root, gc, x3, y3, x4, y4);
+ XDrawLine(disp, root, gc, x4, y4, x1, y1);
+ }
+
+ EXFreeGC(gc);
+}
+
+static void
+IB_Animate_B(char iconify, EWin * ewin, EWin * ibox)
+{
+ EWin *fr, *to;
+ double a, spd, t0;
+ int x, y, w, h;
+ int fx, fy, fw, fh, tx, ty, tw, th;
+ Window root = VRoot.xwin;
+ GC gc;
+ XGCValues gcv;
+
+ if (iconify)
+ {
+ fr = ewin;
+ to = ibox;
+ }
+ else
+ {
+ fr = ibox;
+ to = ewin;
+ }
+
+ fx = EoGetX(fr) - 2;
+ fy = EoGetY(fr) - 2;
+ fw = EoGetW(fr) + 3;
+ fh = EoGetH(fr) + 3;
+
+ tx = EoGetX(to) - 2;
+ ty = EoGetY(to) - 2;
+ tw = EoGetW(to) + 3;
+ th = EoGetH(to) + 3;
+
+ fx += EoGetX(EoGetDesk(fr));
+ fy += EoGetY(EoGetDesk(fr));
+ tx += EoGetX(EoGetDesk(to));
+ ty += EoGetY(EoGetDesk(to));
- spd = 0.00001;
gcv.subwindow_mode = IncludeInferiors;
gcv.function = GXxor;
gcv.fill_style = FillOpaqueStippled;
@@ -72,148 +197,67 @@
gc = EXCreateGC(root,
GCFunction | GCForeground | GCSubwindowMode | GCFillStyle,
&gcv);
- t1 = GetTime();
- if (iconify)
- {
- fw = EoGetW(from) + 4;
- fh = EoGetH(from) + 4;
- fx = EoGetX(from) + EoGetX(dskf) - 2;
- fy = EoGetY(from) + EoGetY(dskf) - 2;
- dw = 4;
- dh = 4;
- dx = EoGetX(to) + EoGetX(dskt) + (EoGetW(to) / 2) - 2;
- dy = EoGetY(to) + EoGetY(dskt) + (EoGetH(to) / 2) - 2;
- for (i = 0.0; i < 1.0; i += spd)
- {
- ii = 1.0 - i;
- x = (fx * ii) + (dx * i);
- y = (fy * ii) + (dy * i);
- w = (fw * ii) + (dw * i);
- h = (fh * ii) + (dh * i);
-
- x = (2 * x + w) / 2; /* x middle */
- y = (2 * y + h) / 2; /* y middle */
- w /= 2; /* width/2 */
- h /= 2; /* height/2 */
-
- x1 = x + w * (1 - .5 * sin(3.14159 + i * 6.2831853072));
- y1 = y + h * cos(i * 6.2831853072);
- x2 = x + w * (1 - .5 * sin(i * 6.2831853072));
- y2 = y - h * cos(i * 6.2831853072);
- x3 = x - w * (1 - .5 * sin(3.14159 + i * 6.2831853072));
- y3 = y - h * cos(i * 6.2831853072);
- x4 = x - w * (1 - .5 * sin(i * 6.2831853072));
- y4 = y + h * cos(i * 6.2831853072);
-
- XDrawLine(disp, root, gc, x1, y1, x2, y2);
- XDrawLine(disp, root, gc, x2, y2, x3, y3);
- XDrawLine(disp, root, gc, x3, y3, x4, y4);
- XDrawLine(disp, root, gc, x4, y4, x1, y1);
-
- XDrawLine(disp, root, gc, x1 + 1, y1 + 1, x2 - 1, y2 - 1);
- XDrawLine(disp, root, gc, x2 + 1, y2 + 1, x3 - 1, y3 - 1);
- XDrawLine(disp, root, gc, x3 + 1, y3 + 1, x4 - 1, y4 - 1);
- XDrawLine(disp, root, gc, x4 + 1, y4 + 1, x1 - 1, y1 - 1);
-
- XDrawLine(disp, root, gc, x1 + 2, y1 + 2, x2 - 2, y2 - 2);
- XDrawLine(disp, root, gc, x2 + 2, y2 + 2, x3 - 2, y3 - 2);
- XDrawLine(disp, root, gc, x3 + 2, y3 + 2, x4 - 2, y4 - 2);
- XDrawLine(disp, root, gc, x4 + 2, y4 + 2, x1 - 2, y1 - 2);
-
- ESync();
- t2 = GetTime();
- t = t2 - t1;
- t1 = t2;
- spd = t / IB_ANIM_TIME;
-
- XDrawLine(disp, root, gc, x1, y1, x2, y2);
- XDrawLine(disp, root, gc, x2, y2, x3, y3);
- XDrawLine(disp, root, gc, x3, y3, x4, y4);
- XDrawLine(disp, root, gc, x4, y4, x1, y1);
-
- XDrawLine(disp, root, gc, x1 + 1, y1 + 1, x2 - 1, y2 - 1);
- XDrawLine(disp, root, gc, x2 + 1, y2 + 1, x3 - 1, y3 - 1);
- XDrawLine(disp, root, gc, x3 + 1, y3 + 1, x4 - 1, y4 - 1);
- XDrawLine(disp, root, gc, x4 + 1, y4 + 1, x1 - 1, y1 - 1);
-
- XDrawLine(disp, root, gc, x1 + 2, y1 + 2, x2 - 2, y2 - 2);
- XDrawLine(disp, root, gc, x2 + 2, y2 + 2, x3 - 2, y3 - 2);
- XDrawLine(disp, root, gc, x3 + 2, y3 + 2, x4 - 2, y4 - 2);
- XDrawLine(disp, root, gc, x4 + 2, y4 + 2, x1 - 2, y1 - 2);
- }
- }
- else
+ XDrawLine(disp, root, gc, fx, fy, tx, ty);
+ XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
+ XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
+ XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
+ XDrawRectangle(disp, root, gc, tx, ty, tw, th);
+ XDrawRectangle(disp, root, gc, fx, fy, fw, fh);
+
+ spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;
+
+ t0 = GetTime();
+ for (a = 0.0; a < 1.0; a += spd)
{
- fw = EoGetW(from) + 4;
- fh = EoGetH(from) + 4;
- fx = EoGetX(from) + EoGetX(dskf) - 2;
- fy = EoGetY(from) + EoGetY(dskf) - 2;
- dw = 4;
- dh = 4;
- dx = EoGetX(to) + EoGetX(dskt) + (EoGetW(to) / 2) - 2;
- dy = EoGetY(to) + EoGetY(dskt) + (EoGetH(to) / 2) - 2;
- for (i = 1.0; i >= 0.0; i -= spd)
- {
- ii = 1.0 - i;
+ x = fx + a * (tx - fx);
+ w = fw + a * (tw - fw);
+ y = fy + a * (ty - fy);
+ h = fh + a * (th - fh);
+ XDrawRectangle(disp, root, gc, x, y, w, h);
- x = (fx * ii) + (dx * i);
- y = (fy * ii) + (dy * i);
- w = (fw * ii) + (dw * i);
- h = (fh * ii) + (dh * i);
-
- x = (2 * x + w) / 2; /* x middle */
- y = (2 * y + h) / 2; /* y middle */
- w /= 2; /* width/2 */
- h /= 2; /* height/2 */
-
- x1 = x + w * (1 - .5 * sin(3.14159 + i * 6.2831853072));
- y1 = y + h * cos(i * 6.2831853072);
- x2 = x + w * (1 - .5 * sin(i * 6.2831853072));
- y2 = y - h * cos(i * 6.2831853072);
- x3 = x - w * (1 - .5 * sin(3.14159 + i * 6.2831853072));
- y3 = y - h * cos(i * 6.2831853072);
- x4 = x - w * (1 - .5 * sin(i * 6.2831853072));
- y4 = y + h * cos(i * 6.2831853072);
-
- XDrawLine(disp, root, gc, x1, y1, x2, y2);
- XDrawLine(disp, root, gc, x2, y2, x3, y3);
- XDrawLine(disp, root, gc, x3, y3, x4, y4);
- XDrawLine(disp, root, gc, x4, y4, x1, y1);
-
- XDrawLine(disp, root, gc, x1 + 1, y1 + 1, x2 - 1, y2 - 1);
- XDrawLine(disp, root, gc, x2 + 1, y2 + 1, x3 - 1, y3 - 1);
- XDrawLine(disp, root, gc, x3 + 1, y3 + 1, x4 - 1, y4 - 1);
- XDrawLine(disp, root, gc, x4 + 1, y4 + 1, x1 - 1, y1 - 1);
-
- XDrawLine(disp, root, gc, x1 + 2, y1 + 2, x2 - 2, y2 - 2);
- XDrawLine(disp, root, gc, x2 + 2, y2 + 2, x3 - 2, y3 - 2);
- XDrawLine(disp, root, gc, x3 + 2, y3 + 2, x4 - 2, y4 - 2);
- XDrawLine(disp, root, gc, x4 + 2, y4 + 2, x1 - 2, y1 - 2);
-
- ESync();
- t2 = GetTime();
- t = t2 - t1;
- t1 = t2;
- spd = t / IB_ANIM_TIME;
-
- XDrawLine(disp, root, gc, x1, y1, x2, y2);
- XDrawLine(disp, root, gc, x2, y2, x3, y3);
- XDrawLine(disp, root, gc, x3, y3, x4, y4);
- XDrawLine(disp, root, gc, x4, y4, x1, y1);
-
- XDrawLine(disp, root, gc, x1 + 1, y1 + 1, x2 - 1, y2 - 1);
- XDrawLine(disp, root, gc, x2 + 1, y2 + 1, x3 - 1, y3 - 1);
- XDrawLine(disp, root, gc, x3 + 1, y3 + 1, x4 - 1, y4 - 1);
- XDrawLine(disp, root, gc, x4 + 1, y4 + 1, x1 - 1, y1 - 1);
-
- XDrawLine(disp, root, gc, x1 + 2, y1 + 2, x2 - 2, y2 - 2);
- XDrawLine(disp, root, gc, x2 + 2, y2 + 2, x3 - 2, y3 - 2);
- XDrawLine(disp, root, gc, x3 + 2, y3 + 2, x4 - 2, y4 - 2);
- XDrawLine(disp, root, gc, x4 + 2, y4 + 2, x1 - 2, y1 - 2);
- }
+ ESync();
+ IB_Animate_Sleep(t0, a);
+
+ XDrawRectangle(disp, root, gc, x, y, w, h);
}
+
+ XDrawLine(disp, root, gc, fx, fy, tx, ty);
+ XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
+ XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
+ XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
+ XDrawRectangle(disp, root, gc, tx, ty, tw, th);
+ XDrawRectangle(disp, root, gc, fx, fy, fw, fh);
+
EXFreeGC(gc);
+}
+
+static void
+IB_Animate(Container * ct, int iconify, EWin * ewin)
+{
+ if (Mode.wm.startup || ct->anim_mode <= 0)
+ return;
+
+ if (Conf_containers.anim_time < 10 || Conf_containers.anim_time > 10000)
+ Conf_containers.anim_time = 250;
+ if (Conf_containers.anim_step < 1 || Conf_containers.anim_step > 1000)
+ Conf_containers.anim_step = 10;
+
+ EobjsRepaint();
+ EGrabServer();
+
+ switch (ct->anim_mode)
+ {
+ default:
+ break;
+ case 1:
+ IB_Animate_A(iconify, ewin, ct->ewin);
+ break;
+ case 2:
+ IB_Animate_B(iconify, ewin, ct->ewin);
+ break;
+ }
+
EUngrabServer();
}
@@ -264,8 +308,8 @@
IconboxObjEwinAdd(ct, ewin);
- if (ct->animate && !ewin->state.showingdesk)
- IB_Animate(1, ewin, ct->ewin);
+ if (ct->anim_mode && !ewin->state.showingdesk)
+ IB_Animate(ct, 1, ewin);
}
static void
@@ -279,8 +323,8 @@
if (!ct)
return;
- if (ct->animate && !ewin->state.showingdesk)
- IB_Animate(0, ewin, ct->ewin);
+ if (ct->anim_mode && !ewin->state.showingdesk)
+ IB_Animate(ct, 0, ewin);
IconboxObjEwinDel(ct, ewin);
ContainerRedraw(ct);
@@ -428,7 +472,7 @@
ct->menu_title = _("Iconbox Options");
ct->dlg_title = _("Iconbox Settings");
ct->iconsize = 48;
- ct->animate = 1;
+ ct->anim_mode = 1;
}
static void
|