mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix shadowview event relativization
This commit is contained in:
parent
a4ca7bbf1e
commit
75d5868162
@ -169,7 +169,9 @@ impl ScrollBase {
|
|||||||
/// Starts scrolling from the given cursor position.
|
/// Starts scrolling from the given cursor position.
|
||||||
pub fn start_drag(&mut self, position: Vec2, width: usize) -> bool {
|
pub fn start_drag(&mut self, position: Vec2, width: usize) -> bool {
|
||||||
// First: are we on the correct column?
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +277,7 @@ impl ScrollBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let scrollbar_x = self.scrollbar_x(printer.size.x);
|
let scrollbar_x = self.scrollbar_x(printer.size.x);
|
||||||
|
// eprintln!("Drawing bar at x={}", scrollbar_x);
|
||||||
|
|
||||||
// The background
|
// The background
|
||||||
printer.print_vline((scrollbar_x, 0), printer.size.y, "|");
|
printer.print_vline((scrollbar_x, 0), printer.size.y, "|");
|
||||||
|
@ -24,10 +24,11 @@ impl<T: View> ShadowView<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn padding(&self) -> Vec2 {
|
fn padding(&self) -> Vec2 {
|
||||||
Vec2::new(
|
self.top_left_padding() + (1, 1)
|
||||||
1 + self.left_padding as usize,
|
}
|
||||||
1 + self.top_padding as usize,
|
|
||||||
)
|
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.
|
/// 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 {
|
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) {
|
fn wrap_draw(&self, printer: &Printer) {
|
||||||
|
@ -191,6 +191,7 @@ impl<R: Deref<Target = Child>, I: Iterator<Item = R>> Iterator
|
|||||||
|
|
||||||
self.previous = offset;
|
self.previous = offset;
|
||||||
|
|
||||||
|
// eprintln!("{:?}", offset);
|
||||||
(v, offset)
|
(v, offset)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user