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

Side by Side Diff: sky/examples/rendering/baseline.dart

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'dart:sky' as sky;
6
7 import 'package:sky/painting/text_style.dart';
8 import 'package:sky/rendering/block.dart';
9 import 'package:sky/rendering/box.dart';
10 import 'package:sky/rendering/object.dart';
11 import 'package:sky/rendering/paragraph.dart';
12 import 'package:sky/rendering/sky_binding.dart';
13
14 RenderBox getBox(double lh) {
15 RenderParagraph paragraph = new RenderParagraph(
16 new InlineStyle(
17 new TextStyle(),
18 [
19 new InlineText('test'),
20 new InlineStyle(
21 new TextStyle(
22 color: const Color(0xFF0000A0),
23 fontFamily: 'serif',
24 fontSize: 50.0,
25 height: lh
26 ),
27 [new InlineText('مرحبا Hello')]
28 )
29 ]
30 )
31 );
32 return new RenderPadding(
33 padding: new EdgeDims.all(10.0),
34 child: new RenderConstrainedBox(
35 additionalConstraints: new BoxConstraints.tightFor(height: 200.0),
36 child: new RenderDecoratedBox(
37 decoration: new BoxDecoration(
38 backgroundColor: const Color(0xFFFFFFFF)
39 ),
40 child: new RenderPadding(
41 padding: new EdgeDims.all(10.0),
42 child: new RenderCustomPaint(
43 child: paragraph,
44 callback: (canvas, size) {
45 double baseline = paragraph.getDistanceToBaseline(TextBaseline.alp habetic);
46 double w = paragraph.getMaxIntrinsicWidth(new BoxConstraints.loose (size));
47 double h = paragraph.getMaxIntrinsicHeight(new BoxConstraints.loos e(size));
48 Path path = new Path();
49 path.moveTo(0.0, 0.0);
50 path.lineTo(w, 0.0);
51 path.moveTo(0.0, baseline);
52 path.lineTo(w, baseline);
53 path.moveTo(0.0, h);
54 path.lineTo(w, h);
55 Paint paint = new Paint();
56 paint.color = const Color(0xFFFF9000);
57 paint.setStyle(sky.PaintingStyle.stroke);
58 paint.strokeWidth = 3.0;
59 canvas.drawPath(path, paint);
60 }
61 )
62 )
63 )
64 )
65 );
66 }
67
68 void main() {
69 RenderBox root = new RenderBlock(children: [
70 new RenderConstrainedBox(
71 additionalConstraints: new BoxConstraints.tightFor(height: 50.0)
72 ),
73 getBox(1.0),
74 getBox(null),
75 ]);
76 var b = new SkyBinding(root: root);
77 // b.onFrame = b.debugDumpRenderTree;
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698