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 import 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
6 | 6 |
7 import 'package:sky/framework/rendering/box.dart'; | 7 import 'package:sky/framework/rendering/box.dart'; |
8 import 'package:sky/framework/rendering/flex.dart'; | 8 import 'package:sky/framework/rendering/flex.dart'; |
9 import 'package:sky/framework/scheduler.dart'; | 9 import 'package:sky/framework/scheduler.dart'; |
10 import 'package:sky/framework/widgets/raised_button.dart'; | 10 import 'package:sky/framework/widgets/raised_button.dart'; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 void rotate(double timeStamp) { | 65 void rotate(double timeStamp) { |
66 if (timeBase == null) | 66 if (timeBase == null) |
67 timeBase = timeStamp; | 67 timeBase = timeStamp; |
68 double delta = (timeStamp - timeBase) / 1000; // radians | 68 double delta = (timeStamp - timeBase) / 1000; // radians |
69 | 69 |
70 transformBox.setIdentity(); | 70 transformBox.setIdentity(); |
71 transformBox.translate(transformBox.size.width / 2.0, transformBox.size.height
/ 2.0); | 71 transformBox.translate(transformBox.size.width / 2.0, transformBox.size.height
/ 2.0); |
72 transformBox.rotateZ(delta); | 72 transformBox.rotateZ(delta); |
73 transformBox.translate(-transformBox.size.width / 2.0, -transformBox.size.heig
ht / 2.0); | 73 transformBox.translate(-transformBox.size.width / 2.0, -transformBox.size.heig
ht / 2.0); |
74 | |
75 // tester.checkFrame(); | |
76 } | 74 } |
77 | 75 |
78 final bool debugDisplayList = false; // set this to true to use the test renderi
ng logic | |
79 | |
80 void main() { | 76 void main() { |
81 // Because we're going to use UINodes, we want to initialise its | 77 // Because we're going to use UINodes, we want to initialise its |
82 // AppView, not use the default one. We don't really need to do | 78 // AppView, not use the default one. We don't really need to do |
83 // this, because RenderObjectToUINodeAdapter does it for us, but | 79 // this, because RenderObjectToUINodeAdapter does it for us, but |
84 // it's good practice in case we happen to not have a | 80 // it's good practice in case we happen to not have a |
85 // RenderObjectToUINodeAdapter in our tree at startup, or in case we | 81 // RenderObjectToUINodeAdapter in our tree at startup, or in case we |
86 // want a renderViewOverride. | 82 // want a renderViewOverride. |
87 UINodeAppView.initUINodeAppView(renderViewOverride: debugDisplayList ? tester
: null); | 83 UINodeAppView.initUINodeAppView(); |
88 | 84 |
89 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical); | 85 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical); |
90 | 86 |
91 RenderProxyBox proxy = new RenderProxyBox(); | 87 RenderProxyBox proxy = new RenderProxyBox(); |
92 new RenderObjectToUINodeAdapter(proxy, builder); // adds itself to proxy | 88 new RenderObjectToUINodeAdapter(proxy, builder); // adds itself to proxy |
93 | 89 |
94 addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFF00FF), flex: 1); | 90 addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFF00FF), flex: 1); |
95 flexRoot.add(proxy); | 91 flexRoot.add(proxy); |
96 addFlexChildSolidColor(flexRoot, const sky.Color(0xFF0000FF), flex: 1); | 92 addFlexChildSolidColor(flexRoot, const sky.Color(0xFF0000FF), flex: 1); |
97 | 93 |
98 transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.ide
ntity()); | 94 transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.ide
ntity()); |
99 RenderPadding root = new RenderPadding(padding: new EdgeDims.all(20.0), child:
transformBox); | 95 RenderPadding root = new RenderPadding(padding: new EdgeDims.all(20.0), child:
transformBox); |
100 | 96 |
101 UINodeAppView.appView.root = root; | 97 UINodeAppView.appView.root = root; |
102 addPersistentFrameCallback(rotate); | 98 addPersistentFrameCallback(rotate); |
103 } | 99 } |
OLD | NEW |