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::{
85    DialogBuilder, DialogButtonEvent, DialogType, DialogOverlay, DialogButtonMarker,
86    // Standard button markers for dialog buttons
87    ConfirmButton, CancelButton, SaveButton, DiscardButton,
88    OkButton, YesButton, NoButton,
89    // Dialog type markers
90    ExitConfirmationDialog, UnsavedChangesDialog, ResolutionDialog,
91    ErrorDialog, InfoDialog, WarningDialog, SuccessDialog
92};
93
94#[cfg(feature = "text_input")]
95pub use text_input::{TextInputBuilder, InputFilter, InputTransform, FocusGroupId, text_input};
96
97#[cfg(feature = "progress")]
98pub use progress::{ProgressBarBuilder, ProgressBar, ProgressBarStyle, progress};
99
100#[cfg(feature = "label")]
101pub use label::{LabelBuilder, Label, LabelStyle, label};
102
103#[cfg(feature = "panel")]
104pub use panel::{PanelBuilder, Panel, PanelStyle, panel};
105
106#[cfg(feature = "separator")]
107pub use separator::{SeparatorBuilder, Separator, SeparatorStyle, Orientation, separator};
108
109/// Prelude module for convenient imports
110pub mod prelude {
111    #[doc(hidden)]
112    pub use crate::{
113        despawn_ui_entities, despawn_entities,
114    };
115
116    #[cfg(feature = "button")]
117    pub use crate::{ButtonBuilder, ButtonStyle, ButtonSize};
118
119    #[cfg(feature = "slider")]
120    pub use crate::{SliderBuilder, ValueFormat};
121
122    #[cfg(feature = "form")]
123    pub use crate::{FormBuilder, FieldType, ValidationRule};
124
125    #[cfg(feature = "dialog")]
126    pub use crate::{
127        DialogBuilder, DialogType, DialogButtonMarker,
128        // Standard button markers
129        ConfirmButton, CancelButton, SaveButton, DiscardButton,
130        OkButton, YesButton, NoButton,
131    };
132
133    #[cfg(feature = "text_input")]
134    pub use crate::{TextInputBuilder, InputFilter};
135
136    #[cfg(feature = "progress")]
137    pub use crate::{ProgressBarBuilder, ProgressBarStyle};
138
139    #[cfg(feature = "label")]
140    pub use crate::{LabelBuilder, LabelStyle};
141
142    #[cfg(feature = "panel")]
143    pub use crate::{PanelBuilder, PanelStyle};
144
145    #[cfg(feature = "separator")]
146    pub use crate::{SeparatorBuilder, Orientation};
147}
148
149define_plugin!(UiBuilderPlugin {
150    plugins: [HoverPlugin, UIRelationshipsPlugin, ScrollViewPlugin],
151    custom_init: |app: &mut App| {
152        #[cfg(feature = "button")]
153        app.add_plugins(button::ButtonPlugin);
154
155        #[cfg(feature = "slider")]
156        app.add_plugins(slider::SliderPlugin);
157
158        #[cfg(feature = "dialog")]
159        app.add_plugins(dialog::DialogPlugin);
160
161        #[cfg(feature = "text_input")]
162        app.add_plugins(text_input::TextInputPlugin);
163
164        #[cfg(feature = "progress")]
165        app.add_plugins(progress::ProgressBarPlugin);
166    }
167});