Decouple mouse::Interaction from UserInterface::draw

This commit is contained in:
Héctor Ramón Jiménez 2025-05-02 23:11:47 +02:00
parent 87afd5b79d
commit 301aac794b
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
6 changed files with 171 additions and 187 deletions

View file

@ -268,7 +268,7 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
renderer,
);
let _ = interface.update(
let (state, _) = interface.update(
&[Event::Window(
window::Event::RedrawRequested(
Instant::now(),
@ -280,7 +280,21 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
&mut Vec::new(),
);
let mouse_interaction = interface.draw(
// Update the mouse cursor
if let user_interface::State::Updated {
mouse_interaction,
..
} = state
{
window.set_cursor(
conversion::mouse_interaction(
mouse_interaction,
),
);
}
// Draw the interface
interface.draw(
renderer,
&Theme::Dark,
&renderer::Style::default(),
@ -297,11 +311,6 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
// Present the frame
frame.present();
// Update the mouse cursor
window.set_cursor(conversion::mouse_interaction(
mouse_interaction,
));
}
Err(error) => match error {
wgpu::SurfaceError::OutOfMemory => {