windui 0.1.0

轻量跨平台桌面 GUI:tiny-skia 渲染 + 平台原生窗口/文字(Windows: Win32+DirectWrite;macOS: Cocoa+CoreText)
Documentation
//! 下拉选择 Dropdown 示例。
//!
//! 运行:cargo run --release --example dropdown
//! 闭合截屏:cargo run --example dropdown -- --screenshot artifacts/dropdown.png
//! 展开截屏:cargo run --example dropdown -- --screenshot artifacts/dropdown_open.png --click 120 96

use std::cell::Cell;
use std::rc::Rc;

use windui::prelude::*;

const BG: u32 = 0xEEF1F5;

fn label(t: &str) -> Element {
    Element::label(t).font_size(13.0).fg(Color::hex(0x636E72)).height(20).width_match()
}

fn main() {
    let theme = Rc::new(Cell::new(1usize));
    let quality = Rc::new(Cell::new(0usize));

    let ui = Element::col()
        .fill()
        .bg(Color::hex(BG))
        .padding(20)
        .spacing(10)
        .child(Element::label("下拉选择").font_size(22.0).fg(Color::hex(0x1A1A2E)).height(30).width_match())
        .child(label("主题"))
        .child(Element::dropdown(vec!["跟随系统", "浅色", "深色"], theme.clone()).width(220))
        .child(label("渲染质量"))
        .child(Element::dropdown(vec!["", "", "", "极致"], quality.clone()).width(220));

    App::new("windui — 下拉选择", 320, 280)
        .bg(Color::hex(BG))
        .screenshot_from_args()
        .content(ui)
        .run();
}