#window-creation #x11 #cross-platform #windowing #query

simple-window

A simple, cross-platform window creation library

5 releases

0.2.4 Jul 17, 2024
0.2.3 Jul 17, 2024
0.1.1 May 21, 2024

#960 in GUI

Download history 554/week @ 2024-07-14 47/week @ 2024-07-21 41/week @ 2024-07-28 37/week @ 2024-09-15 62/week @ 2024-09-29 2/week @ 2024-10-06

101 downloads per month

LGPL-3.0-only

42KB
917 lines

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.

Dependencies

~0.1–8.5MB
~69K SLoC