Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: sky/sdk/lib/framework/fn2.dart

Issue 1156303004: Use Point, Size, and Rect in layout2.dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/framework/components2/scaffold.dart ('k') | sky/sdk/lib/framework/layout2.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 })
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,
957 height: desiredHeight, 955 width: desiredSize.width,
958 width: desiredWidth); 956 height: desiredSize.height);
959 } 957 }
960 958
961 void performLayout() { 959 void performLayout() {
962 width = constraints.constrainWidth(desiredWidth); 960 size = constraints.constrain(desiredSize);
963 height = constraints.constrainHeight(desiredHeight);
964 } 961 }
965 962
966 void handlePointer(sky.PointerEvent event) { 963 void handlePointer(sky.PointerEvent event) {
967 if (event.type == 'pointerdown') 964 if (event.type == 'pointerdown')
968 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); 965 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000);
969 else if (event.type == 'pointerup') 966 else if (event.type == 'pointerup')
970 decoration = new BoxDecoration(backgroundColor: backgroundColor); 967 decoration = new BoxDecoration(backgroundColor: backgroundColor);
971 } 968 }
972 } 969 }
973 970
974 class Rectangle extends RenderNodeWrapper { 971 class Rectangle extends RenderNodeWrapper {
975 972
976 Rectangle(this.color, { 973 Rectangle(this.color, {
977 Object key 974 Object key
978 }) : super( 975 }) : super(
979 key: key 976 key: key
980 ); 977 );
981 978
982 final int color; 979 final int color;
983 980
984 RenderSolidColor root; 981 RenderSolidColor root;
985 RenderSolidColor createNode() => new RenderSolidColor(color, desiredWidth: 40. 0, desiredHeight: 130.0); 982 RenderSolidColor createNode() => new RenderSolidColor(color, desiredSize: new sky.Size(40.0, 130.0));
986 983
987 static final Rectangle _emptyRectangle = new Rectangle(0); 984 static final Rectangle _emptyRectangle = new Rectangle(0);
988 RenderNodeWrapper get emptyNode => _emptyRectangle; 985 RenderNodeWrapper get emptyNode => _emptyRectangle;
989 986
990 } 987 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/scaffold.dart ('k') | sky/sdk/lib/framework/layout2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698