#egui #immediate #imgui #gamedev

egui_dpanel

Dynamic Panels for egui

1 unstable release

0.1.0 Dec 8, 2024

#590 in GUI

Download history 40/week @ 2024-12-02 101/week @ 2024-12-09

141 downloads per month

MIT/Apache

28KB
495 lines

Dynamic Panels

This crate allows creating dynamic panels in egui that are displayed with different configuration depending on a given choice function. A very simple example:

let dpanel = DynamicPanel::new("bla");
let dpanel = dpanel.with_panels(vec![
    SinglePanelCfg::left().into(),
    SinglePanelCfg::bottom().into(),
]);
let dpanel = 
    dpanel.with_choice_function(|ctx| {
        if ctx.input(|i| i.screen_rect).width() < 500. {
            1
        } else {
            0
        }
    });
dpanel.show_dynamic(ctx, |ui| {
    ui.label("This moves!");
});

This will show a panel to the left if the context width is >= 500., otherwise it will show a panel at the bottom.

Dependencies

~4–8.5MB
~85K SLoC