Use visible bounds to determine hit bounds for cursor/mouse regions
This commit is contained in:
parent
5c84f4b92c
commit
a26af194e7
4 changed files with 18 additions and 11 deletions
|
@ -212,11 +212,13 @@ impl Element for Container {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(style) = self.style.cursor {
|
if let Some(hit_bounds) = quad_bounds.intersection(visible_bounds) {
|
||||||
cx.scene.push_cursor_region(CursorRegion {
|
if let Some(style) = self.style.cursor {
|
||||||
bounds: quad_bounds,
|
cx.scene.push_cursor_region(CursorRegion {
|
||||||
style,
|
bounds: hit_bounds,
|
||||||
});
|
style,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let child_origin =
|
let child_origin =
|
||||||
|
|
|
@ -78,13 +78,13 @@ impl Element for EventHandler {
|
||||||
if let Some(discriminant) = self.capture_all {
|
if let Some(discriminant) = self.capture_all {
|
||||||
cx.scene.push_stacking_context(None);
|
cx.scene.push_stacking_context(None);
|
||||||
cx.scene.push_cursor_region(CursorRegion {
|
cx.scene.push_cursor_region(CursorRegion {
|
||||||
bounds,
|
bounds: visible_bounds,
|
||||||
style: Default::default(),
|
style: Default::default(),
|
||||||
});
|
});
|
||||||
cx.scene.push_mouse_region(MouseRegion {
|
cx.scene.push_mouse_region(MouseRegion {
|
||||||
view_id: cx.current_view_id(),
|
view_id: cx.current_view_id(),
|
||||||
discriminant: Some(discriminant),
|
discriminant: Some(discriminant),
|
||||||
bounds,
|
bounds: visible_bounds,
|
||||||
hover: Some(Rc::new(|_, _, _| {})),
|
hover: Some(Rc::new(|_, _, _| {})),
|
||||||
mouse_down: Some(Rc::new(|_, _| {})),
|
mouse_down: Some(Rc::new(|_, _| {})),
|
||||||
click: Some(Rc::new(|_, _, _| {})),
|
click: Some(Rc::new(|_, _, _| {})),
|
||||||
|
|
|
@ -152,9 +152,10 @@ impl Element for MouseEventHandler {
|
||||||
_: &mut Self::LayoutState,
|
_: &mut Self::LayoutState,
|
||||||
cx: &mut PaintContext,
|
cx: &mut PaintContext,
|
||||||
) -> Self::PaintState {
|
) -> Self::PaintState {
|
||||||
|
let hit_bounds = self.hit_bounds(visible_bounds);
|
||||||
if let Some(style) = self.cursor_style {
|
if let Some(style) = self.cursor_style {
|
||||||
cx.scene.push_cursor_region(CursorRegion {
|
cx.scene.push_cursor_region(CursorRegion {
|
||||||
bounds: self.hit_bounds(bounds),
|
bounds: hit_bounds,
|
||||||
style,
|
style,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ impl Element for MouseEventHandler {
|
||||||
cx.scene.push_mouse_region(MouseRegion {
|
cx.scene.push_mouse_region(MouseRegion {
|
||||||
view_id: cx.current_view_id(),
|
view_id: cx.current_view_id(),
|
||||||
discriminant: Some((self.tag, self.id)),
|
discriminant: Some((self.tag, self.id)),
|
||||||
bounds: self.hit_bounds(bounds),
|
bounds: hit_bounds,
|
||||||
hover: self.hover.clone(),
|
hover: self.hover.clone(),
|
||||||
click: self.click.clone(),
|
click: self.click.clone(),
|
||||||
mouse_down: self.mouse_down.clone(),
|
mouse_down: self.mouse_down.clone(),
|
||||||
|
|
|
@ -250,11 +250,15 @@ impl Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_cursor_region(&mut self, region: CursorRegion) {
|
pub fn push_cursor_region(&mut self, region: CursorRegion) {
|
||||||
self.active_layer().push_cursor_region(region);
|
if can_draw(region.bounds) {
|
||||||
|
self.active_layer().push_cursor_region(region);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_mouse_region(&mut self, region: MouseRegion) {
|
pub fn push_mouse_region(&mut self, region: MouseRegion) {
|
||||||
self.active_layer().push_mouse_region(region);
|
if can_draw(region.bounds) {
|
||||||
|
self.active_layer().push_mouse_region(region);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_image(&mut self, image: Image) {
|
pub fn push_image(&mut self, image: Image) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue