1 stable release
new 1.0.0 | Feb 14, 2025 |
---|
#823 in GUI
103 downloads per month
57KB
618 lines
Installation
Add this to your Cargo.toml
:
[dependencies]
luigi-rs = "1.0.0"
or run this command:
cargo add luigi-rs
Features
- Safe Rust interface for Luigi UI library
- Zero-cost abstractions over the C API
- Windows and Linux support
Example
Here's a simple counter application:
use luigi_rs::{self as ui, Button, Label, Panel, Window};
use std::cell::RefCell;
use std::rc::Rc;
fn main() {
ui::init();
let window = Window::new("Counter", 200, 150, 0).expect("Failed to create window");
let panel = Panel::new(&window, ui::UI_PANEL_WHITE).expect("Failed to create panel");
let label = Rc::new(RefCell::new(Label::new(&panel, 0, "0").expect("Failed to create label")));
let count = Rc::new(RefCell::new(0));
let buttons = Panel::new(&panel, ui::UI_PANEL_HORIZONTAL).expect("Failed to create buttons panel");
// Create minus button
let label_clone = label.clone();
let count_clone = count.clone();
let minus = Button::new(&buttons, 0, "-").expect("Failed to create minus button");
minus.invoke(Box::new(move || {
*count_clone.borrow_mut() -= 1;
label_clone.borrow_mut().set_content(&count_clone.borrow().to_string());
}));
// Create plus button
let plus = Button::new(&buttons, 0, "+").expect("Failed to create plus button");
plus.invoke(Box::new(move || {
*count.borrow_mut() += 1;
label.borrow_mut().set_content(&count.borrow().to_string());
}));
ui::message_loop();
}
Building from Source
-
First, ensure you have the bindgen requirements installed.
-
On Linux, install required X11 development packages:
sudo apt-get install libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev
- Clone the repository:
git clone https://github.com/ankddev/luigi-rs
cd luigi-rs
- Build the project:
cargo build
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork it (https://github.com/ankddev/luigi-rs/fork)
- Create your feature branch (
git checkout -b feature/something
) - Commit your changes (
git commit -am 'Add something'
) - Push to the branch (
git push origin feature/something
) - Create a new Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Acknowledgments
- Luigi UI library by nakst
- All contributors to this project
Dependencies
~0–3.5MB
~53K SLoC