Permalink
Browse files

Fix list bugs

  • Loading branch information...
jackpot51 committed Aug 30, 2017
1 parent 07de5a0 commit 4f59f7ee387d0ad03d2e66422d7cfb43c5f51130
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/widgets/list.rs
View
@@ -13,7 +13,7 @@ use widgets::Widget;
use std::ops::Index;
/// An entry in a list
/// Each entry stores widgets within.
/// Each entry stores widgets within.
pub struct Entry {
pub height: Cell<u32>,
click_callback: RefCell<Option<Arc<Fn(&Entry, Point)>>>,
@@ -107,11 +107,14 @@ impl List {
pub fn scroll(&self, y: i32) {
let mut set_to = self.v_scroll.get() + y;
let max = self.current_height.get() as i32 - self.rect.get().height as i32;
if set_to < 0 {
set_to = 0;
} else if self.rect.get().height as i32 + set_to > self.current_height.get() as i32 {
set_to = self.v_scroll.get() as i32;
} else if set_to > max {
set_to = max;
}
self.v_scroll.set(set_to);
}
@@ -178,7 +181,7 @@ impl Widget for List {
}
let image = image.data();
target.image(x, current_y-self.v_scroll.get(), width, entry.height.get(), &image);
target.image(0, current_y-self.v_scroll.get(), width, entry.height.get(), &image);
current_y += entry.height.get() as i32
}
@@ -292,4 +295,3 @@ impl Widget for List {
}
impl Place for List {}

0 comments on commit 4f59f7e

Please sign in to comment.