shading & unshading.... works :)

SVN revision: 3985
This commit is contained in:
Carsten Haitzler 2000-12-13 03:14:18 +00:00
parent a555595aa4
commit 36bfc191e6
3 changed files with 134 additions and 127 deletions

View File

@ -732,30 +732,20 @@ e_act_cb_shade(int val, void *data)
static double t = 0.0; static double t = 0.0;
double dif; double dif;
int si; int si;
int pl, pr, pt, pb; int pix_per_sec = 1600;
int pix_per_sec = 200;
b = data; b = data;
if (b->client.shaded >= 0) if (val == 0) t = e_get_time();
{
t = e_get_time();
b->client.shaded = -1;
}
dif = e_get_time() - t; dif = e_get_time() - t;
pl = pr = pt = pb = 0;
if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
si = val - (int)(dif * (double)pix_per_sec); si = (int)(dif * (double)pix_per_sec);
if (si > b->client.h) si = b->client.h;
if (si <= (pt + pb)) si = pt + pb; b->current.shaded = si;
b->current.requested.h = si;
b->changed = 1; b->changed = 1;
e_border_adjust_limits(b); e_border_adjust_limits(b);
if (si != (pt + pb)) if (si < b->client.h)
e_add_event_timer("e_act_cb_shade()", 0.02, e_act_cb_shade, val, data); e_add_event_timer("shader", 0.01, e_act_cb_shade, 1, data);
else
b->client.shaded = 1;
} }
static void e_act_cb_unshade(int val, void *data); static void e_act_cb_unshade(int val, void *data);
@ -766,30 +756,20 @@ e_act_cb_unshade(int val, void *data)
static double t = 0.0; static double t = 0.0;
double dif; double dif;
int si; int si;
int pl, pr, pt, pb; int pix_per_sec = 1600;
int pix_per_sec = 200;
b = data; b = data;
if (b->client.shaded >= 0) if (val == 0) t = e_get_time();
{
t = e_get_time();
b->client.shaded = -1;
}
dif = e_get_time() - t; dif = e_get_time() - t;
pl = pr = pt = pb = 0;
if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
si = val - (int)(dif * (double)pix_per_sec); si = b->client.h - (int)(dif * (double)pix_per_sec);
if (si < 0) si = 0;
if (si <= (pt + pb)) si = pt + pb; b->current.shaded = si;
b->current.requested.h = si;
b->changed = 1; b->changed = 1;
e_border_adjust_limits(b); e_border_adjust_limits(b);
if (si != (pt + pb)) if (si > 0)
e_add_event_timer("e_act_cb_shade()", 0.02, e_act_cb_shade, val, data); e_add_event_timer("shader", 0.01, e_act_cb_unshade, 1, data);
else
b->client.shaded = 1;
} }
static void static void
@ -798,12 +778,8 @@ e_act_shade_start (void *o, E_Action *a, void *data, int x, int y, int rx, int r
E_Border *b; E_Border *b;
b = o; b = o;
/* in the process of being shaded - abort */ if (b->current.shaded == 0) e_act_cb_shade(0, b);
if (b->client.shaded < 0) return; else e_act_cb_unshade(0, b);
if (b->client.shaded == 0)
e_act_cb_shade(b->client.h, b);
else
e_act_cb_unshade(b->client.h, b);
return; return;
UN(a); UN(a);
UN(data); UN(data);

View File

@ -1458,90 +1458,98 @@ e_border_adjust_limits(E_Border *b)
} }
b->current.w = b->current.requested.w; b->current.w = b->current.requested.w;
b->current.h = b->current.requested.h; b->current.h = b->current.requested.h - b->current.shaded;
pl = pr = pt = pb = 0;
if (b->current.w < 1) b->current.w = 1;
if (b->current.h < 1) b->current.h = 1;
if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
if (b->current.w < (pl + pr + 1)) b->current.w = pl + pr + 1;
if (b->current.h < (pt + pb + 1)) b->current.h = pt + pb + 1;
w = b->current.w - pl - pr; if (!b->current.shaded)
h = b->current.h - pt - pb;
mx = my = 1;
if (b->bits.t) ebits_get_min_size(b->bits.t, &mx, &my);
if (b->current.w < mx) b->current.w = mx;
if (b->current.h < my) b->current.h = my;
mx = my = 999999;
if (b->bits.t) ebits_get_max_size(b->bits.t, &mx, &my);
if (b->current.w > mx) b->current.w = mx;
if (b->current.h > my) b->current.h = my;
if (w < b->client.min.w) w = b->client.min.w;
if (h < b->client.min.h) h = b->client.min.h;
if (w > b->client.max.w) w = b->client.max.w;
if (h > b->client.max.h) h = b->client.max.h;
if ((w > 0) && (h > 0))
{ {
w -= b->client.base.w; if (b->current.w < 1) b->current.w = 1;
h -= b->client.base.h; if (b->current.h < 1) b->current.h = 1;
pl = pr = pt = pb = 0;
if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
if (b->current.w < (pl + pr + 1)) b->current.w = pl + pr + 1;
if (b->current.h < (pt + pb + 1)) b->current.h = pt + pb + 1;
w = b->current.w - pl - pr;
h = b->current.h - pt - pb + b->current.shaded;
mx = my = 1;
if (b->bits.t) ebits_get_min_size(b->bits.t, &mx, &my);
if (b->current.w < mx) b->current.w = mx;
if (b->current.h < my) b->current.h = my;
mx = my = 999999;
if (b->bits.t) ebits_get_max_size(b->bits.t, &mx, &my);
if (b->current.w > mx) b->current.w = mx;
if (b->current.h > my) b->current.h = my;
if (w < b->client.min.w) w = b->client.min.w;
if (h < b->client.min.h) h = b->client.min.h;
if (w > b->client.max.w) w = b->client.max.w;
if (h > b->client.max.h) h = b->client.max.h;
if ((w > 0) && (h > 0)) if ((w > 0) && (h > 0))
{ {
int i, j; w -= b->client.base.w;
double aspect; h -= b->client.base.h;
if ((w > 0) && (h > 0))
aspect = ((double)w) / ((double)h);
if ((b->mode.resize == 4) || (b->mode.resize == 5))
{ {
if (aspect < b->client.min.aspect) int i, j;
h = (int)((double)w / b->client.min.aspect); double aspect;
if (aspect > b->client.max.aspect)
h = (int)((double)w / b->client.max.aspect); aspect = ((double)w) / ((double)h);
if ((b->mode.resize == 4) || (b->mode.resize == 5))
{
if (aspect < b->client.min.aspect)
h = (int)((double)w / b->client.min.aspect);
if (aspect > b->client.max.aspect)
h = (int)((double)w / b->client.max.aspect);
}
else if ((b->mode.resize == 6) || (b->mode.resize == 7))
{
if (aspect < b->client.min.aspect)
w = (int)((double)h * b->client.min.aspect);
if (aspect > b->client.max.aspect)
w = (int)((double)h * b->client.max.aspect);
}
else
{
if (aspect < b->client.min.aspect)
w = (int)((double)h * b->client.min.aspect);
if (aspect > b->client.max.aspect)
h = (int)((double)w / b->client.max.aspect);
}
i = w / b->client.step.w;
j = h / b->client.step.h;
w = i * b->client.step.w;
h = j * b->client.step.h;
} }
else if ((b->mode.resize == 6) || (b->mode.resize == 7)) w += b->client.base.w;
{ h += b->client.base.h;
if (aspect < b->client.min.aspect)
w = (int)((double)h * b->client.min.aspect);
if (aspect > b->client.max.aspect)
w = (int)((double)h * b->client.max.aspect);
}
else
{
if (aspect < b->client.min.aspect)
w = (int)((double)h * b->client.min.aspect);
if (aspect > b->client.max.aspect)
h = (int)((double)w / b->client.max.aspect);
}
i = w / b->client.step.w;
j = h / b->client.step.h;
w = i * b->client.step.w;
h = j * b->client.step.h;
} }
w += b->client.base.w; b->client.w = w;
h += b->client.base.h; b->client.h = h;
b->current.w = w + pl + pr;
b->current.h = h + pt + pb;
} }
b->current.w = w + pl + pr;
b->current.h = h + pt + pb; if (b->current.shaded == 0)
if ((b->mode.resize == 3) || (b->mode.resize == 5) || (b->mode.resize == 7))
{ {
} if ((b->mode.resize == 3) || (b->mode.resize == 5) || (b->mode.resize == 7))
else if ((b->mode.resize == 0) || (b->mode.resize == 4)) {
{ }
b->current.x += (b->current.requested.w - b->current.w); else if ((b->mode.resize == 0) || (b->mode.resize == 4))
b->current.y += (b->current.requested.h - b->current.h); {
} b->current.x += (b->current.requested.w - b->current.w);
else if ((b->mode.resize == 1) || (b->mode.resize == 6)) b->current.y += (b->current.requested.h - b->current.h);
{ }
b->current.y += (b->current.requested.h - b->current.h); else if ((b->mode.resize == 1) || (b->mode.resize == 6))
} {
else if ((b->mode.resize == 2)) b->current.y += (b->current.requested.h - b->current.h);
{ }
b->current.x += (b->current.requested.w - b->current.w); else if ((b->mode.resize == 2))
{
b->current.x += (b->current.requested.w - b->current.w);
}
} }
} }
@ -1595,8 +1603,10 @@ e_border_update(E_Border *b)
pl = pr = pt = pb = 0; pl = pr = pt = pb = 0;
if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
e_icccm_move_resize(b->win.client, e_icccm_move_resize(b->win.client,
b->current.x + pl, b->current.y + pt, b->current.x + pl,
b->current.w - pl - pr, b->current.h - pt - pb); b->current.y + pt,
b->client.w,
b->client.h);
e_cb_border_move_resize(b); e_cb_border_move_resize(b);
} }
else if (size_changed) else if (size_changed)
@ -1609,16 +1619,37 @@ e_border_update(E_Border *b)
smaller = 1; smaller = 1;
pl = pr = pt = pb = 0; pl = pr = pt = pb = 0;
if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
e_window_resize(b->win.client, b->current.w - pl - pr, b->current.h - pt - pb);
e_window_move_resize(b->win.input, e_window_move_resize(b->win.input,
0, 0, b->current.w, b->current.h); 0, 0, b->current.w, b->current.h);
e_window_move_resize(b->win.main, e_window_move_resize(b->win.main,
b->current.x, b->current.y, b->current.x, b->current.y,
b->current.w, b->current.h); b->current.w, b->current.h);
e_window_move_resize(b->win.container, pl, pt, if (b->current.shaded == b->client.h)
b->current.w - pl - pr, b->current.h - pt -pb); {
e_window_move_resize(b->win.client,
0, - b->current.shaded,
b->client.w,
b->client.h);
e_window_move_resize(b->win.container,
b->current.w + 1,
b->current.h + 1,
1,
1);
}
else
{
e_window_move_resize(b->win.client,
0, - b->current.shaded,
b->client.w,
b->client.h);
e_window_move_resize(b->win.container,
pl,
pt,
b->current.w - pl - pr,
b->current.h - pt - pb);
}
x = 0, y = pt, w = pl, h = (b->current.h - pt - pb); x = 0, y = pt, w = pl, h = (b->current.h - pt - pb);
if ((w <1) && (h < 1)) e_window_hide(b->win.l); if ((w <1) || (h < 1)) e_window_hide(b->win.l);
else else
{ {
e_window_show(b->win.l); e_window_show(b->win.l);
@ -1628,7 +1659,7 @@ e_border_update(E_Border *b)
} }
x = 0, y = 0, w = b->current.w, h = pt; x = 0, y = 0, w = b->current.w, h = pt;
if ((w <1) && (h < 1)) e_window_hide(b->win.t); if ((w <1) || (h < 1)) e_window_hide(b->win.t);
else else
{ {
e_window_show(b->win.t); e_window_show(b->win.t);
@ -1638,7 +1669,7 @@ e_border_update(E_Border *b)
} }
x = b->current.w - pr, y = pt, w = pr, h = (b->current.h - pt - pb); x = b->current.w - pr, y = pt, w = pr, h = (b->current.h - pt - pb);
if ((w <1) && (h < 1)) e_window_hide(b->win.r); if ((w <1) || (h < 1)) e_window_hide(b->win.r);
else else
{ {
e_window_show(b->win.r); e_window_show(b->win.r);
@ -1648,7 +1679,7 @@ e_border_update(E_Border *b)
} }
x = 0, y = b->current.h - pb, w = b->current.w, h = pb; x = 0, y = b->current.h - pb, w = b->current.w, h = pb;
if ((w <1) && (h < 1)) e_window_hide(b->win.b); if ((w <1) || (h < 1)) e_window_hide(b->win.b);
else else
{ {
e_window_show(b->win.b); e_window_show(b->win.b);
@ -1663,8 +1694,8 @@ e_border_update(E_Border *b)
if (b->bits.b) ebits_resize(b->bits.b, b->current.w, b->current.h); if (b->bits.b) ebits_resize(b->bits.b, b->current.w, b->current.h);
e_icccm_move_resize(b->win.client, e_icccm_move_resize(b->win.client,
b->current.x + pl, b->current.y + pt, b->current.x + pl, b->current.y + pt - b->current.shaded,
b->current.w - pl - pr, b->current.h - pt - pb); b->client.w, b->client.h);
e_cb_border_move_resize(b); e_cb_border_move_resize(b);
} }
if (visibility_changed) if (visibility_changed)

View File

@ -165,6 +165,7 @@ struct _E_Border
int x, y, w, h; int x, y, w, h;
int visible; int visible;
int selected; int selected;
int shaded;
} current, previous; } current, previous;
struct { struct {
@ -184,7 +185,6 @@ struct _E_Border
Colormap colormap; Colormap colormap;
int fixed; int fixed;
int arrange_ignore; int arrange_ignore;
int shaded;
int hidden; int hidden;
int iconified; int iconified;
int borderless; int borderless;