|
@@ -297,16 +297,16 @@ impl InnerInputState {
|
|
if old_pos != Some(new_pos) {
|
|
if old_pos != Some(new_pos) {
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("mousemove") {
|
|
for node in dom.get_listening_sorted("mousemove") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
let previously_contained = old_pos
|
|
let previously_contained = old_pos
|
|
- .filter(|pos| layout_contains_point(node_layout, *pos))
|
|
|
|
|
|
+ .filter(|pos| layout_contains_point(&node_layout, *pos))
|
|
.is_some();
|
|
.is_some();
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains && previously_contained {
|
|
if currently_contains && previously_contained {
|
|
try_create_event(
|
|
try_create_event(
|
|
"mousemove",
|
|
"mousemove",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -321,11 +321,11 @@ impl InnerInputState {
|
|
// mouseenter
|
|
// mouseenter
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("mouseenter") {
|
|
for node in dom.get_listening_sorted("mouseenter") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
let previously_contained = old_pos
|
|
let previously_contained = old_pos
|
|
- .filter(|pos| layout_contains_point(node_layout, *pos))
|
|
|
|
|
|
+ .filter(|pos| layout_contains_point(&node_layout, *pos))
|
|
.is_some();
|
|
.is_some();
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains && !previously_contained {
|
|
if currently_contains && !previously_contained {
|
|
try_create_event(
|
|
try_create_event(
|
|
@@ -344,16 +344,16 @@ impl InnerInputState {
|
|
// mouseover
|
|
// mouseover
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("mouseover") {
|
|
for node in dom.get_listening_sorted("mouseover") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
let previously_contained = old_pos
|
|
let previously_contained = old_pos
|
|
- .filter(|pos| layout_contains_point(node_layout, *pos))
|
|
|
|
|
|
+ .filter(|pos| layout_contains_point(&node_layout, *pos))
|
|
.is_some();
|
|
.is_some();
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains && !previously_contained {
|
|
if currently_contains && !previously_contained {
|
|
try_create_event(
|
|
try_create_event(
|
|
"mouseover",
|
|
"mouseover",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -367,13 +367,13 @@ impl InnerInputState {
|
|
if was_pressed {
|
|
if was_pressed {
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("mousedown") {
|
|
for node in dom.get_listening_sorted("mousedown") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains {
|
|
if currently_contains {
|
|
try_create_event(
|
|
try_create_event(
|
|
"mousedown",
|
|
"mousedown",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -388,13 +388,13 @@ impl InnerInputState {
|
|
if was_released {
|
|
if was_released {
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("mouseup") {
|
|
for node in dom.get_listening_sorted("mouseup") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains {
|
|
if currently_contains {
|
|
try_create_event(
|
|
try_create_event(
|
|
"mouseup",
|
|
"mouseup",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -410,13 +410,13 @@ impl InnerInputState {
|
|
if mouse_data.trigger_button() == Some(DioxusMouseButton::Primary) && was_released {
|
|
if mouse_data.trigger_button() == Some(DioxusMouseButton::Primary) && was_released {
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("click") {
|
|
for node in dom.get_listening_sorted("click") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains {
|
|
if currently_contains {
|
|
try_create_event(
|
|
try_create_event(
|
|
"click",
|
|
"click",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -433,13 +433,13 @@ impl InnerInputState {
|
|
{
|
|
{
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("contextmenu") {
|
|
for node in dom.get_listening_sorted("contextmenu") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains {
|
|
if currently_contains {
|
|
try_create_event(
|
|
try_create_event(
|
|
"contextmenu",
|
|
"contextmenu",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -456,9 +456,9 @@ impl InnerInputState {
|
|
if wheel_delta != 0.0 {
|
|
if wheel_delta != 0.0 {
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("wheel") {
|
|
for node in dom.get_listening_sorted("wheel") {
|
|
- let node_layout =
|
|
|
|
- layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
|
|
+
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if currently_contains {
|
|
if currently_contains {
|
|
try_create_event(
|
|
try_create_event(
|
|
@@ -479,16 +479,16 @@ impl InnerInputState {
|
|
// mouseleave
|
|
// mouseleave
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("mouseleave") {
|
|
for node in dom.get_listening_sorted("mouseleave") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
let previously_contained = old_pos
|
|
let previously_contained = old_pos
|
|
- .filter(|pos| layout_contains_point(node_layout, *pos))
|
|
|
|
|
|
+ .filter(|pos| layout_contains_point(&node_layout, *pos))
|
|
.is_some();
|
|
.is_some();
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if !currently_contains && previously_contained {
|
|
if !currently_contains && previously_contained {
|
|
try_create_event(
|
|
try_create_event(
|
|
"mouseleave",
|
|
"mouseleave",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -502,16 +502,16 @@ impl InnerInputState {
|
|
// mouseout
|
|
// mouseout
|
|
let mut will_bubble = FxHashSet::default();
|
|
let mut will_bubble = FxHashSet::default();
|
|
for node in dom.get_listening_sorted("mouseout") {
|
|
for node in dom.get_listening_sorted("mouseout") {
|
|
- let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
|
|
|
|
+ let node_layout = get_abs_layout(node, dom, layout);
|
|
let previously_contained = old_pos
|
|
let previously_contained = old_pos
|
|
- .filter(|pos| layout_contains_point(node_layout, *pos))
|
|
|
|
|
|
+ .filter(|pos| layout_contains_point(&node_layout, *pos))
|
|
.is_some();
|
|
.is_some();
|
|
- let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
|
|
|
|
+ let currently_contains = layout_contains_point(&node_layout, new_pos);
|
|
|
|
|
|
if !currently_contains && previously_contained {
|
|
if !currently_contains && previously_contained {
|
|
try_create_event(
|
|
try_create_event(
|
|
"mouseout",
|
|
"mouseout",
|
|
- Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
|
|
|
|
+ Arc::new(prepare_mouse_data(mouse_data, &node_layout)),
|
|
&mut will_bubble,
|
|
&mut will_bubble,
|
|
resolved_events,
|
|
resolved_events,
|
|
node,
|
|
node,
|
|
@@ -544,6 +544,22 @@ impl InnerInputState {
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+fn get_abs_layout(node: &Node, dom: &Dom, taffy: &Taffy) -> Layout {
|
|
|
|
+ let mut node_layout = taffy
|
|
|
|
+ .layout(node.state.layout.node.unwrap())
|
|
|
|
+ .unwrap()
|
|
|
|
+ .clone();
|
|
|
|
+ let mut current = node;
|
|
|
|
+ while let Some(parent_id) = current.parent {
|
|
|
|
+ let parent = &dom[parent_id];
|
|
|
|
+ current = parent;
|
|
|
|
+ let parent_layout = taffy.layout(parent.state.layout.node.unwrap()).unwrap();
|
|
|
|
+ node_layout.location.x += parent_layout.location.x;
|
|
|
|
+ node_layout.location.y += parent_layout.location.y;
|
|
|
|
+ }
|
|
|
|
+ node_layout
|
|
|
|
+}
|
|
|
|
+
|
|
pub struct RinkInputHandler {
|
|
pub struct RinkInputHandler {
|
|
state: Rc<RefCell<InnerInputState>>,
|
|
state: Rc<RefCell<InnerInputState>>,
|
|
queued_events: Rc<RefCell<Vec<EventCore>>>,
|
|
queued_events: Rc<RefCell<Vec<EventCore>>>,
|