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.
This commit is contained in:
parent
bf2a6f7865
commit
a0d12784bd
3 changed files with 30 additions and 24 deletions
|
@ -325,6 +325,7 @@ Image *lightholdcol;
|
||||||
Image *paleholdcol;
|
Image *paleholdcol;
|
||||||
Image *paletextcol;
|
Image *paletextcol;
|
||||||
Image *sizecol;
|
Image *sizecol;
|
||||||
|
Image *badsizecol;
|
||||||
int reverse; /* there are no pastel paints in the dungeons and dragons world -- rob pike */
|
int reverse; /* there are no pastel paints in the dungeons and dragons world -- rob pike */
|
||||||
|
|
||||||
Window **window;
|
Window **window;
|
||||||
|
|
|
@ -196,6 +196,7 @@ iconinit(void)
|
||||||
paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreyblue);
|
paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreyblue);
|
||||||
paletextcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
|
paletextcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
|
||||||
sizecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DRed);
|
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)
|
if(reverse == 0)
|
||||||
holdcol = dholdcol;
|
holdcol = dholdcol;
|
||||||
|
|
|
@ -826,7 +826,7 @@ sweep(void)
|
||||||
if(i == nil)
|
if(i == nil)
|
||||||
goto Rescue;
|
goto Rescue;
|
||||||
oi = i;
|
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);
|
draw(i, insetrect(r, Selborder), cols[BACK], nil, ZP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -858,7 +858,7 @@ sweep(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawedge(Image **bp, Rectangle r)
|
drawedge(Image **bp, Image *col, Rectangle r)
|
||||||
{
|
{
|
||||||
Image *b = *bp;
|
Image *b = *bp;
|
||||||
if(b != nil && Dx(b->r) == Dx(r) && Dy(b->r) == Dy(r))
|
if(b != nil && Dx(b->r) == Dx(r) && Dy(b->r) == Dy(r))
|
||||||
|
@ -866,28 +866,30 @@ drawedge(Image **bp, Rectangle r)
|
||||||
else{
|
else{
|
||||||
freeimage(b);
|
freeimage(b);
|
||||||
b = allocwindow(wscreen, r, Refbackup, DNofill);
|
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;
|
*bp = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawborder(Rectangle r, int show)
|
drawborder(Rectangle r, Image *col)
|
||||||
{
|
{
|
||||||
static Image *b[4];
|
static Image *b[4], *lastcol;
|
||||||
int i;
|
|
||||||
if(show == 0){
|
if(col != lastcol){
|
||||||
for(i = 0; i < 4; i++){
|
freeimage(b[0]), b[0] = nil;
|
||||||
freeimage(b[i]);
|
freeimage(b[1]), b[1] = nil;
|
||||||
b[i] = nil;
|
freeimage(b[2]), b[2] = nil;
|
||||||
}
|
freeimage(b[3]), b[3] = nil;
|
||||||
}else{
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
if(col != nil){
|
||||||
|
r = canonrect(r);
|
||||||
|
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*
|
Image*
|
||||||
|
@ -902,17 +904,17 @@ drag(Window *w)
|
||||||
dm = subpt(om, w->screenr.min);
|
dm = subpt(om, w->screenr.min);
|
||||||
d = subpt(w->screenr.max, w->screenr.min);
|
d = subpt(w->screenr.max, w->screenr.min);
|
||||||
op = subpt(om, dm);
|
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){
|
while(mouse->buttons==4){
|
||||||
p = subpt(mouse->xy, dm);
|
p = subpt(mouse->xy, dm);
|
||||||
if(!eqpt(p, op)){
|
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;
|
op = p;
|
||||||
}
|
}
|
||||||
readmouse(mousectl);
|
readmouse(mousectl);
|
||||||
}
|
}
|
||||||
r = Rect(op.x, op.y, op.x+d.x, op.y+d.y);
|
r = Rect(op.x, op.y, op.x+d.x, op.y+d.y);
|
||||||
drawborder(r, 0);
|
drawborder(r, nil);
|
||||||
p = mouse->xy;
|
p = mouse->xy;
|
||||||
riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil);
|
riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil);
|
||||||
menuing = FALSE;
|
menuing = FALSE;
|
||||||
|
@ -936,7 +938,7 @@ bandsize(Window *w)
|
||||||
or = w->screenr;
|
or = w->screenr;
|
||||||
but = mouse->buttons;
|
but = mouse->buttons;
|
||||||
startp = onscreen(mouse->xy);
|
startp = onscreen(mouse->xy);
|
||||||
drawborder(or, 1);
|
drawborder(or, sizecol);
|
||||||
while(mouse->buttons == but) {
|
while(mouse->buttons == but) {
|
||||||
p = onscreen(mouse->xy);
|
p = onscreen(mouse->xy);
|
||||||
which = whichcorner(or, p);
|
which = whichcorner(or, p);
|
||||||
|
@ -945,13 +947,15 @@ bandsize(Window *w)
|
||||||
riosetcursor(corners[which]);
|
riosetcursor(corners[which]);
|
||||||
}
|
}
|
||||||
r = whichrect(or, p, owhich);
|
r = whichrect(or, p, owhich);
|
||||||
if(!eqrect(r, or) && goodrect(r)){
|
if(!eqrect(r, or)){
|
||||||
|
drawborder(r, goodrect(r)?sizecol:badsizecol);
|
||||||
or = r;
|
or = r;
|
||||||
drawborder(r, 1);
|
|
||||||
}
|
}
|
||||||
readmouse(mousectl);
|
readmouse(mousectl);
|
||||||
}
|
}
|
||||||
drawborder(or, 0);
|
drawborder(or, nil);
|
||||||
|
if(!goodrect(or))
|
||||||
|
riosetcursor(nil);
|
||||||
if(mouse->buttons!=0 || !goodrect(or) || eqrect(or, w->screenr)
|
if(mouse->buttons!=0 || !goodrect(or) || eqrect(or, w->screenr)
|
||||||
|| abs(p.x-startp.x)+abs(p.y-startp.y) <= 1){
|
|| abs(p.x-startp.x)+abs(p.y-startp.y) <= 1){
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue