diff --git a/src/progress_bar.c b/src/progress_bar.c
index 8fe278468000e799b8e7972b87a64d31efa1b4b4..590b7bef974dce5e7c80ca60aab1cca0be28e31c 100644 (file)
--- a/src/progress_bar.c
+++ b/src/progress_bar.c
/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
* Project homepage: http://musicpd.org
*
* This program is free software; you can redistribute it and/or modify
wnoutrefresh(p->window.w);
}
-bool
-progress_bar_resize(struct progress_bar *p)
+static bool
+progress_bar_calc(struct progress_bar *p)
{
- unsigned old_width;
-
- assert(p != NULL);
-
if (p->max == 0)
return false;
- old_width = p->width;
+ unsigned old_width = p->width;
p->width = (p->window.cols * p->current) / (p->max + 1);
assert(p->width < p->window.cols);
return p->width != old_width;
}
+void
+progress_bar_resize(struct progress_bar *p, unsigned width, int y, int x)
+{
+ assert(p != NULL);
+
+ p->window.cols = width;
+ wresize(p->window.w, 1, width);
+ mvwin(p->window.w, y, x);
+
+ progress_bar_calc(p);
+}
+
bool
progress_bar_set(struct progress_bar *p, unsigned current, unsigned max)
{
- bool modified;
-
assert(p != NULL);
if (current > max)
current = max;
- modified = (max == 0) != (p->max == 0);
+ bool modified = (max == 0) != (p->max == 0);
p->max = max;
p->current = current;
- return progress_bar_resize(p) || modified;
+ return progress_bar_calc(p) || modified;
}