Commit e1aa0431 authored by Collin Jackson's avatar Collin Jackson

Merge pull request #110 from collinjackson/baseline2

Track overflow during flex layout and fix stocks row

R=hixie
parents 87c56759 62fc9d85
...@@ -59,7 +59,9 @@ class StockRow extends Component { ...@@ -59,7 +59,9 @@ class StockRow extends Component {
child: new StockArrow(percentChange: stock.percentChange), child: new StockArrow(percentChange: stock.percentChange),
margin: const EdgeDims.only(right: 5.0) 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 ...@@ -81,6 +81,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
} }
} }
bool _overflowOccurredDuringLayout = false;
void setupParentData(RenderBox child) { void setupParentData(RenderBox child) {
if (child.parentData is! FlexBoxParentData) if (child.parentData is! FlexBoxParentData)
child.parentData = new FlexBoxParentData(); child.parentData = new FlexBoxParentData();
...@@ -376,16 +378,20 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -376,16 +378,20 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
break; break;
} }
Size desiredSize;
switch (_direction) { switch (_direction) {
case FlexDirection.horizontal: case FlexDirection.horizontal:
size = constraints.constrain(new Size(mainSize, crossSize)); desiredSize = new Size(mainSize, crossSize);
size = constraints.constrain(desiredSize);
crossSize = size.height; crossSize = size.height;
break; break;
case FlexDirection.vertical: case FlexDirection.vertical:
desiredSize = new Size(crossSize, mainSize);
size = constraints.constrain(new Size(crossSize, mainSize)); size = constraints.constrain(new Size(crossSize, mainSize));
crossSize = size.width; crossSize = size.width;
break; break;
} }
_overflowOccurredDuringLayout = desiredSize != size;
// Position elements // Position elements
double childMainPosition = leadingSpace; double childMainPosition = leadingSpace;
...@@ -433,6 +439,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -433,6 +439,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
} }
void paint(PaintingCanvas canvas, Offset offset) { 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% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment