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

Side by Side Diff: sky/sdk/lib/framework/app.dart

Issue 1178703002: Abstract out the AppView logic in fn so that it can also be used in non-pure-fn apps. (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/stocks2/lib/stock_app.dart ('k') | sky/sdk/lib/framework/fn2.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' 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 = null]) {
20 assert(_app == null);
21 _app = this;
22
20 sky.view.setEventCallback(_handleEvent); 23 sky.view.setEventCallback(_handleEvent);
21 sky.view.setMetricsChangedCallback(_handleMetricsChanged); 24 sky.view.setMetricsChangedCallback(_handleMetricsChanged);
22 scheduler.init(); 25 scheduler.init();
23 scheduler.addPersistentFrameCallback(_beginFrame); 26 scheduler.addPersistentFrameCallback(_beginFrame);
24 27
25 _renderView = new RenderView(child: root); 28 _renderView = new RenderView(child: root);
26 _renderView.attach(); 29 _renderView.attach();
27 _renderView.rootConstraints = _viewConstraints; 30 _renderView.rootConstraints = _viewConstraints;
28 _renderView.scheduleInitialLayout(); 31 _renderView.scheduleInitialLayout();
32
33 assert(_app == this);
29 } 34 }
30 35
36 static AppView _app; // used to enforce that we're a singleton
37
31 RenderView _renderView; 38 RenderView _renderView;
32 39
33 ViewConstraints get _viewConstraints => 40 ViewConstraints get _viewConstraints =>
34 new ViewConstraints(width: sky.view.width, height: sky.view.height); 41 new ViewConstraints(width: sky.view.width, height: sky.view.height);
35 42
36 Map<int, PointerState> _stateForPointer = new Map<int, PointerState>(); 43 Map<int, PointerState> _stateForPointer = new Map<int, PointerState>();
37 44
38 Function onFrame; 45 Function onFrame;
39 46
40 RenderBox get root => _renderView.child; 47 RenderBox get root => _renderView.child;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 entry.target.handleEvent(event, entry); 110 entry.target.handleEvent(event, entry);
104 } 111 }
105 112
106 String toString() => 'Render Tree:\n${_renderView}'; 113 String toString() => 'Render Tree:\n${_renderView}';
107 114
108 void debugDumpRenderTree() { 115 void debugDumpRenderTree() {
109 toString().split('\n').forEach(print); 116 toString().split('\n').forEach(print);
110 } 117 }
111 118
112 } 119 }
OLDNEW
« no previous file with comments | « sky/examples/stocks2/lib/stock_app.dart ('k') | sky/sdk/lib/framework/fn2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698