removed the last dispatch_event I could find
This commit is contained in:
parent
dd7259c832
commit
4761898d9b
1 changed files with 19 additions and 20 deletions
|
@ -5,8 +5,8 @@ use crate::{
|
||||||
},
|
},
|
||||||
json::json,
|
json::json,
|
||||||
presenter::MeasurementContext,
|
presenter::MeasurementContext,
|
||||||
DebugContext, Element, ElementBox, ElementRc, Event, EventContext, LayoutContext, PaintContext,
|
DebugContext, Element, ElementBox, ElementRc, Event, EventContext, LayoutContext, MouseRegion,
|
||||||
RenderContext, ScrollWheelEvent, SizeConstraint, View, ViewContext,
|
PaintContext, RenderContext, SizeConstraint, View, ViewContext,
|
||||||
};
|
};
|
||||||
use std::{cell::RefCell, collections::VecDeque, ops::Range, rc::Rc};
|
use std::{cell::RefCell, collections::VecDeque, ops::Range, rc::Rc};
|
||||||
use sum_tree::{Bias, SumTree};
|
use sum_tree::{Bias, SumTree};
|
||||||
|
@ -263,6 +263,22 @@ impl Element for List {
|
||||||
) {
|
) {
|
||||||
cx.scene.push_layer(Some(bounds));
|
cx.scene.push_layer(Some(bounds));
|
||||||
|
|
||||||
|
cx.scene
|
||||||
|
.push_mouse_region(MouseRegion::new::<Self>(10, 0, bounds).on_scroll({
|
||||||
|
let state = self.state.clone();
|
||||||
|
let height = bounds.height();
|
||||||
|
let scroll_top = scroll_top.clone();
|
||||||
|
move |e, cx| {
|
||||||
|
state.0.borrow_mut().scroll(
|
||||||
|
&scroll_top,
|
||||||
|
height,
|
||||||
|
e.platform_event.delta,
|
||||||
|
e.platform_event.precise,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
let state = &mut *self.state.0.borrow_mut();
|
let state = &mut *self.state.0.borrow_mut();
|
||||||
for (mut element, origin) in state.visible_elements(bounds, scroll_top) {
|
for (mut element, origin) in state.visible_elements(bounds, scroll_top) {
|
||||||
element.paint(origin, visible_bounds, cx);
|
element.paint(origin, visible_bounds, cx);
|
||||||
|
@ -312,20 +328,6 @@ impl Element for List {
|
||||||
drop(cursor);
|
drop(cursor);
|
||||||
state.items = new_items;
|
state.items = new_items;
|
||||||
|
|
||||||
if let Event::ScrollWheel(ScrollWheelEvent {
|
|
||||||
position,
|
|
||||||
delta,
|
|
||||||
precise,
|
|
||||||
..
|
|
||||||
}) = event
|
|
||||||
{
|
|
||||||
if bounds.contains_point(*position)
|
|
||||||
&& state.scroll(scroll_top, bounds.height(), *delta, *precise, cx)
|
|
||||||
{
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handled
|
handled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +529,7 @@ impl StateInner {
|
||||||
mut delta: Vector2F,
|
mut delta: Vector2F,
|
||||||
precise: bool,
|
precise: bool,
|
||||||
cx: &mut EventContext,
|
cx: &mut EventContext,
|
||||||
) -> bool {
|
) {
|
||||||
if !precise {
|
if !precise {
|
||||||
delta *= 20.;
|
delta *= 20.;
|
||||||
}
|
}
|
||||||
|
@ -554,9 +556,6 @@ impl StateInner {
|
||||||
let visible_range = self.visible_range(height, scroll_top);
|
let visible_range = self.visible_range(height, scroll_top);
|
||||||
self.scroll_handler.as_mut().unwrap()(visible_range, cx);
|
self.scroll_handler.as_mut().unwrap()(visible_range, cx);
|
||||||
}
|
}
|
||||||
cx.notify();
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_top(&self, logical_scroll_top: &ListOffset) -> f32 {
|
fn scroll_top(&self, logical_scroll_top: &ListOffset) -> f32 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue