simple-window

Crates.iosimple-window
lib.rssimple-window
version0.2.4
sourcesrc
created_at2024-05-10 11:55:54.485751
updated_at2024-07-17 19:35:16.942171
descriptionA simple, cross-platform window creation library.
homepage
repositoryhttps://github.com/berylllium/simple-window
max_upload_size
id1235936
size45,789
berry (berylllium)

documentation

README

simple_window - Simple cross-platform windowing library.

simple_window is a simple, lightweight, cross-platform library to create and query windows.

NOTE: The library currently only supports GNU/Linux + X11 and Windows. Support for Wayland is planned in the future.

Basic Usage

use simple_window::{Window, WindowEvent, WindowInputEvent};
 
fn main() {
    let mut is_running = true;
 
    let mut window = Window::new("Example Window", 200, 200, 400, 600);
 
    while is_running {
        window.poll_messages(|event| {
            match event {
                WindowEvent::Close => is_running = false,
                WindowEvent::Resize(width, height) => println!("Window resized: {}, {}", width, height),
                WindowEvent::Input(event) => match event {
                    WindowInputEvent::MouseMove(x, y) => println!("Mouse moved!: {}, {}", x, y),
                    WindowInputEvent::KeyDown(key) => println!("Key pressed: {}", key.as_str()),
                    WindowInputEvent::KeyUp(key) => println!("Key released: {}", key.as_str()),
                    WindowInputEvent::MouseWheelMove(dz) => println!("Mouse wheel {}", if dz > 0 { "up" } else { "down" }),
                    WindowInputEvent::MouseDown(button) => println!("Mouse {} down.", button.as_str()),
                    WindowInputEvent::MouseUp(button) => println!("Mouse {} up.", button.as_str()),
                },
            }
        });
    }
}

Support

This library is intended to support only GNU/Linux & Windows. I have no intenion whatsoever of adding support for MacOS, but I am open to pull requests.

Documentation

Please visit the docs.rs page for documentation.

Commit count: 8

cargo fmt