(&mut self)
| 3326 | } |
| 3327 | |
| 3328 | fn calculate_final_layout(&mut self) { |
| 3329 | // Size along X axis |
| 3330 | self.size_containers_along_axis(true); |
| 3331 | |
| 3332 | // Wrap text |
| 3333 | self.wrap_text(); |
| 3334 | |
| 3335 | // Scale vertical heights by aspect ratio |
| 3336 | for i in 0..self.aspect_ratio_element_indexes.len() { |
| 3337 | let elem_idx = self.aspect_ratio_element_indexes[i] as usize; |
| 3338 | if let Some(cfg_idx) = |
| 3339 | self.find_element_config_index(elem_idx, ElementConfigType::Aspect) |
| 3340 | { |
| 3341 | let aspect_ratio = self.aspect_ratio_configs[cfg_idx]; |
| 3342 | let is_cover = self.aspect_ratio_cover_configs[cfg_idx]; |
| 3343 | let new_height = |
| 3344 | (1.0 / aspect_ratio) * self.layout_elements[elem_idx].dimensions.width; |
| 3345 | self.layout_elements[elem_idx].dimensions.height = new_height; |
| 3346 | let layout_idx = self.layout_elements[elem_idx].layout_config_index; |
| 3347 | self.layout_configs[layout_idx].sizing.height.min_max.min = new_height; |
| 3348 | self.layout_configs[layout_idx].sizing.height.min_max.max = if is_cover { |
| 3349 | MAXFLOAT |
| 3350 | } else { |
| 3351 | new_height |
| 3352 | }; |
| 3353 | } |
| 3354 | } |
| 3355 | |
| 3356 | // Propagate height changes up tree (DFS) |
| 3357 | self.propagate_sizes_up_tree(); |
| 3358 | |
| 3359 | // Size along Y axis |
| 3360 | self.size_containers_along_axis(false); |
| 3361 | |
| 3362 | // Scale horizontal widths by aspect ratio |
| 3363 | for i in 0..self.aspect_ratio_element_indexes.len() { |
| 3364 | let elem_idx = self.aspect_ratio_element_indexes[i] as usize; |
| 3365 | if let Some(cfg_idx) = |
| 3366 | self.find_element_config_index(elem_idx, ElementConfigType::Aspect) |
| 3367 | { |
| 3368 | let aspect_ratio = self.aspect_ratio_configs[cfg_idx]; |
| 3369 | let is_cover = self.aspect_ratio_cover_configs[cfg_idx]; |
| 3370 | let new_width = |
| 3371 | aspect_ratio * self.layout_elements[elem_idx].dimensions.height; |
| 3372 | self.layout_elements[elem_idx].dimensions.width = new_width; |
| 3373 | let layout_idx = self.layout_elements[elem_idx].layout_config_index; |
| 3374 | self.layout_configs[layout_idx].sizing.width.min_max.min = new_width; |
| 3375 | self.layout_configs[layout_idx].sizing.width.min_max.max = if is_cover { |
| 3376 | MAXFLOAT |
| 3377 | } else { |
| 3378 | new_width |
| 3379 | }; |
| 3380 | } |
| 3381 | } |
| 3382 | |
| 3383 | // Sort tree roots by z-index (bubble sort) |
| 3384 | let mut sort_max = self.layout_element_tree_roots.len().saturating_sub(1); |
| 3385 | while sort_max > 0 { |
no test coverage detected