Introduce RenderProxyBox and RenderSizedBox

Also makes Point, Size, and Rect immutable.

R=ianh@google.com

Review URL: https://codereview.chromium.org/1162033002
This commit is contained in:
Adam Barth 2015-05-28 13:39:26 -07:00
parent 0a6723479e
commit 2a27cc84ce
2 changed files with 3 additions and 18 deletions

View File

@ -15,7 +15,7 @@ void beginFrame(double timeStamp) {
PictureRecorder canvas = new PictureRecorder(view.width, view.height);
canvas.translate(view.width / 2.0, view.height / 2.0);
canvas.rotateDegrees(delta / 10);
canvas.drawRect(new Rect()..setLTRB(-100.0, -100.0, 100.0, 100.0),
canvas.drawRect(new Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
new Paint()..setARGB(255, 0, 255, 0));
double sin = math.sin(delta / 200);

View File

@ -7,27 +7,12 @@ import '../resources/unit.dart';
import 'dart:sky' as sky;
import 'package:sky/framework/layout2.dart';
class RenderSizedBox extends RenderBox {
final sky.Size desiredSize;
RenderSizedBox({ this.desiredSize });
BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) {
return new BoxDimensions.withConstraints(constraints,
width: desiredSize.width,
height: desiredSize.height);
}
void performLayout() {
size = constraints.constrain(desiredSize);
}
}
void main() {
initUnit();
test("should size to render view", () {
RenderSizedBox root = new RenderSizedBox(desiredSize: new sky.Size.infinite());
RenderSizedBox root = new RenderSizedBox(
new RenderDecoratedBox(new BoxDecoration(backgroundColor: 0xFF00FF00)));
RenderView renderView = new RenderView(child: root);
renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.view.height));
expect(root.size.width, equals(sky.view.width));