| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:sky'; | 5 import 'dart:sky'; |
| 6 import 'package:sky/framework/app.dart'; | 6 import 'package:sky/framework/app.dart'; |
| 7 import 'package:sky/framework/layout2.dart'; | 7 import 'package:sky/framework/layout2.dart'; |
| 8 | 8 |
| 9 class RenderSolidColor extends RenderDecoratedBox { | 9 class RenderSolidColor extends RenderDecoratedBox { |
| 10 final double desiredHeight; | 10 final double desiredHeight; |
| 11 final double desiredWidth; | 11 final double desiredWidth; |
| 12 final int backgroundColor; | 12 final int backgroundColor; |
| 13 | 13 |
| 14 RenderSolidColor(int backgroundColor, { this.desiredHeight: double.INFINITY, | 14 RenderSolidColor(int backgroundColor, { this.desiredHeight: double.INFINITY, |
| 15 this.desiredWidth: double.INFINITY }) | 15 this.desiredWidth: double.INFINITY }) |
| 16 : backgroundColor = backgroundColor, | 16 : backgroundColor = backgroundColor, |
| 17 super(new BoxDecoration(backgroundColor: backgroundColor)); | 17 super(new BoxDecoration(backgroundColor: backgroundColor)); |
| 18 | 18 |
| 19 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { | 19 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |
| 20 return new BoxDimensions.withConstraints(constraints, | 20 return new BoxDimensions.withConstraints(constraints, |
| 21 height: desiredHeight, | 21 height: desiredHeight, |
| 22 width: desiredWidth); | 22 width: desiredWidth); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { | 25 void performLayout() { |
| 26 width = constraints.constrainWidth(desiredWidth); | 26 width = constraints.constrainWidth(desiredWidth); |
| 27 height = constraints.constrainHeight(desiredHeight); | 27 height = constraints.constrainHeight(desiredHeight); |
| 28 layoutDone(); | |
| 29 } | 28 } |
| 30 | 29 |
| 31 void handlePointer(PointerEvent event) { | 30 void handlePointer(PointerEvent event) { |
| 32 if (event.type == 'pointerdown') | 31 if (event.type == 'pointerdown') |
| 33 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); | 32 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); |
| 34 else if (event.type == 'pointerup') | 33 else if (event.type == 'pointerup') |
| 35 decoration = new BoxDecoration(backgroundColor: backgroundColor); | 34 decoration = new BoxDecoration(backgroundColor: backgroundColor); |
| 36 } | 35 } |
| 37 } | 36 } |
| 38 | 37 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Purple and blue cells | 69 // Purple and blue cells |
| 71 addFlexChild(row, 0x77FF00FF, flex: 1); | 70 addFlexChild(row, 0x77FF00FF, flex: 1); |
| 72 addFlexChild(row, 0xFF0000FF, flex: 2); | 71 addFlexChild(row, 0xFF0000FF, flex: 2); |
| 73 | 72 |
| 74 root.add(row); | 73 root.add(row); |
| 75 row.parentData.flex = 3; | 74 row.parentData.flex = 3; |
| 76 | 75 |
| 77 app = new AppView(root); | 76 app = new AppView(root); |
| 78 | 77 |
| 79 } | 78 } |
| OLD | NEW |