Rename method to is_over
This commit is contained in:
parent
d470467718
commit
be860508a9
5 changed files with 13 additions and 37 deletions
|
|
@ -652,11 +652,7 @@ mod toast {
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contains_cursor(
|
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
|
||||||
&self,
|
|
||||||
layout: Layout<'_>,
|
|
||||||
cursor_position: Point,
|
|
||||||
) -> bool {
|
|
||||||
layout
|
layout
|
||||||
.children()
|
.children()
|
||||||
.any(|layout| layout.bounds().contains(cursor_position))
|
.any(|layout| layout.bounds().contains(cursor_position))
|
||||||
|
|
|
||||||
|
|
@ -90,12 +90,8 @@ where
|
||||||
mouse::Interaction::Idle
|
mouse::Interaction::Idle
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the [`Overlay`] contains the cursor
|
/// Returns true if the cursor is over the [`Overlay`]
|
||||||
fn contains_cursor(
|
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
|
||||||
&self,
|
|
||||||
layout: Layout<'_>,
|
|
||||||
cursor_position: Point,
|
|
||||||
) -> bool {
|
|
||||||
layout.bounds().contains(cursor_position)
|
layout.bounds().contains(cursor_position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,13 +116,9 @@ where
|
||||||
self.overlay.operate(layout, renderer, operation);
|
self.overlay.operate(layout, renderer, operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the [`Overlay`] contains the cursor
|
/// Returns true if the cursor is over the [`Element`]
|
||||||
pub fn contains_cursor(
|
pub fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
|
||||||
&self,
|
self.overlay.is_over(layout, cursor_position)
|
||||||
layout: Layout<'_>,
|
|
||||||
cursor_position: Point,
|
|
||||||
) -> bool {
|
|
||||||
self.overlay.contains_cursor(layout, cursor_position)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,11 +258,7 @@ where
|
||||||
.draw(renderer, theme, style, layout, cursor_position)
|
.draw(renderer, theme, style, layout, cursor_position)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contains_cursor(
|
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
|
||||||
&self,
|
self.content.is_over(layout, cursor_position)
|
||||||
layout: Layout<'_>,
|
|
||||||
cursor_position: Point,
|
|
||||||
) -> bool {
|
|
||||||
self.content.contains_cursor(layout, cursor_position)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,17 +152,11 @@ where
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contains_cursor(
|
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
|
||||||
&self,
|
|
||||||
layout: Layout<'_>,
|
|
||||||
cursor_position: Point,
|
|
||||||
) -> bool {
|
|
||||||
self.children
|
self.children
|
||||||
.iter()
|
.iter()
|
||||||
.zip(layout.children())
|
.zip(layout.children())
|
||||||
.any(|(child, layout)| {
|
.any(|(child, layout)| child.is_over(layout, cursor_position))
|
||||||
child.contains_cursor(layout, cursor_position)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ where
|
||||||
let base_cursor = if manual_overlay
|
let base_cursor = if manual_overlay
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.contains_cursor(Layout::new(&layout), cursor_position)
|
.is_over(Layout::new(&layout), cursor_position)
|
||||||
{
|
{
|
||||||
// TODO: Type-safe cursor availability
|
// TODO: Type-safe cursor availability
|
||||||
Point::new(-1.0, -1.0)
|
Point::new(-1.0, -1.0)
|
||||||
|
|
@ -508,10 +508,8 @@ where
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if overlay.contains_cursor(
|
if overlay.is_over(Layout::new(layout), cursor_position)
|
||||||
Layout::new(layout),
|
{
|
||||||
cursor_position,
|
|
||||||
) {
|
|
||||||
overlay_interaction
|
overlay_interaction
|
||||||
} else {
|
} else {
|
||||||
base_interaction
|
base_interaction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue