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

Side by Side Diff: sky/examples/raw/simple_render_tree.dart

Issue 1161983004: Refactor layout/relayout into a single method. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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/examples/raw/sector-layout.dart ('k') | sky/sdk/lib/framework/app.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 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 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) {
20 return new BoxDimensions.withConstraints(constraints, 20 return new BoxDimensions.withConstraints(constraints,
21 height: desiredHeight, 21 height: desiredHeight,
22 width: desiredWidth); 22 width: desiredWidth);
23 } 23 }
24 24
25 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { 25 void performLayout() {
26 width = constraints.constrainWidth(desiredWidth); 26 width = constraints.constrainWidth(desiredWidth);
27 height = constraints.constrainHeight(desiredHeight); 27 height = constraints.constrainHeight(desiredHeight);
28 layoutDone();
29 } 28 }
30 29
31 void handlePointer(PointerEvent event) { 30 void handlePointer(PointerEvent event) {
32 if (event.type == 'pointerdown') 31 if (event.type == 'pointerdown')
33 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); 32 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000);
34 else if (event.type == 'pointerup') 33 else if (event.type == 'pointerup')
35 decoration = new BoxDecoration(backgroundColor: backgroundColor); 34 decoration = new BoxDecoration(backgroundColor: backgroundColor);
36 } 35 }
37 } 36 }
38 37
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Purple and blue cells 69 // Purple and blue cells
71 addFlexChild(row, 0x77FF00FF, flex: 1); 70 addFlexChild(row, 0x77FF00FF, flex: 1);
72 addFlexChild(row, 0xFF0000FF, flex: 2); 71 addFlexChild(row, 0xFF0000FF, flex: 2);
73 72
74 root.add(row); 73 root.add(row);
75 row.parentData.flex = 3; 74 row.parentData.flex = 3;
76 75
77 app = new AppView(root); 76 app = new AppView(root);
78 77
79 } 78 }
OLDNEW
« no previous file with comments | « sky/examples/raw/sector-layout.dart ('k') | sky/sdk/lib/framework/app.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698