Crate winit_app

Crate winit_app 

Source
Expand description

This library helps get started with the winit library , the rust windowing toolkit to get started.

§Usage

Create a new winit application using this library to get started.

use winit::{event::WindowEvent, window::WindowAttributes};
use winit_app::{AppWindowEvent, Application};

fn launch_app() -> Result<(), Box<dyn std::error::Error>> {
    let winit_app = Application::new();

    winit_app.run(
       WindowAttributes::default().with_title("Sample"),
       |app_window_event| match app_window_event {
           AppWindowEvent::NewWindow(_window) => {
               // TODO: Do something with this window
                
           }
           AppWindowEvent::OnWindowEvent(event, event_loop) => match event {
               WindowEvent::CloseRequested => {
                  // Just a default handler to exit the event_loop when window is being closed  
                   event_loop.exit();
               }
               _ => {
                   // Handle all other window events
               }
           },
       },
   )?;
   Ok(())
}

Structs§

Application
Create a new winit application.

Enums§

AppWindowEvent
AppWindowEvent represents the event emitted by Application based on the listener interface
WinitAppError
WinitAppError indicates the possible errors from the winit framework

Type Aliases§

WinitAppResult