winr 0.0.1

A cross-platform windowing framework.
docs.rs failed to build winr-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

winr

winr is a cross-platform windowing framework.

Aspiration

The aspiration of winr is to be a very fast and lightweight windowing framework. Dynamic dispatch usage is kept to a minimum except where absolutely necessary.

State

winr is currently in early days of maturity with high levels of refactoring being expected. Ideas and input for the future of winr is welcomed as it grows.

Platforms

Currently only Windows is supported. MacOS and Wayland implementations are mostly implemented and will be released soon.

Example

use winr::*;
use winr::application::*;
use winr::window::*;

struct MyWindow;

impl WindowCallbacks for MyWindow {
    type Error = WingmanError;
}

#[derive(Default)]
struct MyApp {
    window_main: Option<WindowPtr<MyWindow>>,
}

impl ApplicationCallbacks for MyApp {
    type Exit = ();
    type Error = WingmanError;

    fn on_startup(
        this: &mut ApplicationRunning<Self>,
        event: &EventStartup,
    ) -> Result<(), Self::Error> {
        let mut window = window()
            .with_callbacks(MyWindow)
            .with_title("wingman [normal_window]")
            .with_style(Windowed::default().with_extent(Extent::new(800, 600)))
            .build(this)?;
        window.show()?;

        this.window_main = Some(window);

        Ok(())
    }

    fn on_events_handled(
        this: &mut ApplicationRunning<Self>,
        event: &EventHandled,
    ) -> Result<(), Self::Error> {
        if let Some(window) = &this.window_main
            && !window.is_closed()
        {
            this.wait_for_events()
        } else {
            this.shutdown()
        }
    }
}

fn main() -> Result<(), WingmanError> {
    application()
        .with_callbacks(MyApp::default())
        .build()?
        .run()
}