Skip to main content

Module submenu_builder

Module submenu_builder 

Source
Expand description

Builder framework for dropdown submenus, and the flyout every drawing toolbar menu shares.

The toolbar shows each menu in one flyout (show_flyout): a popup anchored to the button that opened it, with the theme’s menu frame, closing on an outside click or Escape. Its rows are drawn by flyout_row, so tool lists and utility menus look alike.

§Usage

use egui::Ui;
use egui_charts::icons::icons;
use egui_charts::ui::drawing_toolbar::{SubmenuBuilder, ToggleConfig};

fn cursor_menu(ui: &mut Ui, feature_enabled: &mut bool) {
    let action = SubmenuBuilder::new(ui)
        .with_width(240.0)
        .add_icon_item(&icons::CROSSHAIR, "Cross", "Cross cursor")
        .add_icon_item(&icons::DOT, "Dot", "Dot cursor")
        .add_toggle(ToggleConfig {
            label: "Enable feature".to_string(),
            value: feature_enabled,
        })
        .show();
    if let Some(action) = action {
        println!("{action:?}");
    }
}

Structs§

SubmenuBuilder
Builder for creating dropdown submenus with consistent styling.
SubmenuItem
A single item in a submenu
ToggleConfig
Configuration for a toggle checkbox at the bottom of a submenu