bevy_ui_builders/
lib.rs

1//! # Bevy UI Builders
2//!
3//! Declarative UI builders for Bevy.
4//!
5//! ## Example
6//!
7//! ```ignore
8//! use bevy_ui_builders::*;
9//!
10//! ButtonBuilder::new("Click Me")
11//!     .style(ButtonStyle::Primary)
12//!     .build(commands);
13//! ```
14
15#![warn(missing_docs)]
16
17// Re-export Bevy UI prelude for convenience
18pub use bevy::prelude::*;
19use bevy_plugin_builder::define_plugin;
20
21// Core modules
22mod styles;
23mod systems;
24mod utils;
25pub mod relationships;
26
27// Individual builder imports
28#[cfg(feature = "button")]
29pub mod button;
30#[cfg(feature = "slider")]
31pub mod slider;
32#[cfg(feature = "form")]
33pub mod form;
34#[cfg(feature = "dialog")]
35pub mod dialog;
36#[cfg(feature = "text_input")]
37pub mod text_input;
38#[cfg(feature = "progress")]
39pub mod progress;
40#[cfg(feature = "label")]
41pub mod label;
42#[cfg(feature = "panel")]
43pub mod panel;
44#[cfg(feature = "separator")]
45pub mod separator;
46
47// Future modules (not implemented yet)
48// #[cfg(feature = "tooltip")]
49// pub mod tooltip;
50
51// Public exports
52pub use styles::{ButtonStyle, ButtonSize, colors, dimensions};
53pub use systems::cleanup::{despawn_entities, despawn_ui_entities};
54pub use systems::hover::HoverPlugin;
55pub use relationships::{
56    BelongsToDialog, DialogElements,
57    SliderPart, SliderParts,
58    BelongsToForm, FormFields,
59    InButtonGroup, ButtonGroupMembers,
60    PanelContent, PanelContents,
61    TextInputPart, TextInputParts,
62    ProgressBarPart, ProgressBarParts,
63    UIRelationshipsPlugin,
64};
65
66// Builder exports based on features
67#[cfg(feature = "button")]
68pub use button::{
69    ButtonBuilder, StyledButton,
70    primary_button, secondary_button, success_button, danger_button, ghost_button,
71};
72
73#[cfg(feature = "slider")]
74pub use slider::{SliderBuilder, Slider, SliderHandle, SliderTrack, ValueFormat};
75
76#[cfg(feature = "form")]
77pub use form::{FormBuilder, FieldType, ValidationRule};
78
79#[cfg(feature = "dialog")]
80pub use dialog::{DialogBuilder, DialogButtonEvent, DialogType, DialogOverlay};
81
82#[cfg(feature = "text_input")]
83pub use text_input::{TextInputBuilder, InputFilter, InputTransform, FocusGroupId, text_input};
84
85#[cfg(feature = "progress")]
86pub use progress::{ProgressBarBuilder, ProgressBar, ProgressBarStyle, progress};
87
88#[cfg(feature = "label")]
89pub use label::{LabelBuilder, Label, LabelStyle, label};
90
91#[cfg(feature = "panel")]
92pub use panel::{PanelBuilder, Panel, PanelStyle, panel};
93
94#[cfg(feature = "separator")]
95pub use separator::{SeparatorBuilder, Separator, SeparatorStyle, Orientation, separator};
96
97/// Prelude module for convenient imports
98pub mod prelude {
99    #[doc(hidden)]
100    pub use crate::{
101        despawn_ui_entities, despawn_entities,
102    };
103
104    #[cfg(feature = "button")]
105    pub use crate::{ButtonBuilder, ButtonStyle, ButtonSize};
106
107    #[cfg(feature = "slider")]
108    pub use crate::{SliderBuilder, ValueFormat};
109
110    #[cfg(feature = "form")]
111    pub use crate::{FormBuilder, FieldType, ValidationRule};
112
113    #[cfg(feature = "dialog")]
114    pub use crate::{DialogBuilder, DialogType};
115
116    #[cfg(feature = "text_input")]
117    pub use crate::{TextInputBuilder, InputFilter};
118
119    #[cfg(feature = "progress")]
120    pub use crate::{ProgressBarBuilder, ProgressBarStyle};
121
122    #[cfg(feature = "label")]
123    pub use crate::{LabelBuilder, LabelStyle};
124
125    #[cfg(feature = "panel")]
126    pub use crate::{PanelBuilder, PanelStyle};
127
128    #[cfg(feature = "separator")]
129    pub use crate::{SeparatorBuilder, Orientation};
130}
131
132define_plugin!(UiBuilderPlugin {
133    plugins: [HoverPlugin, UIRelationshipsPlugin],
134    custom_init: |app: &mut App| {
135        #[cfg(feature = "button")]
136        app.add_plugins(button::ButtonPlugin);
137
138        #[cfg(feature = "slider")]
139        app.add_plugins(slider::SliderPlugin);
140
141        #[cfg(feature = "dialog")]
142        app.add_plugins(dialog::DialogPlugin);
143
144        #[cfg(feature = "text_input")]
145        app.add_plugins(text_input::TextInputPlugin);
146
147        #[cfg(feature = "progress")]
148        app.add_plugins(progress::ProgressBarPlugin);
149    }
150});