~ft/zuke

5e005228889a1e62170f1cf66f9af0c5ebafe645 — Sigrid Haflínudóttir a month ago 5627fda
show where zuke would seek if the user would press on the seek bar
1 files changed, 20 insertions(+), 7 deletions(-)

M zuke.c
M zuke.c => zuke.c +20 -7
@@ 62,6 62,8 @@ static int mincolwidth[7];
static char *cols = "AatD";
static int *shuffle;
static Rectangle seekbar;
static int seekmx, newseekmx;
static double seekoff; /* ms */
static char *covers[] = {"folder", "cover", "Cover", "scans/CD", "Scans/Front", "Covers/Front"};

static char *menu3i[] = {


@@ 252,9 254,10 @@ redraw(int full)
			msec = MIN(msec, getmeta(pcurplaying)->duration);
			snprint(tmp, sizeof(tmp), "%s%P/%P %d%%",
				shuffle != nil ? "∫ " : "",
				(int)msec/1000,
				(int)(newseekmx >= 0 ? seekoff : msec)/1000,
				getmeta(pcurplaying)->duration/1000,
				volume);
			seekmx = newseekmx;
		}else{
			snprint(tmp, sizeof(tmp), "%s%P %d%%",
				shuffle != nil ? "∫ " : "",


@@ 920,9 923,20 @@ threadmain(int argc, char **argv)
	for(;;){
ev:
		oldpcur = pcur;
		if(seekmx != newseekmx)
			redraw(0);

		switch(alt(a)){
		case 0:
			if(ptinrect(m.xy, seekbar)){
				seekoff = getmeta(pcurplaying)->duration * (double)(m.xy.x-1-seekbar.min.x) / (double)Dx(seekbar);
				if(seekoff < 0)
					seekoff = 0;
				newseekmx = m.xy.x-1;
			}else{
				newseekmx = -1;
			}

			if(m.buttons != 2)
				scrolling = 0;
			if(m.buttons == 0)


@@ 937,16 951,15 @@ ev:
				break;
			}

			n = (m.xy.y - screen->r.min.y)/f->height;

			if(oldbuttons == 0 && !scrolling && ptinrect(m.xy, insetrect(seekbar, -4))){
				m.xy.x--;
				if(ptinrect(m.xy, seekbar)){
					double off = getmeta(pcurplaying)->duration * (double)(m.xy.x-seekbar.min.x) / (double)Dx(seekbar);
					seekrel(playercurr, off/1000.0 - byteswritten/Bps);
				}
				if(ptinrect(m.xy, seekbar))
					seekrel(playercurr, seekoff/1000.0 - byteswritten/Bps);
				break;
			}

			n = (m.xy.y - screen->r.min.y)/f->height;

			if(oldbuttons == 0 && m.xy.x <= screen->r.min.x+Scrollwidth){
				if(m.buttons == 1){
					scroll = MAX(0, scroll-n-1);