From 6c71ac14b0deecdaa130fc69430c48db23365f55 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 25 Jul 2016 12:18:05 -0700 Subject: [PATCH] More linear progress bar progression Each cell should receive the same number of ticks --- examples/progress.rs | 3 +-- src/view/progress_bar.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/progress.rs b/examples/progress.rs index 0b9ff23..3da9245 100644 --- a/examples/progress.rs +++ b/examples/progress.rs @@ -41,8 +41,7 @@ fn main() { })) .title("Progress bar example") - .padding_top(1) - .padding_bottom(1) + .padding((0,0,1,1)) .with_id("dialog")); siv.set_fps(10); diff --git a/src/view/progress_bar.rs b/src/view/progress_bar.rs index 99eabd2..e29ef04 100644 --- a/src/view/progress_bar.rs +++ b/src/view/progress_bar.rs @@ -84,7 +84,7 @@ impl View for ProgressBar { let available = printer.size.x; let value = self.value.load(Ordering::Relaxed); - let length = (available * (value - self.min)) / (self.max - self.min); + let length = ((1 + available) * (value - self.min)) / (1 + self.max - self.min); printer.with_color(ColorStyle::Highlight, |printer| { printer.print_hline((0, 0), length, " "); });