vertical scaling in 'equal' mode (will be called 'default' soon) for columns

This commit is contained in:
Anselm R. Garbe 2006-04-06 17:03:12 +02:00
parent 40a69dddaf
commit c94aff285c
6 changed files with 42 additions and 30 deletions

View File

@ -136,11 +136,12 @@ void
attach_toarea(Area *a, Client *c)
{
static unsigned short id = 1;
unsigned int aidx = area2index(a);
Frame *f;
if(clientofview(a->view, c))
return;
c->floating = !area2index(a); /* set floating flag */
c->floating = !aidx;
f = cext_emallocz(sizeof(Frame));
f->id = id++;
f->area = a;
@ -152,8 +153,11 @@ attach_toarea(Area *a, Client *c)
c->sel = c->frame.size - 1;
cext_vattach(frame2vector(&a->frame),f);
a->sel = a->frame.size - 1;
if(area2index(a)) /* column */
arrange_column(a);
if(aidx) { /* column */
if(a->frame.size > 1)
f->rect.height = a->rect.height / (a->frame.size - 1);
arrange_column(a, False);
}
else /* floating */
resize_client(c, &f->rect, False);
}
@ -181,7 +185,7 @@ detach_fromarea(Area *a, Client *c)
i = area2index(a);
if(i && a->frame.size)
arrange_column(a);
arrange_column(a, False);
else {
if(i) {
if(v->area.size > 2)
@ -302,33 +306,39 @@ relax_area(Area *a)
}
void
arrange_column(Area *a)
arrange_column(Area *a, Bool dirty)
{
unsigned int i, yoff, h;
unsigned int i, yoff = a->rect.y, h, dy = 0;
float scale = 1.0;
if(!a->frame.size)
return;
switch(a->mode) {
case Colequal:
h = a->rect.height;
h /= a->frame.size;
if(h < 2 * bar_height())
h = a->rect.height / a->frame.size;
if(h < (2 * bar_height()))
goto Fallthrough;
if(dirty) {
for(i = 0; i < a->frame.size; i++)
a->frame.data[i]->rect.height = h;
}
for(i = 0; i < a->frame.size; i++)
dy += a->frame.data[i]->rect.height;
scale = (float)a->rect.height / (float)dy;
for(i = 0; i < a->frame.size; i++) {
Frame *f = a->frame.data[i];
f->rect = a->rect;
f->rect.y += i * h;
if(i + 1 < a->frame.size)
f->rect.height = h;
else
f->rect.height =
a->rect.height - f->rect.y + a->rect.y;
f->rect.x = a->rect.x;
f->rect.y = yoff;
f->rect.width = a->rect.width;
f->rect.height *= scale;
if(i == a->frame.size - 1)
f->rect.height = a->rect.height - f->rect.y + a->rect.y;
yoff += f->rect.height;
resize_client(f->client, &f->rect, True);
}
break;
case Colstack:
yoff = a->rect.y;
h = a->rect.height - (a->frame.size - 1) * bar_height();
if(h < 3 * bar_height())
goto Fallthrough;
@ -501,7 +511,7 @@ drop_moving(Frame *f, XRectangle *new, XPoint * pt)
Frame *tmp = src->frame.data[j];
src->frame.data[j] = src->frame.data[i];
src->frame.data[i] = tmp;
arrange_column(src);
arrange_column(src, False);
focus_client(f->client);
}
}

View File

@ -85,7 +85,7 @@ update_bar_geometry()
for(j = 1; j < view.data[i]->area.size; j++) {
Area *a = view.data[i]->area.data[j];
a->rect.height = rect.height - brect.height;
arrange_column(a);
arrange_column(a, False);
}
for(j = 0; j < view.data[i]->area.data[0]->frame.size; j++) {
Frame *f = view.data[i]->area.data[0]->frame.data[j];

View File

@ -98,7 +98,7 @@ focus_client(Client *c)
draw_client(c);
XSync(dpy, False);
if(i > 0 && f->area->mode == Colstack)
arrange_column(f->area);
arrange_column(f->area, False);
}
void
@ -522,7 +522,7 @@ Swaparea:
a->frame.data[j]->area = a;
o->frame.data[o->sel] = f;
f->area = o;
arrange_column(o);
arrange_column(o, False);
}
else if(!strncmp(arg, "up", 3) && i) {
if(j)
@ -541,7 +541,7 @@ Swaparea:
a->frame.data[i] = f;
}
if(area2index(a))
arrange_column(a);
arrange_column(a, False);
focus_client(c);
}

View File

@ -532,10 +532,12 @@ type2stat(Stat *stat, char *wname, Qid *dir)
return mkstat(stat, dir, wname, strlen(def.tag), IXP_DMREAD);
break;
case FsFdata:
return mkstat(stat, dir, wname, (dir_i1 == label.size) ? 0 : strlen(label.data[dir_i1]->data), IXP_DMREAD | IXP_DMWRITE);
return mkstat(stat, dir, wname, (dir_i1 == label.size) ? 0 : strlen(label.data[dir_i1]->data),
IXP_DMREAD | IXP_DMWRITE);
break;
case FsFmode:
return mkstat(stat, dir, wname, strlen(mode2str(view.data[dir_i1]->area.data[dir_i2]->mode)), IXP_DMREAD | IXP_DMWRITE);
return mkstat(stat, dir, wname, strlen(mode2str(view.data[dir_i1]->area.data[dir_i2]->mode)),
IXP_DMREAD | IXP_DMWRITE);
break;
case FsFcolors:
case FsFselcolors:
@ -1324,7 +1326,7 @@ xwrite(IXPConn *c, Fcall *fcall)
if((i = str2mode(buf)) == -1)
return Ebadvalue;
view.data[i1]->area.data[i2]->mode = i;
arrange_column(view.data[i1]->area.data[i2]);
arrange_column(view.data[i1]->area.data[i2], True);
if(view.data[i1]->area.data[i2]->frame.size == 1) /* little hack to update the taglabel */
draw_client(view.data[i1]->area.data[i2]->frame.data[view.data[i1]->area.data[i2]->sel]->client);
break;

View File

@ -289,7 +289,7 @@ restack_view(View *v)
}
void
arrange_view(View *v, Bool updategeometry)
arrange_view(View *v, Bool dirty)
{
unsigned int i;
unsigned int width;
@ -300,11 +300,11 @@ arrange_view(View *v, Bool updategeometry)
width = rect.width / (v->area.size - 1);
for(i = 1; i < v->area.size; i++) {
Area *a = v->area.data[i];
if(updategeometry) {
if(dirty) {
a->rect.height = rect.height - brect.height;
a->rect.x = (i - 1) * width;
a->rect.width = width;
}
arrange_column(a);
arrange_column(a, False);
}
}

View File

@ -193,7 +193,7 @@ void select_area(Area *a, char *arg);
void send2area(Area *to, Area *from, Client *c);
void attach_toarea(Area *a, Client *c);
void detach_fromarea(Area *a, Client *c);
void arrange_column(Area *a);
void arrange_column(Area *a, Bool dirty);
void resize_area(Client *c, XRectangle *r, XPoint *pt);
int str2mode(char *arg);
char *mode2str(int mode);
@ -272,7 +272,7 @@ void update_tags();
void str2tagvector(TagVector *tv, const char *tags);
/* view.c */
void arrange_view(View *v, Bool updategeometry);
void arrange_view(View *v, Bool dirty);
View *alloc_view(char *name);
void focus_view(View *v);
XRectangle *rectangles(View *v, Bool isfloat, unsigned int *num);