aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/samterm
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2012-11-26 00:23:06 -0500
committerRuss Cox <rsc@swtch.com>2012-11-26 00:23:06 -0500
commitc28224992a8e0093f3629afb747c8a1a876683e3 (patch)
tree82349ae1a20fa8db14e4ea38f5de360edcfac5a1 /src/cmd/samterm
parenta8a0a6422c5af47fad529917835ed1c30cd43936 (diff)
downloadplan9port-c28224992a8e0093f3629afb747c8a1a876683e3.tar.gz
plan9port-c28224992a8e0093f3629afb747c8a1a876683e3.tar.bz2
plan9port-c28224992a8e0093f3629afb747c8a1a876683e3.zip
samterm: retina scaling for scroll bars, borders
R=rsc http://codereview.appspot.com/6844083
Diffstat (limited to 'src/cmd/samterm')
-rw-r--r--src/cmd/samterm/flayer.c27
-rw-r--r--src/cmd/samterm/flayer.h7
-rw-r--r--src/cmd/samterm/scroll.c4
3 files changed, 24 insertions, 14 deletions
diff --git a/src/cmd/samterm/flayer.c b/src/cmd/samterm/flayer.c
index f3707738..e9fde31c 100644
--- a/src/cmd/samterm/flayer.c
+++ b/src/cmd/samterm/flayer.c
@@ -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);
+}
diff --git a/src/cmd/samterm/flayer.h b/src/cmd/samterm/flayer.h
index 8db79752..b0b2507a 100644
--- a/src/cmd/samterm/flayer.h
+++ b/src/cmd/samterm/flayer.h
@@ -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];
diff --git a/src/cmd/samterm/scroll.c b/src/cmd/samterm/scroll.c
index 994dc77f..12614751 100644
--- a/src/cmd/samterm/scroll.c
+++ b/src/cmd/samterm/scroll.c
@@ -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){