@@ -47,39 +47,43 @@ pub struct FloatContext {
4747/// to be laid out into
4848#[ derive( Debug , Clone , Copy , Default ) ]
4949pub struct ContentSlot {
50+ /// The id of the segment that the slot starts in
5051 pub segment_id : Option < usize > ,
52+ /// The x position of the start of the slot
5153 pub x : f32 ,
54+ /// The y position of the start of the slot
5255 pub y : f32 ,
56+ /// The width of the slot
5357 pub width : f32 ,
58+ /// The height of the slot
5459 pub height : f32 ,
5560}
5661
57- /// A floated box to place within the context
58- #[ derive( Debug , Clone , Copy , Default ) ]
59- pub struct FloatedBox {
60- /// A user defined ID for the box
61- // pub(crate) id: u64 ,
62- pub ( crate ) width : f32 ,
63- pub ( crate ) height : f32 ,
64- }
62+ // // / A floated box to place within the context
63+ // #[derive(Debug, Clone, Copy, Default)]
64+ // pub struct FloatedBox {
65+ // /// The width of the box
66+ // pub(crate) width: f32 ,
67+ // /// The height of the box
68+ // pub(crate) height: f32,
69+ // }
6570
6671/// A floated box
6772#[ derive( Debug , Clone , Default ) ]
6873struct PlacedFloatedBox {
6974 /// A user defined ID for the box
7075 // id: u64,
76+ /// The width of the box
7177 width : f32 ,
78+ /// The height of the box
7279 height : f32 ,
73- /// Distance from the edge of the container that the box is floated towards
80+ /// Horizontal distance from the edge of the container that the box is floated towards
7481 /// (distance from the left for left floats, from the right for right floats)
7582 x_inset : f32 ,
83+ /// Vertical distance from top edge of the container
7684 y : f32 ,
7785}
7886
79- impl PlacedFloatedBox {
80- const DEFAULT : Self = Self { /*id: 0, */ width : 0.0 , height : 0.0 , x_inset : 0.0 , y : 0.0 } ;
81- }
82-
8387impl FloatContext {
8488 /// Create a new empty `FloatContext`
8589 pub fn new ( available_space : AvailableSpace ) -> Self {
@@ -156,6 +160,7 @@ impl FloatContext {
156160 }
157161 }
158162
163+ /// Search a space suitable for laying out non-floated content into
159164 pub fn find_content_slot (
160165 & self ,
161166 min_y : f32 ,
@@ -166,34 +171,23 @@ impl FloatContext {
166171 self . placer . find_content_slot ( min_y, containing_block_insets, clear, after)
167172 }
168173
169- pub ( crate ) fn content_width ( & self ) -> f32 {
170- match self . available_space {
171- AvailableSpace :: Definite ( width) => width,
172- AvailableSpace :: MinContent => {
173- let left_max =
174- self . left_floats . iter ( ) . map ( |float| float. x_inset ) . max_by ( |a, b| a. total_cmp ( b) ) . unwrap_or ( 0.0 ) ;
175- let right_max =
176- self . right_floats . iter ( ) . map ( |float| float. x_inset ) . max_by ( |a, b| a. total_cmp ( b) ) . unwrap_or ( 0.0 ) ;
177- left_max. max ( right_max)
178- }
179- AvailableSpace :: MaxContent => {
180- let left_max = self . left_floats . last ( ) . map ( |float| float. x_inset ) . unwrap_or ( 0.0 ) ;
181- let right_max = self . right_floats . last ( ) . map ( |float| float. x_inset ) . unwrap_or ( 0.0 ) ;
182- left_max + right_max
183- }
184- }
185- }
186-
187- pub ( crate ) fn content_height ( & self ) -> f32 {
188- self . placer . segments . last ( ) . map ( |seg| seg. y . end ) . unwrap_or ( 0.0 )
189- }
190-
191- fn get_float_list ( & self , float_direction : FloatDirection ) -> & [ PlacedFloatedBox ] {
192- match float_direction {
193- FloatDirection :: Left => & self . left_floats ,
194- FloatDirection :: Right => & self . right_floats ,
195- }
196- }
174+ // pub(crate) fn content_width(&self) -> f32 {
175+ // match self.available_space {
176+ // AvailableSpace::Definite(width) => width,
177+ // AvailableSpace::MinContent => {
178+ // let left_max =
179+ // self.left_floats.iter().map(|float| float.x_inset).max_by(|a, b| a.total_cmp(b)).unwrap_or(0.0);
180+ // let right_max =
181+ // self.right_floats.iter().map(|float| float.x_inset).max_by(|a, b| a.total_cmp(b)).unwrap_or(0.0);
182+ // left_max.max(right_max)
183+ // }
184+ // AvailableSpace::MaxContent => {
185+ // let left_max = self.left_floats.last().map(|float| float.x_inset).unwrap_or(0.0);
186+ // let right_max = self.right_floats.last().map(|float| float.x_inset).unwrap_or(0.0);
187+ // left_max + right_max
188+ // }
189+ // }
190+ // }
197191}
198192
199193#[ derive( Debug , Clone ) ]
0 commit comments