diff --git a/druid/src/widget/flex.rs b/druid/src/widget/flex.rs index 3c8356923b..2044a123aa 100644 --- a/druid/src/widget/flex.rs +++ b/druid/src/widget/flex.rs @@ -306,6 +306,11 @@ pub enum CrossAxisAlignment { /// /// The calculated baseline is the maximum baseline offset of the children. Baseline, + /// Fill the available space. + /// + /// The size on this axis is the size of the largest widget; + /// other widgets must fill that space. + Fill, } /// Arrangement of children on the main axis. @@ -712,6 +717,15 @@ impl Widget for Flex { let child_above_baseline = child_size.height - child_baseline; extra_height + (max_above_baseline - child_above_baseline) } + CrossAxisAlignment::Fill => { + let fill_size: Size = self + .direction + .pack(self.direction.major(child_size), minor_dim) + .into(); + let child_bc = BoxConstraints::tight(fill_size); + child.widget.layout(ctx, &child_bc, data, env); + 0.0 + } _ => { let extra_minor = minor_dim - self.direction.minor(child_size); alignment.align(extra_minor) @@ -793,6 +807,7 @@ impl CrossAxisAlignment { // in vertical layout, baseline is equivalent to center CrossAxisAlignment::Center | CrossAxisAlignment::Baseline => (val / 2.0).round(), CrossAxisAlignment::End => val, + CrossAxisAlignment::Fill => 0.0, } } }