dear-app

Crates.iodear-app
lib.rsdear-app
version0.8.0
created_at2025-10-06 16:36:07.132654+00
updated_at2026-01-02 18:20:42.805795+00
descriptionConvenient Dear ImGui application runner for dear-imgui-rs (Winit + WGPU, docking, themes, add-ons)
homepagehttps://github.com/Latias94/dear-imgui-rs
repositoryhttps://github.com/Latias94/dear-imgui-rs
max_upload_size
id1870401
size135,040
Latias94 (Latias94)

documentation

README

dear-app

Crates.io Documentation

Convenient Dear ImGui application runner for dear-imgui-rs, bundling Winit + WGPU setup into a tiny API. It hides boilerplate, exposes ergonomic callbacks, and can initialize popular add-ons (ImPlot, ImNodes, ImPlot3D) behind feature flags.

Features

  • Winit + WGPU app bootstrap with sensible defaults
  • Per-frame UI closure (run_simple) and a configurable builder (AppBuilder)
  • Optional add-ons via features: implot, imnodes, implot3d
  • Docking helpers, theme presets, INI path selection
  • Lifecycle callbacks: setup/style/fonts/post-init/event/exit

Quick Start

[dependencies]
dear-app = "0.8"

# Optional add-ons (enable any subset)
dear-app = { version = "0.8", features = ["implot", "imnodes", "implot3d"] }

Minimal usage:

use dear_app::run_simple;
use dear_imgui_rs::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    run_simple(|ui| {
        ui.window("Hello")
            .size([360.0, 160.0], Condition::FirstUseEver)
            .build(|| ui.text("Hello from dear-app!"));
    })?;
    Ok(())
}

Tip: pass .opened(&mut open) if you want a title-bar close button (X), and stop submitting the window when open == false.

Builder with add-ons and docking/theme presets:

use dear_app::{AppBuilder, AddOnsConfig, RunnerConfig, Theme};
use dear_imgui_rs as imgui;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cfg = RunnerConfig { theme: Some(Theme::Dark), ..Default::default() };
    let addons = AddOnsConfig::auto(); // enable compiled add-ons

    AppBuilder::new()
        .with_config(cfg)
        .with_addons(addons)
        .on_frame(|ui: &imgui::Ui, addons| {
            ui.window("App").build(|| {
                ui.text("Docking and WGPU are ready!");

                #[cfg(feature = "implot")]
                if let Some(pc) = addons.implot { let plot = ui.implot(pc); let _ = plot; }

                #[cfg(feature = "imnodes")]
                if let Some(nc) = addons.imnodes { let _ = nc; /* ui.imnodes(nc) ... */ }

                #[cfg(feature = "implot3d")]
                if let Some(pc3) = addons.implot3d { let _ = pc3; }
            });
        })
        .run()?;

    Ok(())
}

Notes

  • Backends: Uses dear-imgui-winit and dear-imgui-wgpu internally.
  • Fonts/FreeType: Configure in the on_fonts callback; FreeType can be enabled via dear-imgui-rs/freetype.
Commit count: 274

cargo fmt