orzegui

Crates.ioorzegui
lib.rsorzegui
version0.1.0
created_at2025-10-11 02:37:30.832765+00
updated_at2025-10-11 02:37:30.832765+00
descriptionA proc-macro to automatically generate egui UI from struct fields
homepage
repository
max_upload_size
id1877770
size132,437
(MDZZDYXCMDZZDYXC)

documentation

https://docs.rs/orzegui

README

EguiWidget - Zero-Cost UI Generation for egui

A procedural macro that automatically generates egui UI from Rust structs using attribute annotations. Zero runtime overhead — everything is generated at compile time.

UI Preview

🚀 Quick Start

Add #[derive(EguiWidget)] to your configuration struct and instantly generate a full egui UI!

Example Struct

use orz_egui::EguiWidget;
#[derive(EguiWidget, Default)]
struct MySettings {
    author: String,
    #[egui(text = "Email", width = 150.0, min_width = 100.0)]
    email: String,
    #[egui(text = "NAME")]
    name: String,
    #[egui(radio, choices = "Red,Green,Blue")]
    color: String,
    #[egui(checks, choices = "Red,Green,Blue")]
    lover_color: Vec<String>,
    #[egui(text = "Ok")]
    ok: bool,
    #[egui(text = "SPEED")]
    speed: f32,
}

Use in Your App

fn main(){
    let options = eframe::NativeOptions::default();
    let mut settings = MySettings::default();
    eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
        egui::Window::new("Settings").show(ctx, |ui| {
            settings.ui(ui);
        });
    });
}

🧩 Supported UI Controls

Field Type Control Attributes
String Text Input text="Label", width, min_width
f32 Drag Value text="Label", speed (optional)
bool Checkbox text="Label"
String + radio Radio Buttons choices="A,B,C"
Vec<String> + checks Checkboxes choices="A,B,C"

📋 Configuration Fields

Field Type Description
author String Author name
email String Email address with fixed input width
name String Name, displayed with label "NAME"
color String Primary color selection (Red/Green/Blue)
lover_color Vec<String> Multi-select favorite colors
ok bool Toggle switch
speed f32 Speed adjustment (0.0 ~ 1.0)

🛠️ Installation

Add to your Cargo.toml:

[dependencies]
orzegui = "0.1.0"

📦 Suggested Cargo.toml

If you're using this macro in your app:

[package]
name = "my-egui-app"
version = "0.1.0"
edition = "2021"

[dependencies]
egui = "^0.31"
eframe = "^0.31"  # For desktop apps
orzegui = "0.1.0"  # Local path or from crates.io

📎 Screenshot

Settings Panel

Tip: Save your actual UI screenshot as screenshot.png.


Generated by EguiWidget • 2025


---

### ✅ 英文版 `Cargo.toml` (for the macro crate)

```toml
[package]
name = "egui-widget"
version = "0.1.0"
description = "A proc-macro to automatically generate egui UI from struct fields"
license = "MIT"
authors = ["Your Name <your.email@example.com>"]
repository = "https://github.com/yourname/egui-widget"
documentation = "https://docs.rs/egui-widget"
keywords = ["egui", "gui", "procedural-macro", "ui", "derive"]
categories = ["gui", "development-tools::procedural-macros"]
edition = "2021"
readme = "README.md"

[lib]
proc-macro = true

[dependencies]
syn = { version = "2.0", features = ["full"] }
quote = "1.0"
proc-macro2 = "1.0"

[dev-dependencies]
eframe = "0.22"

优点

  • 专业英文术语,适合国际开源项目
  • 结构清晰,易于理解
  • 包含完整示例和集成说明
  • 支持未来扩展(如 ComboBox, Enum 等)

需要我生成一个 examples/demo.rs 或打包为模板仓库(template repo)吗?我可以立即提供完整项目结构。

Commit count: 0

cargo fmt