Rename scrollbar_padding -> scrollbar_offset in ScrollBase

This commit is contained in:
Alexandre Bury 2016-08-02 00:36:27 -07:00
parent 75c365451f
commit 93ceb17c21
2 changed files with 8 additions and 8 deletions

View File

@ -19,11 +19,11 @@ pub struct ScrollBase {
/// Padding for the scrollbar /// Padding for the scrollbar
/// ///
/// If present, the scrollbar will be shifted /// If present, the scrollbar will be shifted
/// `scrollbar_padding` columns to the left. /// `scrollbar_offset` columns to the left.
/// ///
/// (Useful when each item includes its own side borders, /// (Useful when each item includes its own side borders,
/// to draw the scrollbar inside.) /// to draw the scrollbar inside.)
pub scrollbar_padding: usize, pub scrollbar_offset: usize,
} }
impl ScrollBase { impl ScrollBase {
@ -33,7 +33,7 @@ impl ScrollBase {
start_line: 0, start_line: 0,
content_height: 0, content_height: 0,
view_height: 0, view_height: 0,
scrollbar_padding: 0, scrollbar_offset: 0,
} }
} }
@ -42,8 +42,8 @@ impl ScrollBase {
/// Used by views that draw their side borders in the children. /// Used by views that draw their side borders in the children.
/// Pushing the scrollbar to the left allows it to stay inside /// Pushing the scrollbar to the left allows it to stay inside
/// the borders. /// the borders.
pub fn bar_padding(mut self, padding: usize) -> Self { pub fn bar_offset(mut self, padding: usize) -> Self {
self.scrollbar_padding = padding; self.scrollbar_offset = padding;
self self
} }
@ -143,7 +143,7 @@ impl ScrollBase {
if printer.size.x < 2 { if printer.size.x < 2 {
return; return;
} }
printer.size.x - 2 + self.scrollbar_padding // TODO: 2 printer.size.x - 2 + self.scrollbar_offset
} else { } else {
printer.size.x printer.size.x
}; };
@ -180,7 +180,7 @@ impl ScrollBase {
}; };
// TODO: use 1 instead of 2 // TODO: use 1 instead of 2
let scrollbar_x = printer.size.x - 1 - self.scrollbar_padding; let scrollbar_x = printer.size.x - 1 - self.scrollbar_offset;
printer.print_vline((scrollbar_x, 0), printer.size.y, "|"); printer.print_vline((scrollbar_x, 0), printer.size.y, "|");
printer.with_color(color, |printer| { printer.with_color(color, |printer| {
printer.print_vline((scrollbar_x, start), height, " "); printer.print_vline((scrollbar_x, start), height, " ");

View File

@ -29,7 +29,7 @@ impl MenuPopup {
MenuPopup { MenuPopup {
menu: menu, menu: menu,
focus: 0, focus: 0,
scrollbase: ScrollBase::new().bar_padding(1), scrollbase: ScrollBase::new().bar_offset(1),
align: Align::top_left(), align: Align::top_left(),
on_dismiss: None, on_dismiss: None,
on_action: None, on_action: None,