diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-06 14:50:50 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-06 14:50:50 +0100 |
commit | a0d12784bd6493e9e05c98a66d65837de82f8bda (patch) | |
tree | 830ba06d47e587a454b35b2b5c34e4000cfdbb64 | |
parent | bf2a6f786502026ce4229bc84a6a22e5e55a7c13 (diff) | |
download | plan9front-a0d12784bd6493e9e05c98a66d65837de82f8bda.tar.xz |
rio: give visual clue during sweep and bandsizing when window is too small
We color the window border with a dark red in case the
window is too small.
-rw-r--r-- | sys/src/cmd/rio/dat.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/rio/data.c | 1 | ||||
-rw-r--r-- | sys/src/cmd/rio/rio.c | 50 |
3 files changed, 29 insertions, 23 deletions
diff --git a/sys/src/cmd/rio/dat.h b/sys/src/cmd/rio/dat.h index edc855595..e18c34b49 100644 --- a/sys/src/cmd/rio/dat.h +++ b/sys/src/cmd/rio/dat.h @@ -325,6 +325,7 @@ Image *lightholdcol; Image *paleholdcol; Image *paletextcol; Image *sizecol; +Image *badsizecol; int reverse; /* there are no pastel paints in the dungeons and dragons world -- rob pike */ Window **window; diff --git a/sys/src/cmd/rio/data.c b/sys/src/cmd/rio/data.c index f9b9cfad0..e591255b9 100644 --- a/sys/src/cmd/rio/data.c +++ b/sys/src/cmd/rio/data.c @@ -196,6 +196,7 @@ iconinit(void) paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreyblue); paletextcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse); sizecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DRed); + badsizecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x880000FF); if(reverse == 0) holdcol = dholdcol; diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c index 13c9e29eb..f1af15469 100644 --- a/sys/src/cmd/rio/rio.c +++ b/sys/src/cmd/rio/rio.c @@ -826,7 +826,7 @@ sweep(void) if(i == nil) goto Rescue; oi = i; - border(i, r, Selborder, sizecol, ZP); + border(i, r, Selborder, goodrect(r)?sizecol:badsizecol, ZP); draw(i, insetrect(r, Selborder), cols[BACK], nil, ZP); } } @@ -858,7 +858,7 @@ sweep(void) } void -drawedge(Image **bp, Rectangle r) +drawedge(Image **bp, Image *col, Rectangle r) { Image *b = *bp; if(b != nil && Dx(b->r) == Dx(r) && Dy(b->r) == Dy(r)) @@ -866,28 +866,30 @@ drawedge(Image **bp, Rectangle r) else{ freeimage(b); b = allocwindow(wscreen, r, Refbackup, DNofill); - if(b != nil) draw(b, r, sizecol, nil, ZP); + if(b != nil) draw(b, r, col, nil, ZP); *bp = b; } } void -drawborder(Rectangle r, int show) +drawborder(Rectangle r, Image *col) { - static Image *b[4]; - int i; - if(show == 0){ - for(i = 0; i < 4; i++){ - freeimage(b[i]); - b[i] = nil; - } - }else{ + static Image *b[4], *lastcol; + + if(col != lastcol){ + freeimage(b[0]), b[0] = nil; + freeimage(b[1]), b[1] = nil; + freeimage(b[2]), b[2] = nil; + freeimage(b[3]), b[3] = nil; + } + if(col != nil){ r = canonrect(r); - drawedge(&b[0], Rect(r.min.x, r.min.y, r.min.x+Borderwidth, r.max.y)); - drawedge(&b[1], Rect(r.min.x+Borderwidth, r.min.y, r.max.x-Borderwidth, r.min.y+Borderwidth)); - drawedge(&b[2], Rect(r.max.x-Borderwidth, r.min.y, r.max.x, r.max.y)); - drawedge(&b[3], Rect(r.min.x+Borderwidth, r.max.y-Borderwidth, r.max.x-Borderwidth, r.max.y)); + drawedge(&b[0], col, Rect(r.min.x, r.min.y, r.min.x+Borderwidth, r.max.y)); + drawedge(&b[1], col, Rect(r.min.x+Borderwidth, r.min.y, r.max.x-Borderwidth, r.min.y+Borderwidth)); + drawedge(&b[2], col, Rect(r.max.x-Borderwidth, r.min.y, r.max.x, r.max.y)); + drawedge(&b[3], col, Rect(r.min.x+Borderwidth, r.max.y-Borderwidth, r.max.x-Borderwidth, r.max.y)); } + lastcol = col; } Image* @@ -902,17 +904,17 @@ drag(Window *w) dm = subpt(om, w->screenr.min); d = subpt(w->screenr.max, w->screenr.min); op = subpt(om, dm); - drawborder(Rect(op.x, op.y, op.x+d.x, op.y+d.y), 1); + drawborder(Rect(op.x, op.y, op.x+d.x, op.y+d.y), sizecol); while(mouse->buttons==4){ p = subpt(mouse->xy, dm); if(!eqpt(p, op)){ - drawborder(Rect(p.x, p.y, p.x+d.x, p.y+d.y), 1); + drawborder(Rect(p.x, p.y, p.x+d.x, p.y+d.y), sizecol); op = p; } readmouse(mousectl); } r = Rect(op.x, op.y, op.x+d.x, op.y+d.y); - drawborder(r, 0); + drawborder(r, nil); p = mouse->xy; riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil); menuing = FALSE; @@ -936,7 +938,7 @@ bandsize(Window *w) or = w->screenr; but = mouse->buttons; startp = onscreen(mouse->xy); - drawborder(or, 1); + drawborder(or, sizecol); while(mouse->buttons == but) { p = onscreen(mouse->xy); which = whichcorner(or, p); @@ -945,13 +947,15 @@ bandsize(Window *w) riosetcursor(corners[which]); } r = whichrect(or, p, owhich); - if(!eqrect(r, or) && goodrect(r)){ + if(!eqrect(r, or)){ + drawborder(r, goodrect(r)?sizecol:badsizecol); or = r; - drawborder(r, 1); } readmouse(mousectl); } - drawborder(or, 0); + drawborder(or, nil); + if(!goodrect(or)) + riosetcursor(nil); if(mouse->buttons!=0 || !goodrect(or) || eqrect(or, w->screenr) || abs(p.x-startp.x)+abs(p.y-startp.y) <= 1){ flushimage(display, 1); |