layout_utils.dart 755 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
import 'package:sky/rendering.dart';

const Size _kTestViewSize = const Size(800.0, 600.0);

class TestRenderView extends RenderView {
  TestRenderView({ RenderBox child }) : super(child: child) {
    attach();
    rootConstraints = new ViewConstraints(size: _kTestViewSize);
    scheduleInitialLayout();
  }

  void beginFrame(double timeStamp) {
    RenderObject.flushLayout();
  }
}

RenderView layout(RenderBox box, { BoxConstraints constraints }) {
  if (constraints != null) {
    box = new RenderPositionedBox(
      child: new RenderConstrainedBox(
        additionalConstraints: constraints,
        child: box
      )
    );
  }

  TestRenderView renderView = new TestRenderView(child: box);
  renderView.beginFrame(0.0);
  return renderView;
}