Skip to main content

ferroui_base/rendering/composition/hit_testing/
i_composition_hit_tester.rs

1use crate::media::IntersectionResult;
2use crate::platform::{IGeometryImpl, LtrbRect};
3use crate::rendering::composition::CompositionVisual;
4use crate::Matrix;
5
6/// A kind of hit test of the composition visual tree: what is tested (a
7/// point, a geometry) and how it relates to visuals.
8pub trait ICompositionHitTester {
9    type Input: Clone;
10
11    fn transform(input: &Self::Input, matrix: Matrix) -> Self::Input;
12
13    fn hit_test(visual: &CompositionVisual, input: &Self::Input) -> IntersectionResult;
14
15    fn transformed_sub_tree_bounds_match(bounds: LtrbRect, input: &Self::Input) -> bool;
16
17    fn clipped_bounds_match(visual: &CompositionVisual, input: &Self::Input) -> bool;
18
19    fn clip_matches(clip: &dyn IGeometryImpl, input: &Self::Input) -> bool;
20}
21
22/// `result > IntersectionResult.Empty`.
23pub fn is_hit(result: IntersectionResult) -> bool {
24    (result as i32) > (IntersectionResult::Empty as i32)
25}