Capture relevant events in `image::Viewer`
This commit is contained in:
parent
e7344d03b4
commit
c7f6b2a5c7
|
@ -209,15 +209,23 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event::Status::Captured
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
||||||
if is_mouse_over =>
|
if is_mouse_over =>
|
||||||
{
|
{
|
||||||
self.state.cursor_grabbed_at = Some(cursor_position);
|
self.state.cursor_grabbed_at = Some(cursor_position);
|
||||||
self.state.starting_offset = self.state.current_offset;
|
self.state.starting_offset = self.state.current_offset;
|
||||||
|
|
||||||
|
event::Status::Captured
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => {
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||||
self.state.cursor_grabbed_at = None
|
if self.state.cursor_grabbed_at.is_some() =>
|
||||||
|
{
|
||||||
|
self.state.cursor_grabbed_at = None;
|
||||||
|
|
||||||
|
event::Status::Captured
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::CursorMoved { position }) => {
|
Event::Mouse(mouse::Event::CursorMoved { position }) => {
|
||||||
if let Some(origin) = self.state.cursor_grabbed_at {
|
if let Some(origin) = self.state.cursor_grabbed_at {
|
||||||
|
@ -251,13 +259,15 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
self.state.current_offset = Vector::new(x, y);
|
self.state.current_offset = Vector::new(x, y);
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
event::Status::Captured
|
||||||
|
} else {
|
||||||
event::Status::Ignored
|
event::Status::Ignored
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
_ => event::Status::Ignored,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
|
|
Loading…
Reference in New Issue