Open a window using winit
This commit is contained in:
parent
e1b9d42bf1
commit
63294088ad
2 changed files with 30 additions and 2 deletions
31
src/lib.rs
31
src/lib.rs
|
|
@ -1,7 +1,7 @@
|
|||
pub use iced_wgpu::Renderer;
|
||||
pub use iced_winit::{
|
||||
button, slider, text, Align, Button, Checkbox, Color, Image, Justify,
|
||||
Length, Radio, Slider, Text,
|
||||
button, slider, text, winit, Align, Button, Checkbox, Color, Image,
|
||||
Justify, Length, Radio, Slider, Text,
|
||||
};
|
||||
|
||||
pub type Element<'a, Message> = iced_winit::Element<'a, Message, Renderer>;
|
||||
|
|
@ -19,5 +19,32 @@ pub trait UserInterface {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
window::WindowBuilder,
|
||||
};
|
||||
|
||||
let event_loop = EventLoop::new();
|
||||
|
||||
// TODO: Ask for window settings and configure this properly
|
||||
let window = WindowBuilder::new()
|
||||
.build(&event_loop)
|
||||
.expect("Open window");
|
||||
|
||||
event_loop.run(move |event, _, control_flow| match event {
|
||||
Event::EventsCleared => {
|
||||
window.request_redraw();
|
||||
}
|
||||
Event::WindowEvent {
|
||||
event: WindowEvent::CloseRequested,
|
||||
..
|
||||
} => {
|
||||
*control_flow = ControlFlow::Exit;
|
||||
}
|
||||
_ => {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
pub use iced_native::*;
|
||||
pub use winit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue