Exemplo n.º 1
0
void
float_resizeframe(Frame *f, Rectangle r) {

	if(f->area->view == selview)
		client_resize(f->client, r);
	else
		frame_resize(f, r);
}
Exemplo n.º 2
0
static void
column_resizeframe_h(Frame *f, Rectangle r) {
	Area *a;
	Frame *fn, *fp;
	uint minh;

	minh = labelh(def.font);

	a = f->area;
	fn = f->anext;
	fp = f->aprev;

	if(fp)
		r.min.y = max(r.min.y, fp->colr.min.y + minh);
	else
		r.min.y = max(r.min.y, a->r.min.y);

	if(fn)
		r.max.y = min(r.max.y, fn->colr.max.y - minh);
	else
		r.max.y = min(r.max.y, a->r.max.y);

	if(fp) {
		fp->colr.max.y = r.min.y;
		frame_resize(fp, fp->colr);
	}
	else
		r.min.y = min(r.min.y, r.max.y - minh);

	if(fn) {
		fn->colr.min.y = r.max.y;
		frame_resize(fn, fn->colr);
	}
	else
		r.max.y = max(r.max.y, r.min.y + minh);

	f->colr = r;
	frame_resize(f, r);
}
Exemplo n.º 3
0
static void
column_scale(Area *a) {
	Frame *f;
	uint dy;
	uint ncol, nuncol;
	uint colh;
	int surplus;

	if(!a->frame)
		return;

	column_fit(a, &ncol, &nuncol);

	colh = labelh(def.font);
	if(a->max && !resizing)
		colh = 0;

	dy = 0;
	surplus = Dy(a->r);
	for(f=a->frame; f; f=f->anext) {
		if(f->collapsed)
			f->colr.max.y = f->colr.min.y + colh;
		else if(Dy(f->colr) == 0)
			f->colr.max.y++;
		surplus -= Dy(f->colr);
		if(!f->collapsed)
			dy += Dy(f->colr);
	}
	for(f=a->frame; f; f=f->anext) {
		f->dy = Dy(f->colr);
		f->colr.min.x = a->r.min.x;
		f->colr.max.x = a->r.max.x;
		if(!f->collapsed)
			f->colr.max.y += ((float)f->dy / dy) * surplus;
		if(btassert("6 full", !(f->collapsed ? Dy(f->r) >= 0 : dy > 0)))
			warning("Something's f****d: %s:%d:%s()",
				__FILE__, __LINE__, __func__);
		frame_resize(f, f->colr);
	}

	if(def.incmode == ISqueeze && !resizing)
		column_squeeze(a);
	column_settle(a);
}
Exemplo n.º 4
0
static void
column_fit(Area *a, uint *n_colp, uint *n_uncolp) {
	Frame *f, **fp;
	uint minh, dy;
	uint n_col, n_uncol;
	uint col_h, uncol_h;
	int surplus, i, j;

	/* The minimum heights of collapsed and uncollpsed frames.
	 */
	minh = labelh(def.font);
	col_h = labelh(def.font);
	uncol_h = minh + col_h + 1;
	if(a->max && !resizing)
		col_h = 0;

	/* Count collapsed and uncollapsed frames. */
	n_col = 0;
	n_uncol = 0;
	for(f=a->frame; f; f=f->anext) {
		frame_resize(f, f->colr);
		if(f->collapsed)
			n_col++;
		else
			n_uncol++;
	}

	if(n_uncol == 0) {
		n_uncol++;
		n_col--;
		(a->sel ? a->sel : a->frame)->collapsed = false;
	}

	/* FIXME: Kludge. See frame_attachrect. */
	dy = Dy(a->view->r[a->screen]) - Dy(a->r);
	minh = col_h * (n_col + n_uncol - 1) + uncol_h;
	if(dy && Dy(a->r) < minh)
		a->r.max.y += min(dy, minh - Dy(a->r));

	surplus = Dy(a->r)
		- (n_col * col_h)
		- (n_uncol * uncol_h);

	/* Collapse until there is room */
	if(surplus < 0) {
		i = ceil(-1.F * surplus / (uncol_h - col_h));
		if(i >= n_uncol)
			i = n_uncol - 1;
		n_uncol -= i;
		n_col += i;
		surplus += i * (uncol_h - col_h);
	}
	/* Push to the floating layer until there is room */
	if(surplus < 0) {
		i = ceil(-1.F * surplus / col_h);
		if(i > n_col)
			i = n_col;
		n_col -= i;
		surplus += i * col_h;
	}

	/* Decide which to collapse and which to float. */
	j = n_uncol - 1;
	i = n_col - 1;
	for(fp=&a->frame; *fp;) {
		f = *fp;
		if(f != a->sel) {
			if(!f->collapsed) {
				if(j < 0)
					f->collapsed = true;
				j--;
			}
			if(f->collapsed) {
				if(i < 0) {
					f->collapsed = false;
					area_moveto(f->view->floating, f);
					continue;
				}
				i--;
			}
		}
		/* Doesn't change if we 'continue' */
		fp = &f->anext;
	}

	if(n_colp) *n_colp = n_col;
	if(n_uncolp) *n_uncolp = n_uncol;
}