static void mouse_resizecolframe(Frame *f, Align align) { Window *cwin, *hwin = nil; Divide *d; View *v; Area *a; Rectangle r; Point pt, min; int s; assert((align&(East|West)) != (East|West)); assert((align&(North|South)) != (North|South)); f->collapsed = false; v = selview; d = divs; SET(a); foreach_column(v, s, a) { if(a == f->area) break; d = d->next; } if(align & East) d = d->next; min.x = column_minwidth(); min.y = /*frame_delta_h() +*/ labelh(def.font); /* Set the limits of where this box may be dragged. */ #define frob(pred, f, aprev, rmin, rmax, plus, minus, xy, use_screen) BLOCK( \ if(pred) { \ r.rmin.xy = f->aprev->r.rmin.xy plus min.xy; \ r.rmax.xy = f->r.rmax.xy minus min.xy; \ }else if(use_screen) { \ r.rmin.xy = v->r[f->screen].rmin.xy plus 1; \ r.rmax.xy = a->r.rmax.xy minus min.xy; \ }else { \ r.rmin.xy = a->r.rmin.xy; \ r.rmax.xy = r.rmin.xy plus 1; \ }) r = f->r; if(align & North) frob(f->aprev, f, aprev, min, max, +, -, y, false); else if(align & South)
void column_resizeframe(Frame *f, Rectangle r) { Area *a, *al, *ar; View *v; uint minw; a = f->area; v = a->view; minw = column_minwidth(); al = a->prev; ar = a->next; if(al) r.min.x = max(r.min.x, al->r.min.x + minw); else { /* Hm... */ r.min.x = max(r.min.x, v->r[a->screen].min.x); r.max.x = max(r.max.x, r.min.x + minw); } if(ar) r.max.x = min(r.max.x, ar->r.max.x - minw); else { r.max.x = min(r.max.x, v->r[a->screen].max.x); r.min.x = min(r.min.x, r.max.x - minw); } a->r.min.x = r.min.x; a->r.max.x = r.max.x; if(al) { al->r.max.x = a->r.min.x; column_arrange(al, false); } if(ar) { ar->r.min.x = a->r.max.x; column_arrange(ar, false); } column_resizeframe_h(f, r); view_update(v); }
Area* area_create(View *v, Area *pos, int scrn, uint width) { static ushort id = 1; int i, j; uint minwidth, index; int numcols; Area *a; assert(!pos || pos->screen == scrn); SET(index); if(v->areas) { /* Creating a column. */ minwidth = column_minwidth(); index = pos ? area_idx(pos) : 1; numcols = 0; for(a=v->areas[scrn]; a; a=a->next) numcols++; /* TODO: Need a better sizing/placing algorithm. */ if(width == 0) { if(numcols >= 0) { width = view_newcolwidth(v, index); if (width == 0) width = Dx(v->r[scrn]) / (numcols + 1); } else width = Dx(v->r[scrn]); } if(width < minwidth) width = minwidth; minwidth = numcols * minwidth + minwidth; if(minwidth > Dx(v->r[scrn])) return nil; i = minwidth - Dx(v->pad[scrn]) - Dx(v->r[scrn]); if(i > 0 && Dx(v->pad[scrn])) { j = min(i/2, v->pad[scrn].min.x); v->pad[scrn].min.x -= j; v->pad[scrn].max.x += i - j; } view_scale(v, scrn, Dx(v->r[scrn]) - width); } a = emallocz(sizeof *a); a->view = v; a->screen = scrn; a->id = id++; a->floating = !v->floating; if(a->floating) a->mode = Coldefault; else a->mode = def.colmode; a->frame = nil; a->sel = nil; a->r = v->r[scrn]; a->r.min.x = 0; a->r.max.x = width; if(a->floating) { v->floating = a; a->screen = -1; } else if(pos) { a->next = pos->next; a->prev = pos; } else { a->next = v->areas[scrn]; v->areas[scrn] = a; } if(a->prev) a->prev->next = a; if(a->next) a->next->prev = a; if(v->sel == nil && !a->floating) area_focus(a); if(!a->floating) event("CreateColumn %ud\n", index); return a; }