Wire mouse_motion_event
to Runtime
This commit is contained in:
parent
f6f7505b9d
commit
f007929b9c
@ -39,6 +39,19 @@ impl event::EventHandler for Game {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mouse_motion_event(
|
||||||
|
&mut self,
|
||||||
|
_context: &mut ggez::Context,
|
||||||
|
x: f32,
|
||||||
|
y: f32,
|
||||||
|
_dx: f32,
|
||||||
|
_dy: f32,
|
||||||
|
) {
|
||||||
|
self.runtime.on_event(iced::Event::Mouse(
|
||||||
|
iced::input::mouse::Event::CursorMoved { x, y },
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult {
|
fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult {
|
||||||
graphics::clear(context, [0.1, 0.2, 0.3, 1.0].into());
|
graphics::clear(context, [0.1, 0.2, 0.3, 1.0].into());
|
||||||
|
|
||||||
@ -71,9 +84,10 @@ impl event::EventHandler for Game {
|
|||||||
let renderer =
|
let renderer =
|
||||||
&mut Renderer::new(context, self.spritesheet.clone());
|
&mut Renderer::new(context, self.spritesheet.clone());
|
||||||
|
|
||||||
let ui = self.runtime.compute(content.into(), renderer);
|
let mut ui = self.runtime.compute(content.into(), renderer);
|
||||||
|
|
||||||
let cursor = ui.draw(renderer, iced::Point::new(0.0, 0.0));
|
let messages = ui.update();
|
||||||
|
let cursor = ui.draw(renderer);
|
||||||
|
|
||||||
renderer.flush();
|
renderer.flush();
|
||||||
|
|
||||||
|
@ -94,15 +94,11 @@ impl<'a, Message, Renderer> Interface<'a, Message, Renderer> {
|
|||||||
messages
|
messages
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(
|
pub fn draw(&self, renderer: &mut Renderer) -> MouseCursor {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
cursor_position: Point,
|
|
||||||
) -> MouseCursor {
|
|
||||||
let cursor = self.root.widget.draw(
|
let cursor = self.root.widget.draw(
|
||||||
renderer,
|
renderer,
|
||||||
Layout::new(self.layout),
|
Layout::new(self.layout),
|
||||||
cursor_position,
|
self.cursor_position,
|
||||||
);
|
);
|
||||||
|
|
||||||
cursor
|
cursor
|
||||||
|
Loading…
Reference in New Issue
Block a user