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 import 'rendering/box.dart'; | 6 import 'rendering/box.dart'; |
7 import 'rendering/object.dart'; | 7 import 'rendering/object.dart'; |
8 import 'scheduler.dart' as scheduler; | 8 import 'scheduler.dart' as scheduler; |
9 | 9 |
10 class PointerState { | 10 class PointerState { |
11 HitTestResult result; | 11 HitTestResult result; |
12 Point lastPosition; | 12 Point lastPosition; |
13 | 13 |
14 PointerState({ this.result, this.lastPosition }); | 14 PointerState({ this.result, this.lastPosition }); |
15 } | 15 } |
16 | 16 |
17 class AppView { | 17 class AppView { |
18 | 18 |
19 AppView(RenderBox root) { | 19 AppView(RenderBox root) { |
20 sky.view.setEventCallback(_handleEvent); | 20 sky.view.setEventCallback(_handleEvent); |
21 sky.view.setMetricsChangedCallback(_handleMetricsChanged); | 21 sky.view.setMetricsChangedCallback(_handleMetricsChanged); |
22 scheduler.init(); | 22 scheduler.init(); |
23 scheduler.addPersistentFrameCallback(_beginFrame); | 23 scheduler.addPersistentFrameCallback(_beginFrame); |
24 | 24 |
25 _renderView = new RenderView(child: root); | 25 _renderView = new RenderView(child: root); |
26 _renderView.attach(); | 26 _renderView.attach(); |
27 _renderView.rootConstraints = _viewConstraints; | 27 _renderView.rootConstraints = _viewConstraints; |
28 _renderView.layout(_renderView.rootConstraints); | 28 _renderView.scheduleInitialLayout(); |
29 } | 29 } |
30 | 30 |
31 RenderView _renderView; | 31 RenderView _renderView; |
32 | 32 |
33 ViewConstraints get _viewConstraints => | 33 ViewConstraints get _viewConstraints => |
34 new ViewConstraints(width: sky.view.width, height: sky.view.height); | 34 new ViewConstraints(width: sky.view.width, height: sky.view.height); |
35 | 35 |
36 Map<int, PointerState> _stateForPointer = new Map<int, PointerState>(); | 36 Map<int, PointerState> _stateForPointer = new Map<int, PointerState>(); |
37 | 37 |
38 Function onFrame; | 38 Function onFrame; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 node.handleEvent(event); | 103 node.handleEvent(event); |
104 } | 104 } |
105 | 105 |
106 String toString() => 'Render Tree:\n${_renderView}'; | 106 String toString() => 'Render Tree:\n${_renderView}'; |
107 | 107 |
108 void debugDumpRenderTree() { | 108 void debugDumpRenderTree() { |
109 toString().split('\n').forEach(print); | 109 toString().split('\n').forEach(print); |
110 } | 110 } |
111 | 111 |
112 } | 112 } |
OLD | NEW |