summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6ce0f3b)
raw | patch | inline | side by side (parent: 6ce0f3b)
author | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 06:21:57 +0000 (08:21 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 06:21:57 +0000 (08:21 +0200) |
src/progress_bar.c | patch | blob | history | |
src/progress_bar.h | patch | blob | history | |
src/screen.c | patch | blob | history |
diff --git a/src/progress_bar.c b/src/progress_bar.c
index 8fe278468000e799b8e7972b87a64d31efa1b4b4..37a397715847f1c2105728cd8bc0d3d64434bfdd 100644 (file)
--- a/src/progress_bar.c
+++ b/src/progress_bar.c
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;
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)
{
p->max = max;
p->current = current;
- return progress_bar_resize(p) || modified;
+ return progress_bar_calc(p) || modified;
}
diff --git a/src/progress_bar.h b/src/progress_bar.h
index d6fdba5b0235a967ab4b7eea539387f957181d06..94a76002bcf83d48d9849c81f37f1b44572dde88 100644 (file)
--- a/src/progress_bar.h
+++ b/src/progress_bar.h
};
static inline void
-progress_bar_init(struct progress_bar *p, unsigned height, unsigned width,
- int y, int x)
+progress_bar_init(struct progress_bar *p, unsigned width, int y, int x)
{
- window_init(&p->window, height, width, y, x);
+ window_init(&p->window, 1, width, y, x);
+ leaveok(p->window.w, TRUE);
p->current = 0;
p->max = 0;
p->width = 0;
}
+static inline void
+progress_bar_deinit(struct progress_bar *p)
+{
+ delwin(p->window.w);
+}
+
void
progress_bar_paint(const struct progress_bar *p);
-bool
-progress_bar_resize(struct progress_bar *p);
+void
+progress_bar_resize(struct progress_bar *p, unsigned width, int y, int x);
bool
progress_bar_set(struct progress_bar *p, unsigned current, unsigned max);
diff --git a/src/screen.c b/src/screen.c
index 15a98d08e25b647f659fcb56bbd8567f94851c46..a4f0a89eb26bc730d45fec68c22c1cc527b1a512 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
delwin(screen.top_window.w);
delwin(screen.main_window.w);
- delwin(screen.progress_bar.window.w);
+ progress_bar_deinit(&screen.progress_bar);
delwin(screen.status_window.w);
}
wclear(screen.main_window.w);
/* progress window */
- screen.progress_bar.window.cols = screen.cols;
- wresize(screen.progress_bar.window.w, 1, screen.cols);
- mvwin(screen.progress_bar.window.w, screen.rows-2, 0);
- progress_bar_resize(&screen.progress_bar);
+ progress_bar_resize(&screen.progress_bar, screen.cols,
+ screen.rows - 2, 0);
progress_bar_paint(&screen.progress_bar);
/* status window */
keypad(screen.main_window.w, TRUE);
/* create progress window */
- progress_bar_init(&screen.progress_bar, 1, screen.cols,
+ progress_bar_init(&screen.progress_bar, screen.cols,
screen.rows - 2, 0);
progress_bar_paint(&screen.progress_bar);
- leaveok(screen.progress_bar.window.w, TRUE);
-
/* create status window */
window_init(&screen.status_window, 1, screen.cols,
screen.rows - 1, 0);