Implement Widget::mouse_interaction for Slider

This commit is contained in:
Héctor Ramón Jiménez 2021-10-20 16:28:27 +07:00
parent c800fd07c3
commit 954d6349a8
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -336,6 +336,24 @@ where
});
}
fn mouse_interaction(
&self,
layout: Layout<'_>,
_viewport: &Rectangle,
cursor_position: Point,
) -> mouse::Interaction {
let bounds = layout.bounds();
let is_mouse_over = bounds.contains(cursor_position);
if self.state.is_dragging {
mouse::Interaction::Grabbing
} else if is_mouse_over {
mouse::Interaction::Grab
} else {
mouse::Interaction::default()
}
}
fn hash_layout(&self, state: &mut Hasher) {
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);