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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
936 Text(this.data) : super(key: '*text*'); | 936 Text(this.data) : super(key: '*text*'); |
937 final String data; | 937 final String data; |
938 bool get interchangeable => true; | 938 bool get interchangeable => true; |
939 UINode build() => new Paragraph(children: [new TextFragment(data)]); | 939 UINode build() => new Paragraph(children: [new TextFragment(data)]); |
940 } | 940 } |
941 | 941 |
942 | 942 |
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 double desiredHeight; | 946 final sky.Size desiredSize; |
947 final double desiredWidth; | |
948 final int backgroundColor; | 947 final int backgroundColor; |
949 | 948 |
950 RenderSolidColor(int backgroundColor, { this.desiredHeight: double.INFINITY, | 949 RenderSolidColor(int backgroundColor, { this.desiredSize }) |
Hixie
2015/05/28 18:45:22
If it's a required argument (which it appears it n
| |
951 this.desiredWidth: double.INFINITY }) | |
952 : backgroundColor = backgroundColor, | 950 : backgroundColor = backgroundColor, |
953 super(new BoxDecoration(backgroundColor: backgroundColor)); | 951 super(new BoxDecoration(backgroundColor: backgroundColor)); |
954 | 952 |
955 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { | 953 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |
956 return new BoxDimensions.withConstraints(constraints, | 954 return new BoxDimensions.withConstraints(constraints, |
Hixie
2015/05/28 18:45:22
What if desiredSize is null?
| |
957 height: desiredHeight, | 955 width: desiredSize.width, |
958 width: desiredWidth); | 956 height: desiredSize.height); |
959 } | 957 } |
960 | 958 |
961 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { | 959 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { |
962 width = constraints.constrainWidth(desiredWidth); | 960 size = constraints.constrain(desiredSize); |
963 height = constraints.constrainHeight(desiredHeight); | |
964 layoutDone(); | 961 layoutDone(); |
965 } | 962 } |
966 | 963 |
967 void handlePointer(sky.PointerEvent event) { | 964 void handlePointer(sky.PointerEvent event) { |
968 if (event.type == 'pointerdown') | 965 if (event.type == 'pointerdown') |
969 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); | 966 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); |
970 else if (event.type == 'pointerup') | 967 else if (event.type == 'pointerup') |
971 decoration = new BoxDecoration(backgroundColor: backgroundColor); | 968 decoration = new BoxDecoration(backgroundColor: backgroundColor); |
972 } | 969 } |
973 } | 970 } |
974 | 971 |
975 class Rectangle extends RenderNodeWrapper { | 972 class Rectangle extends RenderNodeWrapper { |
976 | 973 |
977 Rectangle(this.color, { | 974 Rectangle(this.color, { |
978 Object key | 975 Object key |
979 }) : super( | 976 }) : super( |
980 key: key | 977 key: key |
981 ); | 978 ); |
982 | 979 |
983 final int color; | 980 final int color; |
984 | 981 |
985 RenderSolidColor root; | 982 RenderSolidColor root; |
986 RenderSolidColor createNode() => new RenderSolidColor(color, desiredWidth: 40. 0, desiredHeight: 130.0); | 983 RenderSolidColor createNode() => new RenderSolidColor(color, desiredSize: new sky.Size(40.0, 130.0)); |
987 | 984 |
988 static final Rectangle _emptyRectangle = new Rectangle(0); | 985 static final Rectangle _emptyRectangle = new Rectangle(0); |
989 RenderNodeWrapper get emptyNode => _emptyRectangle; | 986 RenderNodeWrapper get emptyNode => _emptyRectangle; |
990 | 987 |
991 } | 988 } |
OLD | NEW |