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 library fn; | 5 library fn; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
10 import 'dart:sky' as sky; | 10 import 'dart:sky' as sky; |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 // for now, but only for now: | 943 // for now, but only for now: |
944 | 944 |
945 class RenderSolidColor extends RenderDecoratedBox { | 945 class RenderSolidColor extends RenderDecoratedBox { |
946 final sky.Size desiredSize; | 946 final sky.Size desiredSize; |
947 final int backgroundColor; | 947 final int backgroundColor; |
948 | 948 |
949 RenderSolidColor(int backgroundColor, { this.desiredSize }) | 949 RenderSolidColor(int backgroundColor, { this.desiredSize }) |
950 : backgroundColor = backgroundColor, | 950 : backgroundColor = backgroundColor, |
951 super(new BoxDecoration(backgroundColor: backgroundColor)); | 951 super(new BoxDecoration(backgroundColor: backgroundColor)); |
952 | 952 |
953 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { | 953 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { |
954 return new BoxDimensions.withConstraints(constraints, | 954 return constraints.constrain(desiredSize); |
955 width: desiredSize.width, | |
956 height: desiredSize.height); | |
957 } | 955 } |
958 | 956 |
959 void performLayout() { | 957 void performLayout() { |
960 size = constraints.constrain(desiredSize); | 958 size = constraints.constrain(desiredSize); |
961 } | 959 } |
962 | 960 |
963 void handlePointer(sky.PointerEvent event) { | 961 void handlePointer(sky.PointerEvent event) { |
964 if (event.type == 'pointerdown') | 962 if (event.type == 'pointerdown') |
965 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); | 963 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); |
966 else if (event.type == 'pointerup') | 964 else if (event.type == 'pointerup') |
(...skipping 11 matching lines...) Expand all Loading... |
978 | 976 |
979 final int color; | 977 final int color; |
980 | 978 |
981 RenderSolidColor root; | 979 RenderSolidColor root; |
982 RenderSolidColor createNode() => new RenderSolidColor(color, desiredSize: new
sky.Size(40.0, 130.0)); | 980 RenderSolidColor createNode() => new RenderSolidColor(color, desiredSize: new
sky.Size(40.0, 130.0)); |
983 | 981 |
984 static final Rectangle _emptyRectangle = new Rectangle(0); | 982 static final Rectangle _emptyRectangle = new Rectangle(0); |
985 RenderNodeWrapper get emptyNode => _emptyRectangle; | 983 RenderNodeWrapper get emptyNode => _emptyRectangle; |
986 | 984 |
987 } | 985 } |
OLD | NEW |