(widget: &Column)
| 68 | |
| 69 | impl ColumnElement { |
| 70 | pub fn new(widget: &Column) -> Self { |
| 71 | // assert!(options.rendering.is_some(), "No Rendering given to Canvas, cannot create a canvas without one."); |
| 72 | |
| 73 | let component = WidgetComponent::get(widget.key.id()); |
| 74 | |
| 75 | // component.onrender.listen(box |_| { |
| 76 | // log::warn!("Got signal to render Column"); |
| 77 | // }); |
| 78 | |
| 79 | // canvas = self; |
| 80 | // let scale = widget.scale; |
| 81 | |
| 82 | let mut children = Vec::new(); |
| 83 | |
| 84 | let mut child_nodes = Vec::new(); |
| 85 | let mut children_height = 0.0; |
| 86 | let mut children_height_correct = true; |
| 87 | |
| 88 | for child in widget.children.iter() { |
| 89 | let element = child.create_element(); |
| 90 | let child_nodes = &mut child_nodes; |
| 91 | if let Some(child) = element.node() { |
| 92 | // let child_style = LayoutSystem::style(child).unwrap(); |
| 93 | // LayoutSystem::set_style( |
| 94 | // child, |
| 95 | // style::Style { |
| 96 | // align_self: style::AlignSelf::Center, |
| 97 | // ..child_style |
| 98 | // }, |
| 99 | // ) |
| 100 | // .unwrap(); |
| 101 | |
| 102 | // calculate row height |
| 103 | let child_style = LayoutSystem::style(child).unwrap(); |
| 104 | if let style::Dimension::Points(height) = child_style.size.height { |
| 105 | children_height += height; |
| 106 | } else { |
| 107 | children_height_correct = false; |
| 108 | } |
| 109 | |
| 110 | child_nodes.push(child); |
| 111 | } |
| 112 | |
| 113 | children.push(element); |
| 114 | } |
| 115 | |
| 116 | // The height of the Column is determined by the mainAxisSize property. |
| 117 | // If the mainAxisSize property is MainAxisSize.max, then the height of the Column is the max height of the incoming constraints. |
| 118 | // If the mainAxisSize property is MainAxisSize.min, then the height of the Column is the sum of heights of the children (subject to the incoming constraints). |
| 119 | |
| 120 | let height = match widget.main_axis_size { |
| 121 | MainAxisSize::Min => { |
| 122 | // should use calculated sum of childs height |
| 123 | if children_height_correct { |
| 124 | style::Dimension::Points(children_height) |
| 125 | } else { |
| 126 | style::Dimension::Percent(1.0) |
| 127 | } |
nothing calls this directly
no test coverage detected