Skip to main content

wde_editor/
lib.rs

1//! A simple editor plugin on top of `wde_egui` that provides an editor interface.
2//!
3//! # Example
4//! To create as an example a top-level menu item "Terrain" with a submenu "Paint", you can do the following:
5//! ```rust
6//! # use bevy::prelude::*;
7//! # use wde_editor::prelude::*;
8//! fn update(ctx: Res<UIContext>, mut ui_menu: ResMut<UIMenu>) {
9//!     UIWindow::new("Paint Debug")
10//!         .open(ui_menu.clicked_mut("Terrain/Paint"))
11//!         .show(&ctx.0, |_ui| {
12//!              // Terrain paint functionality goes here...
13//!         });
14//! }
15//! ```
16//! Menus are grouped by topic: `Engine` (core tools), `Render`, `Camera`, `Terrain`, and `Game` for the project's
17//! own windows (see [`UIMenu`](prelude::UIMenu)).
18//!
19//! To see all the available UI components and how to use them, check out the [`egui`] documentation, which is the underlying UI library used by `wde_egui` and thus also by this editor plugin.
20//!
21//! # Default Panels
22//! This crate also provides basic panels such as ones for inspecting entities and assets, and the editor's
23//! [theme](prelude::ui_theme), installed on the egui context.
24
25use bevy::prelude::*;
26use wde_egui::{EguiPlugin, prelude::EguiContext};
27
28use crate::{panels::PanelsPlugin, ui::EditorUIMenu};
29
30mod panels;
31pub mod theme;
32mod ui;
33mod ui_textures;
34
35#[doc(hidden)]
36pub mod prelude {
37    // Re-export egui types for easier access in editor code
38    pub use wde_egui::prelude::EguiContext as UIContext;
39
40    // Re-export editor UI types
41    pub use wde_egui::prelude::egui::{
42        Button, Checkbox, CollapsingHeader, Color32, ColorImage, ComboBox, DragValue, FontId,
43        Label, ScrollArea, Separator, Slider, TextEdit
44    };
45    pub mod ui {
46        pub use wde_egui::prelude::*;
47    }
48
49    // Re-export editor types
50    pub use super::panels::FrameDataOverlayConfig;
51    pub use super::theme as ui_theme;
52    pub use super::ui::{
53        EditorMenuBarSet, EngineUiConfig, EngineUiSet, MenuBarVisibility, UIMenu, UIWindow
54    };
55    pub use super::ui_textures::{UITextureHandle, UITextures};
56}
57
58pub struct EditorPlugin;
59impl Plugin for EditorPlugin {
60    fn build(&self, app: &mut App) {
61        app.add_plugins((EguiPlugin, EditorUIMenu, PanelsPlugin));
62        theme::install(&app.world().resource::<EguiContext>().0);
63    }
64}