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 Size getIntrinsicDimensions(BoxConstraints constraints) { |
20 return new BoxDimensions.withConstraints(constraints, | 20 return constraints.constrain(new Size(desiredWidth, desiredHeight)); |
21 height: desiredHeight, | |
22 width: desiredWidth); | |
23 } | 21 } |
24 | 22 |
25 void performLayout() { | 23 void performLayout() { |
26 width = constraints.constrainWidth(desiredWidth); | 24 width = constraints.constrainWidth(desiredWidth); |
27 height = constraints.constrainHeight(desiredHeight); | 25 height = constraints.constrainHeight(desiredHeight); |
28 } | 26 } |
29 | 27 |
30 void handlePointer(PointerEvent event) { | 28 void handlePointer(PointerEvent event) { |
31 if (event.type == 'pointerdown') | 29 if (event.type == 'pointerdown') |
32 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); | 30 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); |
(...skipping 19 matching lines...) Expand all Loading... |
52 andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola | 50 andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola |
53 alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl. | 51 alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl. |
54 Pancetta meatball tongue tenderloin rump tail jowl boudin."""; | 52 Pancetta meatball tongue tenderloin rump tail jowl boudin."""; |
55 | 53 |
56 child = new RenderParagraph(meatyString); | 54 child = new RenderParagraph(meatyString); |
57 root.add(child); | 55 root.add(child); |
58 child.parentData.flex = 1; | 56 child.parentData.flex = 1; |
59 | 57 |
60 app = new AppView(root); | 58 app = new AppView(root); |
61 } | 59 } |
OLD | NEW |