pub struct BoxDimensions {
pub total_bounds: Bounds,
pub content_bounds: Bounds,
pub viewable_width: usize,
pub viewable_height: usize,
pub content_width: usize,
pub content_height: usize,
pub horizontal_scroll: f64,
pub vertical_scroll: f64,
pub border_thickness: usize,
pub tab_height: usize,
pub vertical_scrollbar_width: usize,
pub horizontal_scrollbar_height: usize,
}Expand description
Box dimensions and coordinate system definitions
This module formalizes the coordinate systems and size measurements for boxes:
- Box Span: Total space including borders, tabs, scrollbars, all attachments
- Content Area: Space available for renderable content (inside borders/scrollbars)
- Screen Coordinates: Absolute terminal coordinates (0,0 = top-left terminal)
- Inbox Coordinates: Content-local coordinates (0,0 = top-left content cell)
Fields§
§total_bounds: BoundsTotal box span including all attachments (borders, scrollbars, tabs)
content_bounds: BoundsContent area bounds (where renderable content is placed)
viewable_width: usizeDimensions of the viewable content area
viewable_height: usize§content_width: usizeActual content dimensions (may exceed viewable area)
content_height: usize§horizontal_scroll: f64Current scroll positions (0-100 percentage)
vertical_scroll: f64§border_thickness: usizeBorder thickness
tab_height: usizeTab bar height (if tabs are present)
vertical_scrollbar_width: usizeScrollbar dimensions
horizontal_scrollbar_height: usizeImplementations§
Source§impl BoxDimensions
impl BoxDimensions
Sourcepub fn new(
muxbox: &MuxBox,
bounds: &Bounds,
content_width: usize,
content_height: usize,
) -> Self
pub fn new( muxbox: &MuxBox, bounds: &Bounds, content_width: usize, content_height: usize, ) -> Self
Create new BoxDimensions from MuxBox state with explicit content size.
This is the single canonical coordinate authority shared by rendering and
hit-testing. content_bounds is computed purely from the box’s border and
tab presence (inclusive coordinates), and one column/row is always reserved
for scrollbars so the viewable region never depends on whether a scrollbar
happens to be visible. inbox_to_screen/screen_to_inbox are exact
inverses over this region, so any cell a renderer draws via inbox_to_screen
is hit-tested back to the same inbox coordinate.
Sourcepub fn screen_to_box_span(
&self,
screen_x: usize,
screen_y: usize,
) -> Option<(usize, usize)>
pub fn screen_to_box_span( &self, screen_x: usize, screen_y: usize, ) -> Option<(usize, usize)>
Convert screen coordinates to box span coordinates Box span includes borders, tabs, scrollbars - the total area the box occupies
Sourcepub fn box_span_to_screen(&self, box_x: usize, box_y: usize) -> (usize, usize)
pub fn box_span_to_screen(&self, box_x: usize, box_y: usize) -> (usize, usize)
Convert box span coordinates to screen coordinates
Sourcepub fn screen_to_inbox(
&self,
screen_x: usize,
screen_y: usize,
) -> Option<(usize, usize)>
pub fn screen_to_inbox( &self, screen_x: usize, screen_y: usize, ) -> Option<(usize, usize)>
Convert screen coordinates to inbox (content-local) coordinates.
Exact inverse of inbox_to_screen over the viewable window. The viewable
window is [content_left, content_left + viewable_width) horizontally and
[content_top, content_top + viewable_height) vertically, so the last
viewable cell is reachable (no off-by-one) and the reserved scrollbar
column/row is excluded.
Sourcepub fn inbox_to_screen(&self, inbox_x: usize, inbox_y: usize) -> (usize, usize)
pub fn inbox_to_screen(&self, inbox_x: usize, inbox_y: usize) -> (usize, usize)
Convert inbox coordinates to screen coordinates. Returns (usize::MAX, usize::MAX) when the inbox cell is outside content or scrolled out of the
viewable window. Exact inverse of screen_to_inbox.
Sourcepub fn contains_screen_point(&self, screen_x: usize, screen_y: usize) -> bool
pub fn contains_screen_point(&self, screen_x: usize, screen_y: usize) -> bool
Check if screen coordinates are within the content area
Sourcepub fn contains_screen_point_in_span(
&self,
screen_x: usize,
screen_y: usize,
) -> bool
pub fn contains_screen_point_in_span( &self, screen_x: usize, screen_y: usize, ) -> bool
Check if screen coordinates are within the total box span
Sourcepub fn calculate_from_muxbox(muxbox: &MuxBox, total_bounds: Bounds) -> Self
pub fn calculate_from_muxbox(muxbox: &MuxBox, total_bounds: Bounds) -> Self
Calculate BoxDimensions from MuxBox and bounds
Sourcepub fn is_inbox_visible(&self, inbox_x: usize, inbox_y: usize) -> bool
pub fn is_inbox_visible(&self, inbox_x: usize, inbox_y: usize) -> bool
Check if inbox coordinates are currently visible in the viewable area
Trait Implementations§
Source§impl Clone for BoxDimensions
impl Clone for BoxDimensions
Source§fn clone(&self) -> BoxDimensions
fn clone(&self) -> BoxDimensions
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 BoxDimensions
impl RefUnwindSafe for BoxDimensions
impl Send for BoxDimensions
impl Sync for BoxDimensions
impl Unpin for BoxDimensions
impl UnsafeUnpin for BoxDimensions
impl UnwindSafe for BoxDimensions
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.