Skip to content

Commit

Permalink
Remove unneeded match and 'is in bounds' calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
yusdacra committed Nov 3, 2020
1 parent b1da5a4 commit f59ce87
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions native/src/widget/tooltip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,13 @@ where
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>,
) {
match event {
Event::Mouse(iced_core::mouse::Event::CursorMoved { x, y }) => {
self.state.cursor_position.x = x;
self.state.cursor_position.y = y;
if layout.bounds().contains(self.state.cursor_position) {
self.state.is_hovered = true;
} else {
self.state.is_hovered = false;
}
}
_ => (),
if layout.bounds().contains(cursor_position) {
self.state.cursor_position = cursor_position;
self.state.is_hovered = true;
} else {
self.state.is_hovered = false;
}

self.content.widget.on_event(
event,
layout,
Expand Down Expand Up @@ -119,9 +114,9 @@ where

fn overlay(
&mut self,
layout: Layout<'_>,
_layout: Layout<'_>,
) -> Option<overlay::Element<'_, Message, Renderer>> {
if layout.bounds().contains(self.state.cursor_position) {
if self.state.is_hovered {
Some(overlay::Element::new(
self.state.cursor_position,
Box::new(Overlay::new(&self.hover_content)),
Expand Down

0 comments on commit f59ce87

Please sign in to comment.