Crates.io | simple-window |
lib.rs | simple-window |
version | 0.2.4 |
source | src |
created_at | 2024-05-10 11:55:54.485751 |
updated_at | 2024-07-17 19:35:16.942171 |
description | A simple, cross-platform window creation library. |
homepage | |
repository | https://github.com/berylllium/simple-window |
max_upload_size | |
id | 1235936 |
size | 45,789 |
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.
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()),
},
}
});
}
}
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.
Please visit the docs.rs page for documentation.