ProgressBar takes all given width

This commit is contained in:
Alexandre Bury 2016-07-26 09:55:22 -07:00
parent 2e5262096a
commit 04f961657f
3 changed files with 9 additions and 3 deletions

View File

@ -88,7 +88,7 @@ impl XY<usize> {
}
/// Returns a new `Vec2` with the axis `o` set to `value`.
pub fn with(&self, o: Orientation, value: usize) -> Self {
pub fn with_axis(&self, o: Orientation, value: usize) -> Self {
let mut other = *self;
*o.get_ref(&mut other) = value;
other

View File

@ -222,7 +222,7 @@ impl View for LinearLayout {
// Ok, so maybe it didn't.
// Budget cuts, everyone.
let budget_req = req.with(self.orientation, 1);
let budget_req = req.with_axis(self.orientation, 1);
// println_stderr!("Budget req: {:?}", budget_req);
// See how they like it that way
@ -288,7 +288,7 @@ impl View for LinearLayout {
.map(|v| self.orientation.get(v))
.zip(allocations.iter())
.map(|(a, b)| a + b)
.map(|l| req.with(self.orientation, l))
.map(|l| req.with_axis(self.orientation, l))
.collect();
// println_stderr!("Final sizes: {:?}", final_lengths);

View File

@ -3,7 +3,9 @@ use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicUsize, Ordering};
use {Cursive, Printer};
use vec::Vec2;
use align::HAlign;
use direction::Orientation;
use event::*;
use theme::{ColorStyle, Effect};
use view::View;
@ -139,4 +141,8 @@ impl View for ProgressBar {
EventResult::Ignored
}
fn get_min_size(&mut self, size: Vec2) -> Vec2 {
size.with_axis(Orientation::Vertical, 1)
}
}