mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
samterm: retina scaling for scroll bars, borders
R=rsc http://codereview.appspot.com/6844083
This commit is contained in:
parent
a8a0a6422c
commit
c28224992a
3 changed files with 24 additions and 14 deletions
|
@ -65,9 +65,9 @@ flrect(Flayer *l, Rectangle r)
|
|||
{
|
||||
rectclip(&r, lDrect);
|
||||
l->entire = r;
|
||||
l->scroll = insetrect(r, FLMARGIN);
|
||||
l->scroll = insetrect(r, FLMARGIN(l));
|
||||
r.min.x =
|
||||
l->scroll.max.x = r.min.x+FLMARGIN+FLSCROLLWID+(FLGAP-FLMARGIN);
|
||||
l->scroll.max.x = r.min.x+FLMARGIN(l)+FLSCROLLWID(l)+(FLGAP(l)-FLMARGIN(l));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,8 @@ flinit(Flayer *l, Rectangle r, Font *ft, Image **cols)
|
|||
llinsert(l);
|
||||
l->visible = All;
|
||||
l->origin = l->p0 = l->p1 = 0;
|
||||
frinit(&l->f, insetrect(flrect(l, r), FLMARGIN), ft, screen, cols);
|
||||
l->f.display = display; // for FLMARGIN
|
||||
frinit(&l->f, insetrect(flrect(l, r), FLMARGIN(l)), ft, screen, cols);
|
||||
l->f.maxtab = maxtab*stringwidth(ft, "0");
|
||||
newvisibilities(1);
|
||||
draw(screen, l->entire, l->f.cols[BACK], nil, ZP);
|
||||
|
@ -111,8 +112,8 @@ void
|
|||
flborder(Flayer *l, int wide)
|
||||
{
|
||||
if(flprepare(l)){
|
||||
border(l->f.b, l->entire, FLMARGIN, l->f.cols[BACK], ZP);
|
||||
border(l->f.b, l->entire, wide? FLMARGIN : 1, l->f.cols[BORD], ZP);
|
||||
border(l->f.b, l->entire, FLMARGIN(l), l->f.cols[BACK], ZP);
|
||||
border(l->f.b, l->entire, wide? FLMARGIN(l) : 1, l->f.cols[BORD], ZP);
|
||||
if(l->visible==Some)
|
||||
flrefresh(l, l->entire, 0);
|
||||
}
|
||||
|
@ -392,13 +393,13 @@ flresize(Rectangle dr)
|
|||
r.min.x = dr.min.x;
|
||||
if(r.max.x-r.min.x<100)
|
||||
r.max.x = dr.max.x;
|
||||
if(r.max.y-r.min.y<2*FLMARGIN+f->font->height)
|
||||
if(r.max.y-r.min.y<2*FLMARGIN(l)+f->font->height)
|
||||
r.min.y = dr.min.y;
|
||||
if(r.max.y-r.min.y<2*FLMARGIN+f->font->height)
|
||||
if(r.max.y-r.min.y<2*FLMARGIN(l)+f->font->height)
|
||||
r.max.y = dr.max.y;
|
||||
if(!move)
|
||||
l->visible = None;
|
||||
frsetrects(f, insetrect(flrect(l, r), FLMARGIN), f->b);
|
||||
frsetrects(f, insetrect(flrect(l, r), FLMARGIN(l)), f->b);
|
||||
if(!move && f->b)
|
||||
scrdraw(l, scrtotal(l));
|
||||
}
|
||||
|
@ -422,7 +423,7 @@ flprepare(Flayer *l)
|
|||
else if((f->b = allocimage(display, l->entire, screen->chan, 0, 0))==0)
|
||||
return 0;
|
||||
draw(f->b, l->entire, f->cols[BACK], nil, ZP);
|
||||
border(f->b, l->entire, l==llist[0]? FLMARGIN : 1, f->cols[BORD], ZP);
|
||||
border(f->b, l->entire, l==llist[0]? FLMARGIN(l) : 1, f->cols[BORD], ZP);
|
||||
n = f->nchars;
|
||||
frinit(f, f->entire, f->font, f->b, 0);
|
||||
f->maxtab = maxtab*stringwidth(f->font, "0");
|
||||
|
@ -496,3 +497,11 @@ flrefresh(Flayer *l, Rectangle r, int i)
|
|||
someinvis = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
flscale(Flayer *l, int n)
|
||||
{
|
||||
if(l == nil)
|
||||
return n;
|
||||
return scalesize(l->f.display, n);
|
||||
}
|
||||
|
|
|
@ -41,10 +41,11 @@ void flsetselect(Flayer*, long, long);
|
|||
void flstart(Rectangle);
|
||||
void flupfront(Flayer*);
|
||||
Flayer *flwhich(Point);
|
||||
int flscale(Flayer*, int);
|
||||
|
||||
#define FLMARGIN 4
|
||||
#define FLSCROLLWID 12
|
||||
#define FLGAP 4
|
||||
#define FLMARGIN(l) flscale(l, 4)
|
||||
#define FLSCROLLWID(l) flscale(l, 12)
|
||||
#define FLGAP(l) flscale(l, 4)
|
||||
|
||||
extern Image *maincols[NCOL];
|
||||
extern Image *cmdcols[NCOL];
|
||||
|
|
|
@ -107,7 +107,7 @@ scroll(Flayer *l, int but)
|
|||
long p0;
|
||||
|
||||
s = l->scroll;
|
||||
x = s.min.x+FLSCROLLWID/2;
|
||||
x = s.min.x+FLSCROLLWID(l)/2;
|
||||
scr = scrpos(l->scroll, l->origin, l->origin+l->f.nchars, tot);
|
||||
r = scr;
|
||||
y = scr.min.y;
|
||||
|
@ -115,7 +115,7 @@ scroll(Flayer *l, int but)
|
|||
draw(scrback, Rect(0,0,Dx(l->scroll), Dy(l->scroll)), l->f.b, nil, l->scroll.min);
|
||||
do{
|
||||
oin = in;
|
||||
in = abs(x-mousep->xy.x)<=FLSCROLLWID/2;
|
||||
in = abs(x-mousep->xy.x)<=FLSCROLLWID(l)/2;
|
||||
if(oin && !in)
|
||||
scrunmark(l, r);
|
||||
if(in){
|
||||
|
|
Loading…
Reference in a new issue