waterui_layout/
lib.rs

1#![no_std]
2//! Layout building blocks for `WaterUI`.
3//!
4//! This crate bridges the declarative [`View`](waterui_core::View) system with
5//! the imperative, backend-driven layout pass. It contains:
6//!
7//! - the low-level [`Layout`] trait and its geometry helpers,
8//! - reusable containers such as [`spacer()`], [`padding::Padding`], and stacks,
9//! - thin wrappers (for example [`scroll()`]) that signal backend-specific
10//!   behaviour.
11//!
12//! # Logical Pixels (Points)
13//!
14//! All layout values use **logical pixels** (points/dp) - the same unit as design
15//! tools like Figma, Sketch, and Adobe XD. Native backends handle conversion to
16//! physical pixels based on screen density:
17//!
18//! - iOS/macOS: Uses points natively
19//! - Android: Converts dp → pixels via `displayMetrics.density`
20//!
21//! This ensures `spacing(8.0)` or `width(100.0)` renders at the same physical
22//! size across all platforms, matching your design specifications exactly.
23//!
24//! # Example
25//!
26//! ```rust,ignore
27//! use waterui_layout::{stack, spacer};
28//! use waterui_text::text;
29//!
30//! pub fn toolbar() -> impl waterui_core::View {
31//!     stack::hstack((
32//!         text("WaterUI"),
33//!         spacer(),
34//!         stack::vstack((text("Docs"), text("Blog"))),
35//!     ))
36//!     .spacing(8.0)  // 8pt spacing - same as Figma/Sketch
37//! }
38//! ```
39//!
40//! For a broader tour see the crate README.
41
42extern crate alloc;
43
44pub use waterui_core::layout::*;
45
46pub mod spacer;
47pub use spacer::{Spacer, spacer};
48pub mod stack;
49
50pub mod scroll;
51pub use scroll::{ScrollView, scroll};
52pub mod frame;
53
54pub mod container;
55
56pub use container::LazyContainer;
57
58pub mod grid;
59pub mod overlay;
60pub mod padding;
61pub mod safe_area;
62
63pub use overlay::{Overlay, OverlayLayout, overlay};
64pub use safe_area::{EdgeSet, IgnoreSafeArea};
65
66#[cfg(test)]
67mod tests;