Skip to main content

univis_ui_engine/
lib.rs

1//! Core engine crate for Univis UI.
2//!
3//! This crate owns the root model, layout solver, rendering sync, and the
4//! schedule sets that the rest of the workspace builds on top of.
5//!
6//! Most applications import these APIs through `univis_ui::prelude`, while
7//! engine-level integrations typically use [`prelude`] or [`layout`] directly.
8
9use bevy::prelude::*;
10
11/// Layout, roots, rendering helpers, and node primitives.
12pub mod layout;
13/// Shared schedule sets used by engine, widgets, and interaction systems.
14pub mod schedule;
15
16#[allow(unused_imports)]
17#[doc(hidden)]
18pub(crate) mod internal {
19    pub use crate::layout::components::{
20        CachedUiContext, IntrinsicSize, LayoutDepth, LayoutTreeDepth, UI3d, UiNodeStageVersions,
21    };
22    pub use crate::layout::geometry::ComputedSize;
23    pub use crate::layout::layout_system::{ResolvedRootStack, ResolvedRootUi};
24    pub use crate::layout::render::system::{MaterialHandles, MaterialPool, MeshPool};
25}
26
27#[allow(unused_imports)]
28pub(crate) mod internal_prelude {
29    pub use crate::internal::*;
30    pub use crate::layout::algorithms::prelude::*;
31    pub use crate::layout::components::*;
32    pub use crate::layout::core::prelude::*;
33    pub use crate::layout::geometry::*;
34    pub use crate::layout::image::*;
35    pub use crate::layout::layout_system::*;
36    pub use crate::layout::pbr::*;
37    pub use crate::layout::pipeline::prelude::*;
38    pub use crate::layout::profiling::*;
39    pub use crate::layout::render::prelude::*;
40    pub use crate::layout::solver_types::*;
41    pub use crate::layout::univis_node::*;
42    pub use crate::schedule::*;
43    pub use univis_ui_style::prelude::*;
44}
45
46/// The recommended import surface when depending on `univis_ui_engine` directly.
47///
48/// Deprecated compatibility wrappers stay on explicit paths such as
49/// [`crate::layout::layout_system::UScreenRoot`] and
50/// [`crate::layout::layout_system::UWorldRoot`] instead of this default import.
51pub mod prelude {
52    pub use crate::layout::geometry::{UCornerRadius, USides, UVal};
53    pub use crate::layout::image::UImage;
54    pub use crate::layout::layout_system::{
55        URootUi, UiCameraRef, UiCanvasSize, UiRootSettlementState, UiSpace,
56    };
57    pub use crate::layout::pbr::UPbr;
58    pub use crate::layout::univis_node::*;
59    pub use crate::schedule::{
60        UiPickingRuntimeState, UiRolloutConfig, UiSettlementConfig, UiSettlementRuntimeState,
61        UiValidationMode, UiValidationState,
62    };
63    pub use crate::{UnivisEnginePlugin, layout::prelude::*};
64}
65
66/// Registers the engine-level plugins responsible for node setup, layout
67/// solving, and render synchronization.
68pub struct UnivisEnginePlugin;
69
70impl Plugin for UnivisEnginePlugin {
71    fn build(&self, app: &mut App) {
72        app.init_resource::<schedule::UiRolloutConfig>()
73            .init_resource::<schedule::UiValidationState>()
74            .add_plugins((
75                layout::univis_node::UnivisNodePlugin,
76                layout::UnivisLayoutPlugin,
77                layout::render::UnivisRenderPlugin,
78            ));
79    }
80}