(
&self,
parent_index: usize,
main_axis_x: bool,
)
| 2399 | } |
| 2400 | |
| 2401 | fn compute_wrapped_lines( |
| 2402 | &self, |
| 2403 | parent_index: usize, |
| 2404 | main_axis_x: bool, |
| 2405 | ) -> Vec<WrappedLayoutLine> { |
| 2406 | let layout_idx = self.layout_elements[parent_index].layout_config_index; |
| 2407 | let layout = self.layout_configs[layout_idx]; |
| 2408 | |
| 2409 | let children_length = self.layout_elements[parent_index].children_length as usize; |
| 2410 | if children_length == 0 { |
| 2411 | return Vec::new(); |
| 2412 | } |
| 2413 | |
| 2414 | let parent_main_size = if main_axis_x { |
| 2415 | self.layout_elements[parent_index].dimensions.width |
| 2416 | } else { |
| 2417 | self.layout_elements[parent_index].dimensions.height |
| 2418 | }; |
| 2419 | let main_padding = if main_axis_x { |
| 2420 | (layout.padding.left + layout.padding.right) as f32 |
| 2421 | } else { |
| 2422 | (layout.padding.top + layout.padding.bottom) as f32 |
| 2423 | }; |
| 2424 | let available_main = (parent_main_size - main_padding).max(0.0); |
| 2425 | |
| 2426 | if !layout.wrap { |
| 2427 | return vec![self.build_wrapped_line( |
| 2428 | parent_index, |
| 2429 | 0, |
| 2430 | children_length, |
| 2431 | main_axis_x, |
| 2432 | )]; |
| 2433 | } |
| 2434 | |
| 2435 | let children_start = self.layout_elements[parent_index].children_start; |
| 2436 | let mut lines = Vec::new(); |
| 2437 | let mut line_start = 0usize; |
| 2438 | let mut line_break_main = 0.0; |
| 2439 | |
| 2440 | for child_offset in 0..children_length { |
| 2441 | let child_index = self.layout_element_children[children_start + child_offset] as usize; |
| 2442 | let break_size = self.child_wrap_break_main_size(child_index, main_axis_x); |
| 2443 | |
| 2444 | let additional = if child_offset == line_start { |
| 2445 | break_size |
| 2446 | } else { |
| 2447 | layout.child_gap as f32 + break_size |
| 2448 | }; |
| 2449 | |
| 2450 | if child_offset > line_start && line_break_main + additional > available_main + EPSILON { |
| 2451 | lines.push(self.build_wrapped_line( |
| 2452 | parent_index, |
| 2453 | line_start, |
| 2454 | child_offset, |
| 2455 | main_axis_x, |
| 2456 | )); |
| 2457 | line_start = child_offset; |
| 2458 | line_break_main = break_size; |
no test coverage detected