ref: 6e8e1763053da3c3d71032d1477e4a10d47857f1
parent: 2a933163ce1662c38390bdcd8848370460d17362
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed May 27 10:07:10 EDT 2020
even simpler
--- a/zuke.c
+++ b/zuke.c
@@ -124,97 +124,92 @@
return;
lockdisplay(display);
- if(!full){
- r = screen->r;
- r.min.x = r.max.x - 128 - 8;
- r.min.y = r.max.y - font->height - 128 - 8 - 4;
- replclipr(screen, 0, r);
- }
+ if(full){
+ draw(screen, screen->r, colors[Dback].im, nil, ZP);
- draw(screen, screen->r, colors[Dback].im, nil, ZP);
+ scrollsz = Dy(screen->r) / f->height - 1;
+ adjustcolumns();
+ left = screen->r.min.x;
+ if(scrollsz < plnum){ /* add a scrollbar */
+ p.x = sp.x = screen->r.min.x + Scrollwidth;
+ p.y = screen->r.min.y;
+ sp.y = screen->r.max.y;
+ line(screen, p, sp, Endsquare, Endsquare, 0, colors[Dfmed].im, ZP);
- scrollsz = Dy(screen->r) / f->height - 1;
- adjustcolumns();
- left = screen->r.min.x;
- if(scrollsz < plnum){ /* add a scrollbar */
- p.x = sp.x = screen->r.min.x + Scrollwidth;
- p.y = screen->r.min.y;
+ r = screen->r;
+ r.max.x = r.min.x + Scrollwidth - 1;
+ r.min.x += 1;
+ if(scroll < 1)
+ scrollcenter = 0;
+ else
+ scrollcenter = (Dy(screen->r)-Scrollheight*5/4)*scroll / (plnum - scrollsz);
+ r.min.y += scrollcenter + Scrollheight/4;
+ r.max.y = r.min.y + Scrollheight;
+ draw(screen, r, colors[Dfmed].im, nil, ZP);
+
+ left += Scrollwidth + 4;
+ }
+
+ p.x = sp.x = left + colwidth[0] + 4;
+ p.y = 0;
sp.y = screen->r.max.y;
line(screen, p, sp, Endsquare, Endsquare, 0, colors[Dfmed].im, ZP);
- r = screen->r;
- r.max.x = r.min.x + Scrollwidth - 1;
- r.min.x += 1;
- if(scroll < 1)
- scrollcenter = 0;
- else
- scrollcenter = (Dy(screen->r)-Scrollheight*5/4)*scroll / (plnum - scrollsz);
- r.min.y += scrollcenter + Scrollheight/4;
- r.max.y = r.min.y + Scrollheight;
- draw(screen, r, colors[Dfmed].im, nil, ZP);
+ p.x = sp.x = left + colwidth[0] + 8 + colwidth[1] + 4;
+ p.y = 0;
+ sp.y = screen->r.max.y;
+ line(screen, p, sp, Endsquare, Endsquare, 0, colors[Dfmed].im, ZP);
- left += Scrollwidth + 4;
- }
+ sp.x = sp.y = 0;
+ p.x = left + 2;
+ p.y = screen->r.min.y + 2;
- p.x = sp.x = left + colwidth[0] + 4;
- p.y = 0;
- sp.y = screen->r.max.y;
- line(screen, p, sp, Endsquare, Endsquare, 0, colors[Dfmed].im, ZP);
+ for(i = scroll; i < plnum; i++, p.y += f->height){
+ if(i < 0)
+ continue;
+ if(p.y > screen->r.max.y)
+ break;
- p.x = sp.x = left + colwidth[0] + 8 + colwidth[1] + 4;
- p.y = 0;
- sp.y = screen->r.max.y;
- line(screen, p, sp, Endsquare, Endsquare, 0, colors[Dfmed].im, ZP);
+ if(pcur == i){
+ sel.min.x = left;
+ sel.min.y = p.y;
+ sel.max.x = screen->r.max.x;
+ sel.max.y = p.y + f->height;
+ draw(screen, sel, colors[Dbinv].im, nil, ZP);
+ col = colors[Dfinv].im;
+ }else{
+ col = colors[pcurplaying == i ? Dfhigh : Dfmed].im;
+ }
- sp.x = sp.y = 0;
- p.x = left + 2;
- p.y = screen->r.min.y + 2;
+ sel = screen->r;
+ r = screen->r;
- for(i = scroll; i < plnum; i++, p.y += f->height){
- if(i < 0)
- continue;
- if(p.y > screen->r.max.y)
- break;
+ p.x = left + 2;
+ sel.max.x = p.x + colwidth[0];
+ replclipr(screen, 0, sel);
+ string(screen, p, col, sp, f, pl[i].artist[0]);
+ p.x += colwidth[0] + 8;
+ sel.min.x = p.x;
+ sel.max.x = p.x + colwidth[1];
+ replclipr(screen, 0, sel);
+ string(screen, p, col, sp, f, pl[i].album);
+ p.x += colwidth[1] + 8;
+ sel.min.x = p.x;
+ sel.max.x = p.x + colwidth[2];
+ replclipr(screen, 0, sel);
+ string(screen, p, col, sp, f, pl[i].title);
- if(pcur == i){
- sel.min.x = left;
- sel.min.y = p.y;
- sel.max.x = screen->r.max.x;
- sel.max.y = p.y + f->height;
- draw(screen, sel, colors[Dbinv].im, nil, ZP);
- col = colors[Dfinv].im;
- }else{
- col = colors[pcurplaying == i ? Dfhigh : Dfmed].im;
- }
+ replclipr(screen, 0, r);
- sel = screen->r;
- r = screen->r;
-
- p.x = left + 2;
- sel.max.x = p.x + colwidth[0];
- replclipr(screen, 0, sel);
- string(screen, p, col, sp, f, pl[i].artist[0]);
- p.x += colwidth[0] + 8;
- sel.min.x = p.x;
- sel.max.x = p.x + colwidth[1];
- replclipr(screen, 0, sel);
- string(screen, p, col, sp, f, pl[i].album);
- p.x += colwidth[1] + 8;
- sel.min.x = p.x;
- sel.max.x = p.x + colwidth[2];
- replclipr(screen, 0, sel);
- string(screen, p, col, sp, f, pl[i].title);
-
- replclipr(screen, 0, r);
-
- if(pcurplaying == i){
- Point rightp, leftp;
- leftp.y = rightp.y = p.y - 1;
- leftp.x = left;
- rightp.x = screen->r.max.x;
- line(screen, leftp, rightp, 0, 0, 0, colors[Dfmed].im, sp);
- leftp.y = rightp.y = p.y + f->height;
- line(screen, leftp, rightp, 0, 0, 0, colors[Dfmed].im, sp);
+ if(pcurplaying == i){
+ Point rightp, leftp;
+ leftp.y = rightp.y = p.y - 1;
+ leftp.x = left;
+ rightp.x = screen->r.max.x;
+ line(screen, leftp, rightp, 0, 0, 0, colors[Dfmed].im, sp);
+ leftp.y = rightp.y = p.y + f->height;
+ line(screen, leftp, rightp, 0, 0, 0, colors[Dfmed].im, sp);
+ }
}
}
@@ -228,7 +223,7 @@
draw(screen, r, colors[Dblow].im, nil, ZP);
string(screen, addpt(r.min, Pt(2, 2)), colors[Dfhigh].im, sp, f, tmp);
- if(cover != nil){
+ if(cover != nil && full){
r.max.x = r.min.x;
r.min.x = screen->r.max.x - cover->r.max.x - 8;
draw(screen, r, colors[Dblow].im, nil, ZP);
@@ -240,8 +235,6 @@
draw(screen, insetrect(r, 4), cover, nil, ZP);
}
- replclipr(screen, 0, screen->r);
-
flushimage(display, 1);
unlockdisplay(display);
}
@@ -472,7 +465,7 @@
if(player->img != nil && nbrecv(player->img, &thiscover) != 0){
freeimage(cover);
cover = thiscover;
- redraw(0);
+ redraw(1);
player->img = nil;
}
c = nbrecvul(player->ctl);