Skip to content

Commit 0ab6f62

Browse files
committed
Fixed WrapperWidget layout when not aligning
When not aligning, the child widget should be forced to fill if the constraint limit is fill.
1 parent af7f08c commit 0ab6f62

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/widget.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,13 +848,17 @@ pub trait WrapperWidget: Debug + Send + 'static {
848848
#[must_use]
849849
fn position_child(
850850
&mut self,
851-
layout: WidgetLayout,
851+
mut layout: WidgetLayout,
852852
available_space: Size<ConstraintLimit>,
853853
context: &mut LayoutContext<'_, '_, '_, '_>,
854854
) -> WrappedLayout {
855855
if self.align_child() {
856856
WrappedLayout::aligned(layout, available_space, context)
857857
} else {
858+
layout.size = Size::new(
859+
available_space.width.fill_or_fit(layout.size.width),
860+
available_space.height.fill_or_fit(layout.size.height),
861+
);
858862
WrappedLayout::from(layout)
859863
}
860864
}

src/widgets/grid.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ impl GridLayout {
580580
}
581581
}
582582

583-
let measured = self.update_offsets(needs_final_layout, gutter, scale, measure);
583+
let measured = self.update_offsets(needs_final_layout, gutter, measure);
584584

585585
WidgetLayout {
586586
size: self.orientation.make_size(measured, total_other),
@@ -616,7 +616,6 @@ impl GridLayout {
616616
&mut self,
617617
needs_final_layout: bool,
618618
gutter: UPx,
619-
scale: Fraction,
620619
mut measure: impl FnMut(usize, usize, Size<ConstraintLimit>, bool) -> WidgetLayout,
621620
) -> UPx {
622621
let mut offset = UPx::ZERO;
@@ -637,7 +636,7 @@ impl GridLayout {
637636
index,
638637
element,
639638
self.orientation.make_size(
640-
ConstraintLimit::Fill(self.layouts[index].size.into_upx(scale)),
639+
ConstraintLimit::Fill(self.layouts[index].size),
641640
ConstraintLimit::Fill(self.others[element]),
642641
),
643642
true,
@@ -685,6 +684,7 @@ impl GridLayout {
685684
row_index: usize,
686685
vertical_alignment: VerticalAlign,
687686
) -> Rect<Px> {
687+
// TODO We need to honor expanding the child if we are supposed to expand it.
688688
let mut position = Rect::new(
689689
self.orientation
690690
.make_point(layout.offset, other_offset)

0 commit comments

Comments
 (0)