提交 1fcc5071 编写于 作者: C Collin Jackson

Merge pull request #110 from collinjackson/baseline2

Track overflow during flex layout and fix stocks row

R=hixie
......@@ -59,7 +59,9 @@ class StockRow extends Component {
child: new StockArrow(percentChange: stock.percentChange),
margin: const EdgeDims.only(right: 5.0)
),
new Flex(children, alignItems: FlexAlignItems.baseline)
new Flexible(
child: new Flex(children, alignItems: FlexAlignItems.baseline)
)
])
)
);
......
......@@ -81,6 +81,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
bool _overflowOccurredDuringLayout = false;
void setupParentData(RenderBox child) {
if (child.parentData is! FlexBoxParentData)
child.parentData = new FlexBoxParentData();
......@@ -376,16 +378,20 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
break;
}
Size desiredSize;
switch (_direction) {
case FlexDirection.horizontal:
size = constraints.constrain(new Size(mainSize, crossSize));
desiredSize = new Size(mainSize, crossSize);
size = constraints.constrain(desiredSize);
crossSize = size.height;
break;
case FlexDirection.vertical:
desiredSize = new Size(crossSize, mainSize);
size = constraints.constrain(new Size(crossSize, mainSize));
crossSize = size.width;
break;
}
_overflowOccurredDuringLayout = desiredSize != size;
// Position elements
double childMainPosition = leadingSpace;
......@@ -433,6 +439,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
void paint(PaintingCanvas canvas, Offset offset) {
defaultPaint(canvas, offset);
if (_overflowOccurredDuringLayout) {
canvas.save();
canvas.clipRect(offset & size);
defaultPaint(canvas, offset);
canvas.restore();
} else {
defaultPaint(canvas, offset);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册