Rename method to is_over

This commit is contained in:
Cory Forsstrom 2023-01-17 17:20:53 -08:00
parent d470467718
commit be860508a9
No known key found for this signature in database
GPG key ID: 1DFE170A4415C9F5
5 changed files with 13 additions and 37 deletions

View file

@ -116,13 +116,9 @@ where
self.overlay.operate(layout, renderer, operation);
}
/// Whether the [`Overlay`] contains the cursor
pub fn contains_cursor(
&self,
layout: Layout<'_>,
cursor_position: Point,
) -> bool {
self.overlay.contains_cursor(layout, cursor_position)
/// Returns true if the cursor is over the [`Element`]
pub fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
self.overlay.is_over(layout, cursor_position)
}
}
@ -262,11 +258,7 @@ where
.draw(renderer, theme, style, layout, cursor_position)
}
fn contains_cursor(
&self,
layout: Layout<'_>,
cursor_position: Point,
) -> bool {
self.content.contains_cursor(layout, cursor_position)
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
self.content.is_over(layout, cursor_position)
}
}

View file

@ -152,17 +152,11 @@ where
});
}
fn contains_cursor(
&self,
layout: Layout<'_>,
cursor_position: Point,
) -> bool {
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
self.children
.iter()
.zip(layout.children())
.any(|(child, layout)| {
child.contains_cursor(layout, cursor_position)
})
.any(|(child, layout)| child.is_over(layout, cursor_position))
}
}