pub struct ComponentDimensions { /* private fields */ }Expand description
ComponentDimensions - Centralizes all UI component mathematical operations
Eliminates ad hoc math like:
- bounds.left() + 1, bounds.right() - 1
- width.saturating_sub(2)
- (x1 + x2) / 2 for center calculations
- Hit testing and coordinate validation
All component positioning, sizing, and geometric operations centralized here.
Implementations§
Source§impl ComponentDimensions
impl ComponentDimensions
Sourcepub fn with_border_thickness(self, thickness: usize) -> Self
pub fn with_border_thickness(self, thickness: usize) -> Self
Builder pattern for configuration
pub fn with_padding(self, padding: Padding) -> Self
pub fn with_scrollbars(self, vertical: bool, horizontal: bool) -> Self
Sourcepub fn outer_bounds(&self) -> Bounds
pub fn outer_bounds(&self) -> Bounds
Get outer bounds (full component including border)
Sourcepub fn border_bounds(&self) -> Bounds
pub fn border_bounds(&self) -> Bounds
Get border area bounds (just the border region)
Sourcepub fn content_bounds(&self) -> Bounds
pub fn content_bounds(&self) -> Bounds
Get content area bounds (inside border and padding) Replaces: bounds.left() + 2, bounds.right() - 2, etc.
Sourcepub fn center(&self) -> (usize, usize)
pub fn center(&self) -> (usize, usize)
Get center point of component Replaces: (x1 + x2) / 2, (y1 + y2) / 2
Sourcepub fn content_center(&self) -> (usize, usize)
pub fn content_center(&self) -> (usize, usize)
Get content area center
Sourcepub fn content_width(&self) -> usize
pub fn content_width(&self) -> usize
Calculate available content width Replaces: width.saturating_sub(4), bounds.width() - borders
Sourcepub fn content_height(&self) -> usize
pub fn content_height(&self) -> usize
Calculate available content height Replaces: height.saturating_sub(4), bounds.height() - borders
Sourcepub fn border_coordinates(&self) -> BorderCoordinates
pub fn border_coordinates(&self) -> BorderCoordinates
Get border drawing coordinates for each side
Sourcepub fn inside_border_bounds(&self) -> Bounds
pub fn inside_border_bounds(&self) -> Bounds
Calculate inside border coordinates (border + 1) Replaces: bounds.left() + 1, bounds.right() - 1, etc.
Sourcepub fn hit_test(&self, x: usize, y: usize) -> HitRegion
pub fn hit_test(&self, x: usize, y: usize) -> HitRegion
Hit test a point against component regions Centralizes all coordinate hit testing logic
Sourcepub fn calculate_title_position(
&self,
title: &str,
position: &str,
padding: usize,
) -> TitleLayout
pub fn calculate_title_position( &self, title: &str, position: &str, padding: usize, ) -> TitleLayout
Calculate title positioning within component Centralizes title positioning math from draw_utils.rs
Sourcepub fn is_near_corner(
&self,
x: usize,
y: usize,
tolerance: usize,
) -> Option<Corner>
pub fn is_near_corner( &self, x: usize, y: usize, tolerance: usize, ) -> Option<Corner>
Check if point is near corner (for resize detection) Replaces: x >= bounds.x2.saturating_sub(corner_tolerance) && x <= bounds.x2
Sourcepub fn available_child_space(&self) -> (usize, usize)
pub fn available_child_space(&self) -> (usize, usize)
Calculate space available for child components
Sourcepub fn validate(&self) -> Result<(), ComponentDimensionError>
pub fn validate(&self) -> Result<(), ComponentDimensionError>
Validate that dimensions are reasonable
Source§impl ComponentDimensions
impl ComponentDimensions
Sourcepub fn vertical_scrollbar_track_bounds(&self) -> Bounds
pub fn vertical_scrollbar_track_bounds(&self) -> Bounds
Get vertical scrollbar track bounds Replaces: bounds.top() + 1, bounds.bottom() - 1
Sourcepub fn horizontal_scrollbar_track_bounds(&self) -> Bounds
pub fn horizontal_scrollbar_track_bounds(&self) -> Bounds
Get horizontal scrollbar track bounds
Replaces: bounds.left() + 1, bounds.right() - 1
Trait Implementations§
Source§impl Clone for ComponentDimensions
impl Clone for ComponentDimensions
Source§fn clone(&self) -> ComponentDimensions
fn clone(&self) -> ComponentDimensions
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 ComponentDimensions
impl RefUnwindSafe for ComponentDimensions
impl Send for ComponentDimensions
impl Sync for ComponentDimensions
impl Unpin for ComponentDimensions
impl UnsafeUnpin for ComponentDimensions
impl UnwindSafe for ComponentDimensions
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.