Fix shadowview event relativization

This commit is contained in:
Alexandre Bury 2017-10-12 16:41:45 -07:00
parent a4ca7bbf1e
commit 75d5868162
3 changed files with 12 additions and 6 deletions

View File

@ -169,7 +169,9 @@ impl ScrollBase {
/// Starts scrolling from the given cursor position.
pub fn start_drag(&mut self, position: Vec2, width: usize) -> bool {
// First: are we on the correct column?
if position.x != self.scrollbar_x(width) {
let scrollbar_x = self.scrollbar_x(width);
// eprintln!("Grabbed {} for {}", position.x, scrollbar_x);
if position.x != scrollbar_x {
return false;
}
@ -275,6 +277,7 @@ impl ScrollBase {
};
let scrollbar_x = self.scrollbar_x(printer.size.x);
// eprintln!("Drawing bar at x={}", scrollbar_x);
// The background
printer.print_vline((scrollbar_x, 0), printer.size.y, "|");

View File

@ -24,10 +24,11 @@ impl<T: View> ShadowView<T> {
}
fn padding(&self) -> Vec2 {
Vec2::new(
1 + self.left_padding as usize,
1 + self.top_padding as usize,
)
self.top_left_padding() + (1, 1)
}
fn top_left_padding(&self) -> Vec2 {
Vec2::new(self.left_padding as usize, self.top_padding as usize)
}
/// If set, adds an empty column to the left of the view.
@ -62,7 +63,8 @@ impl<T: View> ViewWrapper for ShadowView<T> {
}
fn wrap_on_event(&mut self, event: Event) -> EventResult {
self.view.on_event(event.relativized((1, 1)))
let padding = self.top_left_padding();
self.view.on_event(event.relativized(padding))
}
fn wrap_draw(&self, printer: &Printer) {

View File

@ -191,6 +191,7 @@ impl<R: Deref<Target = Child>, I: Iterator<Item = R>> Iterator
self.previous = offset;
// eprintln!("{:?}", offset);
(v, offset)
})
}