Select views now highlight the entire line

And scrollviews have an extra padding column between the content and the
scrollbar.
This commit is contained in:
Alexandre Bury 2015-06-01 15:48:31 -07:00
parent 405cd1e961
commit 2a423b8408
3 changed files with 10 additions and 4 deletions

View File

@ -95,10 +95,11 @@ impl ScrollBase {
{ {
// Print the content in a sub_printer // Print the content in a sub_printer
let max_y = min(self.view_height, self.content_height - self.start_line); let max_y = min(self.view_height, self.content_height - self.start_line);
let w = if self.scrollable() { printer.size.x - 2 } else { printer.size.x };
for y in 0..max_y { for y in 0..max_y {
// Y is the actual coordinate of the line. // Y is the actual coordinate of the line.
// The item ID is then Y + self.start_line // The item ID is then Y + self.start_line
line_drawer(&printer.sub_printer(Vec2::new(0,y),printer.size,true), y+self.start_line); line_drawer(&printer.sub_printer(Vec2::new(0,y),Vec2::new(w,1),true), y+self.start_line);
} }

View File

@ -99,7 +99,11 @@ impl <T: 'static> View for SelectView<T> {
} else { } else {
color::PRIMARY color::PRIMARY
}; };
printer.with_color(style, |printer| printer.print((0,0), &self.items[i].label)); printer.with_color(style, |printer| {
printer.print((0,0), &self.items[i].label);
let x:usize = self.items[i].label.chars().count();
printer.print_hline((x,0), printer.size.x-x, ' ' as u64);
});
}); });
} }
@ -115,7 +119,8 @@ impl <T: 'static> View for SelectView<T> {
false false
}; };
let w = if scrolling { w + 1 } else { w }; // Add 2 spaces for the scrollbar if we need
let w = if scrolling { w + 2 } else { w };
Vec2::new(w,h) Vec2::new(w,h)
} }

View File

@ -242,7 +242,7 @@ impl View for TextView {
// Compute the text rows. // Compute the text rows.
self.rows = LinesIterator::new(&self.content, size.x).collect(); self.rows = LinesIterator::new(&self.content, size.x).collect();
if self.rows.len() > size.y { if self.rows.len() > size.y {
self.rows = LinesIterator::new(&self.content, size.x - 1).collect(); self.rows = LinesIterator::new(&self.content, size.x - 2).collect();
} }
self.scrollbase.set_heights(size.y, self.rows.len()); self.scrollbase.set_heights(size.y, self.rows.len());
} }