(&mut self)
| 3651 | } |
| 3652 | |
| 3653 | fn generate_render_commands(&mut self) { |
| 3654 | self.render_commands.clear(); |
| 3655 | let mut dfs_buffer: Vec<LayoutElementTreeNode> = Vec::new(); |
| 3656 | let mut visited: Vec<bool> = Vec::new(); |
| 3657 | |
| 3658 | for root_index in 0..self.layout_element_tree_roots.len() { |
| 3659 | dfs_buffer.clear(); |
| 3660 | visited.clear(); |
| 3661 | let root = self.layout_element_tree_roots[root_index]; |
| 3662 | let root_elem_idx = root.layout_element_index as usize; |
| 3663 | let root_element = &self.layout_elements[root_elem_idx]; |
| 3664 | let mut root_position = Vector2::default(); |
| 3665 | |
| 3666 | // Position floating containers |
| 3667 | if self.element_has_config(root_elem_idx, ElementConfigType::Floating) { |
| 3668 | if let Some(parent_item) = self.layout_element_map.get(&root.parent_id) { |
| 3669 | let parent_bbox = parent_item.bounding_box; |
| 3670 | if let Some(float_cfg_idx) = self |
| 3671 | .find_element_config_index(root_elem_idx, ElementConfigType::Floating) |
| 3672 | { |
| 3673 | let config = &self.floating_element_configs[float_cfg_idx]; |
| 3674 | let root_dims = root_element.dimensions; |
| 3675 | let mut target = Vector2::default(); |
| 3676 | |
| 3677 | // X position - parent attach point |
| 3678 | match config.attach_points.parent_x { |
| 3679 | AlignX::Left => { |
| 3680 | target.x = parent_bbox.x; |
| 3681 | } |
| 3682 | AlignX::CenterX => { |
| 3683 | target.x = parent_bbox.x + parent_bbox.width / 2.0; |
| 3684 | } |
| 3685 | AlignX::Right => { |
| 3686 | target.x = parent_bbox.x + parent_bbox.width; |
| 3687 | } |
| 3688 | } |
| 3689 | // X position - element attach point |
| 3690 | match config.attach_points.element_x { |
| 3691 | AlignX::Left => {} |
| 3692 | AlignX::CenterX => { |
| 3693 | target.x -= root_dims.width / 2.0; |
| 3694 | } |
| 3695 | AlignX::Right => { |
| 3696 | target.x -= root_dims.width; |
| 3697 | } |
| 3698 | } |
| 3699 | // Y position - parent attach point |
| 3700 | match config.attach_points.parent_y { |
| 3701 | AlignY::Top => { |
| 3702 | target.y = parent_bbox.y; |
| 3703 | } |
| 3704 | AlignY::CenterY => { |
| 3705 | target.y = parent_bbox.y + parent_bbox.height / 2.0; |
| 3706 | } |
| 3707 | AlignY::Bottom => { |
| 3708 | target.y = parent_bbox.y + parent_bbox.height; |
| 3709 | } |
| 3710 | } |
no test coverage detected