mothra: make scrollbar style consistent with other applications

Scrollbar was drawn using a wide dark gutter over a white background
	whereas other applications (window, sam, ...) use a thinner scrollbar with an
	inverse colorscheme.
	This makes the scrollbar more consistent with other 9front applications.
This commit is contained in:
phil9 2022-04-06 16:46:58 +00:00 committed by xfnw
parent cc9d153723
commit 4148ebcf0e
3 changed files with 21 additions and 9 deletions

View file

@ -13,12 +13,13 @@
#define CKWID 1 /* width of frame around check mark */
#define CKINSET 1 /* space around check mark frame */
#define CKBORDER 2 /* space around X inside frame */
static Image *pl_light, *pl_dark, *pl_tick, *pl_hilit;
static Image *pl_light, *pl_dark, *pl_scrl, *pl_tick, *pl_hilit;
Image *pl_blue, *pl_white, *pl_black;
int pl_drawinit(void){
pl_white=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0xFFFFFFFF);
pl_light=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0xFFFFFFFF);
pl_dark=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF);
pl_scrl=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x999999FF);
pl_black=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x000000FF);
pl_hilit=allocimage(display, Rect(0,0,1,1), CHAN1(CAlpha,8), 1, 0x80);
pl_blue=allocimage(display, Rect(0,0,1,1), RGB24, 1, 0x0000FFFF);
@ -28,7 +29,7 @@ int pl_drawinit(void){
draw(pl_tick, Rect(0, 0, TICKW, TICKW), pl_black, nil, ZP);
draw(pl_tick, Rect(0, font->height-TICKW, TICKW, font->height), pl_black, nil, ZP);
}
if(pl_white==0 || pl_light==0 || pl_black==0 || pl_dark==0 || pl_blue==0 || pl_tick==0) sysfatal("allocimage: %r");
if(pl_white==0 || pl_light==0 || pl_black==0 || pl_dark==0 || pl_scrl==0 || pl_blue==0 || pl_tick==0) sysfatal("allocimage: %r");
return 1;
}
Rectangle pl_boxoutline(Image *b, Rectangle r, int style, int fill){
@ -206,6 +207,19 @@ void pl_sliderupd(Image *b, Rectangle r1, int dir, int lo, int hi){
draw(b, r2, pl_dark, 0, ZP);
draw(b, r3, pl_light, 0, ZP);
}
void pl_scrollupd(Image *b, Rectangle r, int lo, int hi)
{
Rectangle sr;
if(lo<0) lo=0;
if(hi<=lo) hi=lo+1;
sr=r;
sr.min.y+=lo;
sr.max.x-=1;
sr.max.y=sr.min.y+hi;
if(sr.max.y>r.max.y) sr.max.y=r.max.y;
draw(b, r, pl_scrl, 0, ZP);
draw(b, sr, pl_light, 0, ZP);
}
void pl_draw1(Panel *p, Image *b);
void pl_drawall(Panel *p, Image *b){
if(p->flags&INVIS || p->flags&IGNORE) return;

View file

@ -68,6 +68,7 @@ Rectangle pl_check(Image *, Rectangle, int);
Rectangle pl_radio(Image *, Rectangle, int);
int pl_ckwid(void);
void pl_sliderupd(Image *, Rectangle, int, int, int);
void pl_scrollupd(Image *, Rectangle, int, int);
void pl_invis(Panel *, int);
Point pl_iconsize(int, Icon *);
void pl_highlight(Image *, Rectangle);

View file

@ -12,12 +12,12 @@ struct Scrollbar{
Rectangle interior;
Point minsize;
};
#define SBWID 15 /* should come from draw.c? */
#define SBWID 8 /* should come from draw.c? */
void pl_drawscrollbar(Panel *p){
Scrollbar *sp;
sp=p->data;
sp->interior=pl_outline(p->b, p->r, SUP); /* SUP was p->state */
pl_sliderupd(p->b, sp->interior, sp->dir, sp->lo, sp->hi);
pl_scrollupd(p->b, sp->interior, sp->lo, sp->hi);
}
int pl_hitscrollbar(Panel *g, Mouse *m){
int oldstate, pos, len, dy;
@ -49,8 +49,7 @@ int pl_hitscrollbar(Panel *g, Mouse *m){
switch(m->buttons){
case 1:
dy=pos*(sp->hi-sp->lo)/len;
pl_sliderupd(g->b, sp->interior, sp->dir, sp->lo-dy,
sp->hi-dy);
pl_scrollupd(g->b, sp->interior, sp->lo-dy, sp->hi-dy);
break;
case 2:
if(g->scrollee && g->scrollee->scroll)
@ -59,8 +58,7 @@ int pl_hitscrollbar(Panel *g, Mouse *m){
break;
case 4:
dy=pos*(sp->hi-sp->lo)/len;
pl_sliderupd(g->b, sp->interior, sp->dir, sp->lo+dy,
sp->hi+dy);
pl_scrollupd(g->b, sp->interior, sp->lo+dy, sp->hi+dy);
break;
}
}
@ -94,7 +92,6 @@ void pl_setscrollbarscrollbar(Panel *p, int lo, int hi, int len){
sp=p->data;
ul=p->r.min;
size=subpt(p->r.max, p->r.min);
pl_interior(p->state, &ul, &size);
mylen=sp->dir==HORIZ?size.x:size.y;
if(len==0) len=1;
sp->lo=lo*mylen/len;