Skip to content

Commit 76f4787

Browse files
committed
Hit-testing works again
1 parent 9fcf485 commit 76f4787

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

azul-desktop/src/wr_translate.rs

+37-10
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,6 @@ pub(crate) fn fullhittest_new_webrender(
720720

721721
let pipeline_id = PipelineId(dom_id.inner.min(core::u32::MAX as usize) as u32, document_id.id);
722722

723-
println!("doing hit test: cursor = {:?} (hidipi = {:?}), document = {:?}, pipeline = {:?}",
724-
cursor_location, hidpi_factor, document_id, pipeline_id);
725-
726723
let layout_result = match layout_results.get(dom_id.inner) {
727724
Some(s) => s,
728725
None => break,
@@ -733,8 +730,6 @@ pub(crate) fn fullhittest_new_webrender(
733730
WrWorldPoint::new(cursor_relative_to_dom.x, cursor_relative_to_dom.y),
734731
);
735732

736-
println!("wr result: {:#?}", wr_result);
737-
738733
let hit_items = wr_result.items.iter()
739734
.filter_map(|i| {
740735

@@ -753,8 +748,6 @@ pub(crate) fn fullhittest_new_webrender(
753748
}))
754749
}).collect::<Vec<_>>();
755750

756-
println!("hit_items: {:#?}", hit_items);
757-
758751
for (node_id, item) in hit_items.into_iter() {
759752

760753
use azul_core::ui_solver::HitTest;
@@ -796,9 +789,6 @@ pub(crate) fn fullhittest_new_webrender(
796789
}
797790
}
798791

799-
println!("final result: {:#?}", ret);
800-
println!("--------------------------");
801-
802792
ret
803793
}
804794

@@ -1644,6 +1634,19 @@ fn push_frame(
16441634
None => WrClipId::root(builder.pipeline_id), // no clipping
16451635
};
16461636

1637+
// push the hit-testing tag if any
1638+
if let Some(hit_tag) = frame.tag {
1639+
builder.push_hit_test(&WrCommonItemProperties {
1640+
clip_rect: WrLayoutRect::new(
1641+
WrLayoutPoint::new(0.0, 0.0),
1642+
WrLayoutSize::new(frame.size.width, frame.size.height),
1643+
),
1644+
spatial_id: rect_spatial_id,
1645+
clip_id: parent_clip_id,
1646+
flags: WrPrimitiveFlags::empty(),
1647+
}, (hit_tag.0, 0));
1648+
}
1649+
16471650
// if let Some(image_mask) -> define_image_mask_clip()
16481651
for child in frame.children {
16491652
push_display_list_msg(document_id, render_api, builder, child, rect_spatial_id, children_clip_id, positioned_items, current_hidpi_factor);
@@ -1712,6 +1715,30 @@ fn push_scroll_frame(
17121715
),
17131716
);
17141717

1718+
// push the scroll hit-testing tag if any
1719+
builder.push_hit_test(&WrCommonItemProperties {
1720+
clip_rect: WrLayoutRect::new(
1721+
WrLayoutPoint::new(0.0, 0.0),
1722+
WrLayoutSize::new(scroll_frame.content_rect.size.width, scroll_frame.content_rect.size.height),
1723+
),
1724+
spatial_id: scroll_frame_clip_info.spatial_id,
1725+
clip_id: scroll_frame_clip_info.clip_id,
1726+
flags: WrPrimitiveFlags::empty(),
1727+
}, (scroll_frame.scroll_tag.0.0, 0));
1728+
1729+
// additionally push the hit tag of the frame if there is any
1730+
if let Some(hit_tag) = scroll_frame.frame.tag {
1731+
builder.push_hit_test(&WrCommonItemProperties {
1732+
clip_rect: WrLayoutRect::new(
1733+
WrLayoutPoint::new(0.0, 0.0),
1734+
WrLayoutSize::new(scroll_frame.frame.size.width, scroll_frame.frame.size.height),
1735+
),
1736+
spatial_id: scroll_frame_clip_info.spatial_id,
1737+
clip_id: scroll_frame_clip_info.clip_id,
1738+
flags: WrPrimitiveFlags::empty(),
1739+
}, (hit_tag.0, 0));
1740+
}
1741+
17151742
for child in scroll_frame.frame.children {
17161743
push_display_list_msg(
17171744
document_id,

0 commit comments

Comments
 (0)