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

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

Issue 1165463002: Make RenderParagraph mutable, and make it fit the new RenderNode protocols (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: git rebase -i 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 | « no previous file | sky/examples/raw/sector-layout.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 Size desiredSize;
11 final double desiredWidth;
12 final int backgroundColor; 11 final int backgroundColor;
13 12
14 RenderSolidColor(int backgroundColor, { this.desiredHeight: double.INFINITY, 13 RenderSolidColor(int backgroundColor, { this.desiredSize: const Size.infinite( ) })
15 this.desiredWidth: double.INFINITY })
16 : backgroundColor = backgroundColor, 14 : backgroundColor = backgroundColor,
17 super(new BoxDecoration(backgroundColor: backgroundColor)); 15 super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
18 16
19 Size getIntrinsicDimensions(BoxConstraints constraints) { 17 Size getIntrinsicDimensions(BoxConstraints constraints) {
20 return constraints.constrain(new Size(desiredWidth, desiredHeight)); 18 return constraints.constrain(new Size(desiredWidth, desiredHeight));
21 } 19 }
22 20
23 void performLayout() { 21 void performLayout() {
24 width = constraints.constrainWidth(desiredWidth); 22 size = constraints.constrain(desiredSize);
25 height = constraints.constrainHeight(desiredHeight);
26 } 23 }
27 24
28 void handlePointer(PointerEvent event) { 25 void handlePointer(PointerEvent event) {
29 if (event.type == 'pointerdown') 26 if (event.type == 'pointerdown')
30 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); 27 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000);
31 else if (event.type == 'pointerup') 28 else if (event.type == 'pointerup')
32 decoration = new BoxDecoration(backgroundColor: backgroundColor); 29 decoration = new BoxDecoration(backgroundColor: backgroundColor);
33 } 30 }
34 } 31 }
35 32
36 AppView app; 33 AppView app;
37 34
38 void main() { 35 void main() {
39 var root = new RenderFlex( 36 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical);
40 direction: FlexDirection.Vertical, 37
41 decoration: new BoxDecoration(backgroundColor: 0xFF000000)); 38 RenderNode root = new RenderDecoratedBox(
39 decoration: new BoxDecoration(backgroundColor: 0xFF606060),
40 child: flexRoot
41 );
42 42
43 RenderNode child = new RenderSolidColor(0xFFFFFF00); 43 RenderNode child = new RenderSolidColor(0xFFFFFF00);
44 root.add(child); 44 flexRoot.add(child);
45 child.parentData.flex = 2; 45 child.parentData.flex = 2;
46 46
47 // The internet is a beautiful place. https://baconipsum.com/ 47 // The internet is a beautiful place. https://baconipsum.com/
48 String meatyString = """Bacon ipsum dolor amet ham fatback tri-tip, prosciutto 48 String meatyString = """Bacon ipsum dolor amet ham fatback tri-tip, prosciutto
49 porchetta bacon kevin meatball meatloaf pig beef ribs chicken. Brisket ribeye 49 porchetta bacon kevin meatball meatloaf pig beef ribs chicken. Brisket ribeye
50 andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola 50 andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola
51 alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl. 51 alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
52 Pancetta meatball tongue tenderloin rump tail jowl boudin."""; 52 Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
53 53
54 child = new RenderParagraph(meatyString); 54 child = new RenderDecoratedBox(
55 root.add(child); 55 decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF),
56 child: new RenderParagraph(text: meatyString, color: 0xFF009900)
57 );
58 flexRoot.add(child);
56 child.parentData.flex = 1; 59 child.parentData.flex = 1;
57 60
58 app = new AppView(root); 61 app = new AppView(root);
59 } 62 }
OLDNEW
« no previous file with comments | « no previous file | sky/examples/raw/sector-layout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698