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:math'; | 5 import 'dart:math'; |
6 import 'dart:sky'; | 6 import 'dart:sky'; |
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 int backgroundColor; | 10 final int backgroundColor; |
11 | 11 |
12 RenderSolidColor(int backgroundColor) | 12 RenderSolidColor(int backgroundColor) |
13 : super(new BoxDecoration(backgroundColor: backgroundColor)), | 13 : super(new BoxDecoration(backgroundColor: backgroundColor)), |
14 backgroundColor = backgroundColor; | 14 backgroundColor = backgroundColor; |
15 | 15 |
16 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { | 16 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |
17 return new BoxDimensions.withConstraints(constraints, height: 200.0); | 17 return new BoxDimensions.withConstraints(constraints, height: 200.0); |
18 } | 18 } |
19 | 19 |
20 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { | 20 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { |
21 setWidth(constraints, constraints.maxWidth); | 21 width = constraints.constrainWidth(constraints.maxWidth); |
22 setHeight(constraints, 200.0); | 22 height = constraints.constrainHeight(200.0); |
23 layoutDone(); | 23 layoutDone(); |
24 } | 24 } |
25 | 25 |
26 bool handlePointer(PointerEvent event, { double x: 0.0, double y: 0.0 }) { | 26 bool handlePointer(PointerEvent event, { double x: 0.0, double y: 0.0 }) { |
27 if (event.type == 'pointerdown') { | 27 if (event.type == 'pointerdown') { |
28 setBoxDecoration(new BoxDecoration(backgroundColor: 0xFFFF0000)); | 28 setBoxDecoration(new BoxDecoration(backgroundColor: 0xFFFF0000)); |
29 return true; | 29 return true; |
30 } | 30 } |
31 | 31 |
32 if (event.type == 'pointerup') { | 32 if (event.type == 'pointerup') { |
(...skipping 27 matching lines...) Expand all Loading... |
60 decoration: new BoxDecoration(backgroundColor: 0xFF00FFFF)); | 60 decoration: new BoxDecoration(backgroundColor: 0xFF00FFFF)); |
61 | 61 |
62 root.add(new RenderSolidColor(0xFF00FF00)); | 62 root.add(new RenderSolidColor(0xFF00FF00)); |
63 root.add(new RenderSolidColor(0xFF0000FF)); | 63 root.add(new RenderSolidColor(0xFF0000FF)); |
64 | 64 |
65 renderView = new RenderView(root: root); | 65 renderView = new RenderView(root: root); |
66 renderView.layout(newWidth: view.width, newHeight: view.height); | 66 renderView.layout(newWidth: view.width, newHeight: view.height); |
67 | 67 |
68 view.scheduleFrame(); | 68 view.scheduleFrame(); |
69 } | 69 } |
OLD | NEW |