mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
0a6723479e
commit
2a27cc84ce
@ -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);
|
||||
|
||||
@ -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));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user