pub struct LayoutDimensions { /* private fields */ }Expand description
LayoutDimensions - Centralizes ALL layout and positioning mathematical operations
Eliminates ad hoc layout math like:
- percentage parsing and normalization
- bounds calculations from InputBounds
- percentage.clamp(0.0, 100.0) / 100.0
- (normalized * (total - 1) as f64).round() as usize
- Anchor resolution and positioning
Replaces scattered layout logic from utils.rs, model/common.rs, and layout calculation code.
Implementations§
Source§impl LayoutDimensions
impl LayoutDimensions
Sourcepub fn add_child(&mut self, input_bounds: InputBounds)
pub fn add_child(&mut self, input_bounds: InputBounds)
Add child constraint
Sourcepub fn with_strategy(self, strategy: LayoutStrategy) -> Self
pub fn with_strategy(self, strategy: LayoutStrategy) -> Self
Set layout strategy
Sourcepub fn parse_percentage(percentage_str: &str) -> Result<f64, LayoutError>
pub fn parse_percentage(percentage_str: &str) -> Result<f64, LayoutError>
Parse percentage string to normalized value (0.0-1.0) Centralizes: percentage.clamp(0.0, 100.0) / 100.0
Sourcepub fn percentage_to_absolute(&self, percentage: f64, axis: Axis) -> usize
pub fn percentage_to_absolute(&self, percentage: f64, axis: Axis) -> usize
Convert percentage to absolute coordinate within total bounds Centralizes: (normalized * (total - 1) as f64).round() as usize
Sourcepub fn resolve_input_bounds(
&self,
input: &InputBounds,
) -> Result<Bounds, LayoutError>
pub fn resolve_input_bounds( &self, input: &InputBounds, ) -> Result<Bounds, LayoutError>
Parse InputBounds into actual Bounds Centralizes all InputBounds → Bounds conversion logic from utils.rs
Sourcepub fn resolve_anchor(
&self,
anchor: &Anchor,
target_size: (usize, usize),
container: &Bounds,
) -> Bounds
pub fn resolve_anchor( &self, anchor: &Anchor, target_size: (usize, usize), container: &Bounds, ) -> Bounds
Resolve anchor positioning for a target size within bounds Centralizes anchor resolution logic
Sourcepub fn calculate_all_child_bounds(&self) -> Result<Vec<Bounds>, LayoutError>
pub fn calculate_all_child_bounds(&self) -> Result<Vec<Bounds>, LayoutError>
Calculate all child bounds based on constraints and strategy
Sourcepub fn distribute_space(
&self,
percentages: &[f64],
) -> Result<Vec<usize>, LayoutError>
pub fn distribute_space( &self, percentages: &[f64], ) -> Result<Vec<usize>, LayoutError>
Calculate space distribution for responsive layouts Handles percentage-based space allocation
Sourcepub fn calculate_minimum_space(&self) -> (usize, usize)
pub fn calculate_minimum_space(&self) -> (usize, usize)
Calculate minimum required space for all children
Sourcepub fn validate_layout(&self) -> Result<(), LayoutError>
pub fn validate_layout(&self) -> Result<(), LayoutError>
Validate layout fits within available space
Trait Implementations§
Source§impl Clone for LayoutDimensions
impl Clone for LayoutDimensions
Source§fn clone(&self) -> LayoutDimensions
fn clone(&self) -> LayoutDimensions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LayoutDimensions
impl RefUnwindSafe for LayoutDimensions
impl Send for LayoutDimensions
impl Sync for LayoutDimensions
impl Unpin for LayoutDimensions
impl UnsafeUnpin for LayoutDimensions
impl UnwindSafe for LayoutDimensions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.