• 简体中文
  • RUST + LVGL / WEBASSEMBLY

    组件预览

    通过工作台侧栏切换分类,操作控件,查看布局和动画。浏览器版与桌面版使用同一套 Rust 视图。

    查看当前分类的 Rust 源码 rs_lvgl_ui/examples/studio/pages.rs:65

    这段代码参与编译上方画面,共用的辅助函数与状态位于 studio.rs。可以在演练场中直接试写支持的 UI 代码;修改完整工作台源码时,使用其中的本地编译模式。

    rs_lvgl_ui/examples/studio/pages.rs:65
    fn overview(app: &Studio, theme: &Theme) -> View<StudioAction> {
        let plot = card(
            "A live workspace",
            "Synthetic signal / last 12 samples",
            theme,
        )
        .width(percent(64))
        .height(px(326))
        .child(studio_row().children([
            metric("84.2", "Signal strength", ORANGE, theme),
            metric("12", "Sample points", TEAL, theme),
        ]))
        .child(signal_chart(134));
        let control = card("Try the controls", "Changes carry between pages.", theme)
            .width(percent(34))
            .height(px(326))
            .child(
                studio_row()
                    .justify_content(FlexAlign::SpaceBetween)
                    .align_items(ItemAlign::Center)
                    .align_content(FlexAlign::Center)
                    .child(metric(
                        &format!("{}%", app.value),
                        "Output level",
                        theme.text,
                        theme,
                    ))
                    .child(
                        switch(app.enabled)
                            .focusable(true)
                            .on_value_changed(|v| StudioAction::Enabled(v != 0)),
                    ),
            )
            .child(
                slider(0, 100, app.value)
                    .key(Key::Named("overview-slider"))
                    .style(full(12))
                    .focusable(true)
                    .on_value_changed(StudioAction::Value),
            )
            .child(primary("Explore components", StudioAction::Page(1), theme).style(full(44)))
            .child(text("Touch, click or use Tab + Enter.", theme));
        studio_column()
            .child(studio_row().children([plot, control]))
            .child(
                studio_row().children([
                    third(
                        card("Compose", "Small nodes. Complete interfaces.", theme),
                        242,
                    )
                    .child(
                        spans([
                            Span::new("App").color(ORANGE),
                            Span::new("  /  View  /  "),
                            Span::new("Ui").color(TEAL),
                        ])
                        .style(full(40).font(Font::montserrat_20())),
                    )
                    .child(action_button(
                        "Open composition",
                        StudioAction::Page(7),
                        theme,
                    )),
                    third(
                        card("Create", "Pixels, motion and vector media.", theme),
                        242,
                    )
                    .child(studio_row().children([
                        rs_lvgl_ui::image(sample_image(false)),
                        text("Made for your device.", theme),
                    ]))
                    .child(action_button("Open media", StudioAction::Page(5), theme)),
                    third(
                        card("Connect", "A native engine, a Rust workflow.", theme),
                        242,
                    )
                    .child(
                        studio_row().height(px(38)).children([
                            led(TEAL)
                                .width(px(18))
                                .height(px(18))
                                .radius(9)
                                .shadow_width(0),
                            text("LVGL 9.6 / native rendering", theme),
                        ]),
                    )
                    .child(action_button(
                        "Open a dialog",
                        StudioAction::Dialog(true),
                        theme,
                    )),
                ]),
            )
    }

    十一个分类覆盖基础控件、文本与拼音输入、图表、布局、GIF/Lottie、画布动画、对话框、导航和原生控件,以及控件与图表深度示例。通过画布内侧栏切换分类,下方源码会同步更新。

    组件工作台使用预编译 WebAssembly,静态网站也能运行。演练场支持在浏览器中修改一部分 Rust 语法,也提供可选的本地完整编译模式。浏览器画布展示 LVGL 的渲染与交互,设备驱动和物理屏幕仍在对应硬件上验证。