diff options
-rw-r--r-- | include/frame.h | 4 | ||||
-rw-r--r-- | src/libframe/frdraw.c | 19 | ||||
-rw-r--r-- | src/libframe/frinit.c | 11 |
3 files changed, 24 insertions, 10 deletions
diff --git a/include/frame.h b/include/frame.h index c4ebd160..590a7b8c 100644 --- a/include/frame.h +++ b/include/frame.h @@ -1,7 +1,7 @@ #ifndef _FRAME_H_ #define _FRAME_H_ 1 #if defined(__cplusplus) -extern "C" { +extern "C" { #endif AUTOLIB(frame) @@ -19,7 +19,6 @@ enum{ }; #define FRTICKW 3 - struct Frbox { long wid; /* in pixels */ @@ -51,6 +50,7 @@ struct Frame Image *tickback; /* saved image under tick */ int ticked; /* flag: is tick onscreen? */ int noredraw; /* don't draw on the screen */ + int tickscale; /* tick scaling factor */ }; ulong frcharofpt(Frame*, Point); diff --git a/src/libframe/frdraw.c b/src/libframe/frdraw.c index c1cace42..2a3a95e0 100644 --- a/src/libframe/frdraw.c +++ b/src/libframe/frdraw.c @@ -137,15 +137,15 @@ frredraw(Frame *f) pt = frdrawsel0(f, pt, f->p1, f->nchars, f->cols[BACK], f->cols[TEXT]); } -void -frtick(Frame *f, Point pt, int ticked) +static void +_frtick(Frame *f, Point pt, int ticked) { Rectangle r; if(f->ticked==ticked || f->tick==0 || !ptinrect(pt, f->r)) return; - pt.x--; /* looks best just left of where requested */ - r = Rect(pt.x, pt.y, pt.x+FRTICKW, pt.y+f->font->height); + pt.x -= f->tickscale; /* looks best just left of where requested */ + r = Rect(pt.x, pt.y, pt.x+FRTICKW*f->tickscale, pt.y+f->font->height); /* can go into left border but not right */ if(r.max.x > f->r.max.x) r.max.x = f->r.max.x; @@ -157,6 +157,17 @@ frtick(Frame *f, Point pt, int ticked) f->ticked = ticked; } +void +frtick(Frame *f, Point pt, int ticked) +{ + if(f->tickscale != scalesize(f->display, 1)) { + if(f->ticked) + _frtick(f, pt, 0); + frinittick(f); + } + _frtick(f, pt, ticked); +} + Point _frdraw(Frame *f, Point pt) { diff --git a/src/libframe/frinit.c b/src/libframe/frinit.c index c178ede1..90931f25 100644 --- a/src/libframe/frinit.c +++ b/src/libframe/frinit.c @@ -31,11 +31,14 @@ frinittick(Frame *f) Image *b; Font *ft; + if(f->cols[BACK] == nil || f->display == nil) + return; + f->tickscale = scalesize(f->display, 1); b = f->display->screenimage; ft = f->font; if(f->tick) freeimage(f->tick); - f->tick = allocimage(f->display, Rect(0, 0, FRTICKW, ft->height), b->chan, 0, DWhite); + f->tick = allocimage(f->display, Rect(0, 0, f->tickscale*FRTICKW, ft->height), b->chan, 0, DWhite); if(f->tick == nil) return; if(f->tickback) @@ -49,10 +52,10 @@ frinittick(Frame *f) /* background color */ draw(f->tick, f->tick->r, f->cols[BACK], nil, ZP); /* vertical line */ - draw(f->tick, Rect(FRTICKW/2, 0, FRTICKW/2+1, ft->height), f->display->black, nil, ZP); + draw(f->tick, Rect(f->tickscale*(FRTICKW/2), 0, f->tickscale*(FRTICKW/2+1), ft->height), f->display->black, nil, ZP); /* box on each end */ - draw(f->tick, Rect(0, 0, FRTICKW, FRTICKW), f->cols[TEXT], nil, ZP); - draw(f->tick, Rect(0, ft->height-FRTICKW, FRTICKW, ft->height), f->cols[TEXT], nil, ZP); + draw(f->tick, Rect(0, 0, f->tickscale*FRTICKW, f->tickscale*FRTICKW), f->cols[TEXT], nil, ZP); + draw(f->tick, Rect(0, ft->height-f->tickscale*FRTICKW, f->tickscale*FRTICKW, ft->height), f->cols[TEXT], nil, ZP); } void |