Introduce mouse_interaction method to Widget trait
This commit is contained in:
parent
7a876c8b29
commit
be97a5d502
10 changed files with 152 additions and 21 deletions
|
|
@ -1,4 +1,5 @@
|
|||
//! Create interactive, native cross-platform applications.
|
||||
use crate::mouse;
|
||||
use crate::{Error, Executor, Runtime};
|
||||
|
||||
pub use iced_winit::Application;
|
||||
|
|
@ -179,9 +180,7 @@ async fn run_instance<A, E, C>(
|
|||
&mut debug,
|
||||
));
|
||||
|
||||
// TODO
|
||||
// let mut mouse_interaction = mouse::Interaction::default();
|
||||
|
||||
let mut mouse_interaction = mouse::Interaction::default();
|
||||
let mut events = Vec::new();
|
||||
let mut messages = Vec::new();
|
||||
|
||||
|
|
@ -245,9 +244,18 @@ async fn run_instance<A, E, C>(
|
|||
}
|
||||
|
||||
debug.draw_started();
|
||||
user_interface.draw(&mut renderer, state.cursor_position());
|
||||
let new_mouse_interaction =
|
||||
user_interface.draw(&mut renderer, state.cursor_position());
|
||||
debug.draw_finished();
|
||||
|
||||
if new_mouse_interaction != mouse_interaction {
|
||||
context.window().set_cursor_icon(
|
||||
conversion::mouse_interaction(new_mouse_interaction),
|
||||
);
|
||||
|
||||
mouse_interaction = new_mouse_interaction;
|
||||
}
|
||||
|
||||
context.window().request_redraw();
|
||||
}
|
||||
event::Event::PlatformSpecific(event::PlatformSpecific::MacOS(
|
||||
|
|
@ -289,9 +297,20 @@ async fn run_instance<A, E, C>(
|
|||
debug.layout_finished();
|
||||
|
||||
debug.draw_started();
|
||||
user_interface.draw(&mut renderer, state.cursor_position());
|
||||
let new_mouse_interaction = user_interface
|
||||
.draw(&mut renderer, state.cursor_position());
|
||||
debug.draw_finished();
|
||||
|
||||
if new_mouse_interaction != mouse_interaction {
|
||||
context.window().set_cursor_icon(
|
||||
conversion::mouse_interaction(
|
||||
new_mouse_interaction,
|
||||
),
|
||||
);
|
||||
|
||||
mouse_interaction = new_mouse_interaction;
|
||||
}
|
||||
|
||||
context.resize(glutin::dpi::PhysicalSize::new(
|
||||
physical_size.width,
|
||||
physical_size.height,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue