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// ScrollView module (always available - core functionality)
48pub mod scroll_view;
49
50// Future modules (not implemented yet)
51// #[cfg(feature = "tooltip")]
52// pub mod tooltip;
53
54// Public exports
55pub use styles::{ButtonStyle, ButtonSize, colors, dimensions};
56pub use systems::cleanup::{despawn_entities, despawn_ui_entities};
57pub use systems::hover::HoverPlugin;
58pub use scroll_view::{ScrollViewBuilder, ScrollView, ScrollConfig, ScrollDirection, ScrollViewPlugin, scroll_view};
59pub use relationships::{
60    BelongsToDialog, DialogElements,
61    SliderPart, SliderParts,
62    BelongsToForm, FormFields,
63    InButtonGroup, ButtonGroupMembers,
64    PanelContent, PanelContents,
65    TextInputPart, TextInputParts,
66    ProgressBarPart, ProgressBarParts,
67    UIRelationshipsPlugin,
68};
69
70// Builder exports based on features
71#[cfg(feature = "button")]
72pub use button::{
73    ButtonBuilder, StyledButton,
74    primary_button, secondary_button, success_button, danger_button, ghost_button,
75};
76
77#[cfg(feature = "slider")]
78pub use slider::{SliderBuilder, SliderBuilderWithMarker, Slider, SliderHandle, SliderTrack, ValueFormat};
79
80#[cfg(feature = "form")]
81pub use form::{FormBuilder, FieldType, ValidationRule};
82
83#[cfg(feature = "dialog")]
84pub use dialog::{DialogBuilder, DialogButtonEvent, DialogType, DialogOverlay};
85
86#[cfg(feature = "text_input")]
87pub use text_input::{TextInputBuilder, InputFilter, InputTransform, FocusGroupId, text_input};
88
89#[cfg(feature = "progress")]
90pub use progress::{ProgressBarBuilder, ProgressBar, ProgressBarStyle, progress};
91
92#[cfg(feature = "label")]
93pub use label::{LabelBuilder, Label, LabelStyle, label};
94
95#[cfg(feature = "panel")]
96pub use panel::{PanelBuilder, Panel, PanelStyle, panel};
97
98#[cfg(feature = "separator")]
99pub use separator::{SeparatorBuilder, Separator, SeparatorStyle, Orientation, separator};
100
101/// Prelude module for convenient imports
102pub mod prelude {
103    #[doc(hidden)]
104    pub use crate::{
105        despawn_ui_entities, despawn_entities,
106    };
107
108    #[cfg(feature = "button")]
109    pub use crate::{ButtonBuilder, ButtonStyle, ButtonSize};
110
111    #[cfg(feature = "slider")]
112    pub use crate::{SliderBuilder, ValueFormat};
113
114    #[cfg(feature = "form")]
115    pub use crate::{FormBuilder, FieldType, ValidationRule};
116
117    #[cfg(feature = "dialog")]
118    pub use crate::{DialogBuilder, DialogType};
119
120    #[cfg(feature = "text_input")]
121    pub use crate::{TextInputBuilder, InputFilter};
122
123    #[cfg(feature = "progress")]
124    pub use crate::{ProgressBarBuilder, ProgressBarStyle};
125
126    #[cfg(feature = "label")]
127    pub use crate::{LabelBuilder, LabelStyle};
128
129    #[cfg(feature = "panel")]
130    pub use crate::{PanelBuilder, PanelStyle};
131
132    #[cfg(feature = "separator")]
133    pub use crate::{SeparatorBuilder, Orientation};
134}
135
136define_plugin!(UiBuilderPlugin {
137    plugins: [HoverPlugin, UIRelationshipsPlugin, ScrollViewPlugin],
138    custom_init: |app: &mut App| {
139        #[cfg(feature = "button")]
140        app.add_plugins(button::ButtonPlugin);
141
142        #[cfg(feature = "slider")]
143        app.add_plugins(slider::SliderPlugin);
144
145        #[cfg(feature = "dialog")]
146        app.add_plugins(dialog::DialogPlugin);
147
148        #[cfg(feature = "text_input")]
149        app.add_plugins(text_input::TextInputPlugin);
150
151        #[cfg(feature = "progress")]
152        app.add_plugins(progress::ProgressBarPlugin);
153    }
154});