| 78 | } |
| 79 | |
| 80 | fn required_dimension(&self) -> Dimension { |
| 81 | let mut heights = Vec::with_capacity(self.rows.len() + 1); |
| 82 | let mut widths = Vec::new(); |
| 83 | |
| 84 | let title_dimension = self.title.as_ref().map(RowStruct::required_dimension); |
| 85 | |
| 86 | if let Some(title_dimension) = title_dimension { |
| 87 | widths = title_dimension.widths; |
| 88 | heights.push(title_dimension.height); |
| 89 | } |
| 90 | |
| 91 | for row in self.rows.iter() { |
| 92 | let row_dimension = row.required_dimension(); |
| 93 | |
| 94 | heights.push(row_dimension.height); |
| 95 | |
| 96 | let new_widths = row_dimension.widths; |
| 97 | |
| 98 | if widths.is_empty() { |
| 99 | widths = new_widths; |
| 100 | } else { |
| 101 | for (width, new_width) in widths.iter_mut().zip(new_widths.into_iter()) { |
| 102 | *width = std::cmp::max(new_width, *width); |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | Dimension { widths, heights } |
| 108 | } |
| 109 | |
| 110 | fn buffers(&self, writer: &BufferWriter) -> Result<Vec<Buffer>> { |
| 111 | let table_dimension = self.required_dimension(); |