@@ -27,15 +27,16 @@ pub enum Length {
2727 /// Fill a fixed amount of space in pixels.
2828 Fixed ( f32 ) ,
2929
30- /// Fill a certain amount of space inside the given [`Bounds`] with some [`Fluidity`] .
30+ /// Fill a certain amount of space inside the given [`Bounds`] with some [`Sizing`] strategy .
3131 Bounded {
32- /// The amount of space that can be filled.
32+ /// The [`Bounds`] of space that can be filled.
3333 bounds : Bounds ,
34- /// The strategy in which the space should be filled.
35- with : Fluidity ,
34+ /// The [`Sizing`] strategy with which the [`Bounds`] should be filled.
35+ sizing : Sizing ,
3636 } ,
3737
38- /// TODO
38+ /// Fill the remaining space like [`Fill`](Self::Fill), but subject to a single
39+ /// open-ended [`Constraint`].
3940 Fluid ( Constraint ) ,
4041}
4142
@@ -98,7 +99,7 @@ impl Bounds {
9899}
99100
100101#[ derive( Debug , Clone , Copy , PartialEq ) ]
101- pub enum Fluidity {
102+ pub enum Sizing {
102103 Fit ,
103104 Fill ( u16 ) ,
104105 Shrink ,
@@ -110,22 +111,25 @@ impl Length {
110111 let min = min. into ( ) . 0 ;
111112
112113 let with = match self {
113- Self :: Fit | Self :: Fluid ( _) => Fluidity :: Fit ,
114- Self :: Fill => Fluidity :: Fill ( 1 ) ,
115- Self :: FillPortion ( factor) => Fluidity :: Fill ( factor) ,
116- Self :: Shrink => Fluidity :: Shrink ,
114+ Self :: Fit | Self :: Fluid ( _) => Sizing :: Fit ,
115+ Self :: Fill => Sizing :: Fill ( 1 ) ,
116+ Self :: FillPortion ( factor) => Sizing :: Fill ( factor) ,
117+ Self :: Shrink => Sizing :: Shrink ,
117118 Self :: Fixed ( _) => return self ,
118- Self :: Bounded { bounds, with } => {
119+ Self :: Bounded {
120+ bounds,
121+ sizing : with,
122+ } => {
119123 return Self :: Bounded {
120124 bounds : bounds. min ( min) ,
121- with,
125+ sizing : with,
122126 } ;
123127 }
124128 } ;
125129
126130 Self :: Bounded {
127131 bounds : Bounds :: Min ( min) ,
128- with,
132+ sizing : with,
129133 }
130134 }
131135
@@ -134,22 +138,25 @@ impl Length {
134138 let max = max. into ( ) . 0 ;
135139
136140 let with = match self {
137- Self :: Fit | Self :: Fluid ( _) => Fluidity :: Fit ,
138- Self :: Fill => Fluidity :: Fill ( 1 ) ,
139- Self :: FillPortion ( factor) => Fluidity :: Fill ( factor) ,
140- Self :: Shrink => Fluidity :: Shrink ,
141+ Self :: Fit | Self :: Fluid ( _) => Sizing :: Fit ,
142+ Self :: Fill => Sizing :: Fill ( 1 ) ,
143+ Self :: FillPortion ( factor) => Sizing :: Fill ( factor) ,
144+ Self :: Shrink => Sizing :: Shrink ,
141145 Self :: Fixed ( _) => return self ,
142- Self :: Bounded { bounds, with } => {
146+ Self :: Bounded {
147+ bounds,
148+ sizing : with,
149+ } => {
143150 return Self :: Bounded {
144151 bounds : bounds. max ( max) ,
145- with,
152+ sizing : with,
146153 } ;
147154 }
148155 } ;
149156
150157 Self :: Bounded {
151158 bounds : Bounds :: Max ( max) ,
152- with,
159+ sizing : with,
153160 }
154161 }
155162
@@ -163,7 +170,7 @@ impl Length {
163170 Length :: Fill => 1 ,
164171 Length :: FillPortion ( factor)
165172 | Length :: Bounded {
166- with : Fluidity :: Fill ( factor) ,
173+ sizing : Sizing :: Fill ( factor) ,
167174 ..
168175 } => * factor,
169176 Length :: Fluid ( _) => 1 ,
@@ -182,19 +189,6 @@ impl Length {
182189 matches ! ( self , Self :: Fit )
183190 }
184191
185- /// Returns the "fluid" variant of the [`Length`].
186- ///
187- /// Specifically:
188- /// - [`Length::Shrink`] if [`Length::Shrink`] or [`Length::Fixed`].
189- /// - [`Length::Fill`] otherwise.
190- pub fn fluid ( & self ) -> Self {
191- if self . fill_factor ( ) == 0 {
192- Self :: Shrink
193- } else {
194- Self :: Fill
195- }
196- }
197-
198192 /// TODO
199193 pub fn stack ( self , other : Length ) -> Self {
200194 self . merge_with ( other, Constraint :: stack)
@@ -216,34 +210,43 @@ impl Length {
216210 Length :: Fluid ( a) ,
217211 Length :: Bounded {
218212 bounds,
219- with : Fluidity :: Fill ( _) ,
213+ sizing : Sizing :: Fill ( _) ,
220214 } ,
221215 ) => Length :: Fluid ( merge ( a, bounds. constraint ( ) ) ) ,
222216 ( Length :: Fluid ( constraint) , _) => Length :: Fluid ( constraint) ,
223217
224218 (
225219 Length :: Bounded {
226220 bounds,
227- with : Fluidity :: Fit ,
221+ sizing : Sizing :: Fit ,
228222 } ,
229223 Length :: Fill
230224 | Length :: FillPortion ( _)
231225 | Length :: Bounded {
232- with : Fluidity :: Fill ( _) ,
226+ sizing : Sizing :: Fill ( _) ,
233227 ..
234228 } ,
235229 ) => Length :: Bounded {
236230 bounds,
237- with : Fluidity :: Fill ( 1 ) ,
231+ sizing : Sizing :: Fill ( 1 ) ,
232+ } ,
233+ (
234+ Length :: Bounded {
235+ bounds,
236+ sizing : with,
237+ } ,
238+ _,
239+ ) => Length :: Bounded {
240+ bounds,
241+ sizing : with,
238242 } ,
239- ( Length :: Bounded { bounds, with } , _) => Length :: Bounded { bounds, with } ,
240243
241244 // Fluid and bounded constraints must be propagated
242245 (
243246 _,
244247 Length :: Bounded {
245248 bounds,
246- with : Fluidity :: Fill ( _) ,
249+ sizing : Sizing :: Fill ( _) ,
247250 } ,
248251 ) => Length :: Fluid ( bounds. constraint ( ) ) ,
249252 ( _, Length :: Fluid ( constraint) ) => Length :: Fluid ( constraint) ,
0 commit comments