#widgets #style #fit #api #beginner #learn

rusty_gui

This is a simple GUI library for Rust

2 releases

new 0.1.4 Jan 5, 2025
0.1.3 Jan 5, 2025
0.1.2 Dec 18, 2024
0.1.1 Dec 9, 2024
0.1.0 Nov 30, 2024

#323 in GUI

Download history 113/week @ 2024-11-27 136/week @ 2024-12-04 40/week @ 2024-12-11 150/week @ 2024-12-18 206/week @ 2025-01-01

432 downloads per month

Apache-2.0

100KB
2.5K SLoC

Rusty GUI

rusty_gui aims to create a low entry threshold Rust GUI framework. It mostly uses a simplified API style, making it more intuitive and simple to use. It is very friendly to Rust's beginners, and you can even learn some programming ideas in Rust that are different from other languages through it. It also can help beginners write graphical programs to enhance their skills.

Features

  • Low Entry Threshold: rusty_gui is designed to be easy to use for beginners. It uses a simplified API style, making it more intuitive and simple to use.
  • Easy to learn and use: rusty_gui is designed to be easy to learn and use. It is very friendly to Rust's beginners, and you can even learn some programming ideas in Rust that are different from other languages through it.
  • Customizable: rusty_gui is designed to be customizable. You can easily create your own widgets, themes, and other components to fit your needs.

Usage

To use rusty_gui, add the following to your Cargo.toml file:

[dependencies]
rusty_gui = "0.1"

Or use the following command to add it to your project:

cargo add rusty_gui

Demo

Here is a simple demo of rusty_gui:

use rusty_gui::*;

struct MyWindow {
    this: Window,
    content: String,
}

default_as_window!(MyWindow);

impl Drawable for MyWindow {
    fn draw(&mut self, canvas: &mut Canvas) {
        canvas.clear(Color::WHITE);
        let style = FontStyle {
            size: 24,
            ..FontStyle::default()
        };
        canvas.set_font(&Font::new(style));
        canvas.rect_text(self.this.rect(), &self.content, TextAlign::Center);
    }
}

impl EventListener for MyWindow {
    fn on_event(&mut self, event: &Event) {
        let _ = event;
    }
}

impl MyWindow {
    fn new(content: &str) -> Self {
        Self {
            this: Window::default(),
            content: String::from(content),
        }
    }

    fn create(content: &str, rect: Rect) -> Widget<Self> {
        let mut ret = Widget::new(Self::new(content));
        ret.this = Window::new("MyWindow", rect, None, &ret);
        ret
    }
}

fn main() {
    let app = Application::new(true);

    let window = MyWindow::create("Hello, This is Rusty GUI!", rect!(50, 50, 800, 600));
    window.as_window().show();

    app.exec();
}

License

This library is licensed under the Apache 2.0 license.

More Information

If you want to learn more about rusty_gui, you can read the learning guide. If you want to contribute to rusty_gui, you can fork the repository and submit a pull request. Such as:

  • Adding new widgets or features.
  • Fixing bugs.
  • Improving performance.

If you have any questions or concerns, you can open an issue on the repository. You should add a prefix label to indicate your main requirements. Such as:

  • [question] How to use the library?
  • [bug] The library does not work properly.
  • [enhancement] Add a new feature to the library.

For more information, please visit the GitHub repository.

Dependencies

~225KB