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

Side by Side Diff: sky/sdk/lib/widgets/scaffold.dart

Issue 1226113007: Add @override annotation to known overriden methods (Closed) Base URL: https://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
« no previous file with comments | « sky/sdk/lib/widgets/raised_button.dart ('k') | sky/sdk/lib/widgets/scrollable.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 6
7 import '../rendering/box.dart'; 7 import '../rendering/box.dart';
8 import '../rendering/object.dart'; 8 import '../rendering/object.dart';
9 import '../theme/view_configuration.dart'; 9 import '../theme/view_configuration.dart';
10 import 'widget.dart'; 10 import 'widget.dart';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 dropChild(old); 47 dropChild(old);
48 if (value == null) { 48 if (value == null) {
49 _slots.remove(slot); 49 _slots.remove(slot);
50 } else { 50 } else {
51 _slots[slot] = value; 51 _slots[slot] = value;
52 adoptChild(value); 52 adoptChild(value);
53 } 53 }
54 markNeedsLayout(); 54 markNeedsLayout();
55 } 55 }
56 56
57 @override
57 void attachChildren() { 58 void attachChildren() {
58 for (ScaffoldSlots slot in ScaffoldSlots.values) { 59 for (ScaffoldSlots slot in ScaffoldSlots.values) {
59 RenderBox box = _slots[slot]; 60 RenderBox box = _slots[slot];
60 if (box != null) 61 if (box != null)
61 box.attach(); 62 box.attach();
62 } 63 }
63 } 64 }
64 65
66 @override
65 void detachChildren() { 67 void detachChildren() {
66 for (ScaffoldSlots slot in ScaffoldSlots.values) { 68 for (ScaffoldSlots slot in ScaffoldSlots.values) {
67 RenderBox box = _slots[slot]; 69 RenderBox box = _slots[slot];
68 if (box != null) 70 if (box != null)
69 box.detach(); 71 box.detach();
70 } 72 }
71 } 73 }
72 74
73 ScaffoldSlots remove(RenderBox child) { 75 ScaffoldSlots remove(RenderBox child) {
74 assert(child != null); 76 assert(child != null);
75 for (ScaffoldSlots slot in ScaffoldSlots.values) { 77 for (ScaffoldSlots slot in ScaffoldSlots.values) {
76 if (_slots[slot] == child) { 78 if (_slots[slot] == child) {
77 this[slot] = null; 79 this[slot] = null;
78 return slot; 80 return slot;
79 } 81 }
80 } 82 }
81 return null; 83 return null;
82 } 84 }
83 85
86 @override
84 bool get sizedByParent => true; 87 bool get sizedByParent => true;
88
89 @override
85 void performResize() { 90 void performResize() {
86 size = constraints.biggest; 91 size = constraints.biggest;
87 assert(!size.isInfinite); 92 assert(!size.isInfinite);
88 } 93 }
89 94
90 // TODO(eseidel): These change based on device size! 95 // TODO(eseidel): These change based on device size!
91 // http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keyl ines-keylines-spacing 96 // http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keyl ines-keylines-spacing
92 static const kButtonX = 16.0; // left from right edge of body 97 static const kButtonX = 16.0; // left from right edge of body
93 static const kButtonY = 16.0; // up from bottom edge of body 98 static const kButtonY = 16.0; // up from bottom edge of body
94 99
100 @override
95 void performLayout() { 101 void performLayout() {
96 double bodyHeight = size.height; 102 double bodyHeight = size.height;
97 double bodyPosition = 0.0; 103 double bodyPosition = 0.0;
98 if (_slots[ScaffoldSlots.statusBar] != null) { 104 if (_slots[ScaffoldSlots.statusBar] != null) {
99 RenderBox statusBar = _slots[ScaffoldSlots.statusBar]; 105 RenderBox statusBar = _slots[ScaffoldSlots.statusBar];
100 statusBar.layout(new BoxConstraints.tight(new Size(size.width, kStatusBarH eight))); 106 statusBar.layout(new BoxConstraints.tight(new Size(size.width, kStatusBarH eight)));
101 assert(statusBar.parentData is BoxParentData); 107 assert(statusBar.parentData is BoxParentData);
102 statusBar.parentData.position = new Point(0.0, size.height - kStatusBarHei ght); 108 statusBar.parentData.position = new Point(0.0, size.height - kStatusBarHei ght);
103 bodyHeight -= kStatusBarHeight; 109 bodyHeight -= kStatusBarHeight;
104 } 110 }
(...skipping 30 matching lines...) Expand all
135 floatingActionButton.parentData.position = (area - floatingActionButton.si ze).toPoint(); 141 floatingActionButton.parentData.position = (area - floatingActionButton.si ze).toPoint();
136 } 142 }
137 if (_slots[ScaffoldSlots.drawer] != null) { 143 if (_slots[ScaffoldSlots.drawer] != null) {
138 RenderBox drawer = _slots[ScaffoldSlots.drawer]; 144 RenderBox drawer = _slots[ScaffoldSlots.drawer];
139 drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: size.width, minH eight: size.height, maxHeight: size.height)); 145 drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: size.width, minH eight: size.height, maxHeight: size.height));
140 assert(drawer.parentData is BoxParentData); 146 assert(drawer.parentData is BoxParentData);
141 drawer.parentData.position = Point.origin; 147 drawer.parentData.position = Point.origin;
142 } 148 }
143 } 149 }
144 150
151 @override
145 void paint(PaintingCanvas canvas, Offset offset) { 152 void paint(PaintingCanvas canvas, Offset offset) {
146 for (ScaffoldSlots slot in ScaffoldSlots.values) { 153 for (ScaffoldSlots slot in ScaffoldSlots.values) {
147 RenderBox box = _slots[slot]; 154 RenderBox box = _slots[slot];
148 if (box != null) { 155 if (box != null) {
149 assert(box.parentData is BoxParentData); 156 assert(box.parentData is BoxParentData);
150 canvas.paintChild(box, box.parentData.position + offset); 157 canvas.paintChild(box, box.parentData.position + offset);
151 } 158 }
152 } 159 }
153 } 160 }
154 161
162 @override
155 void hitTestChildren(HitTestResult result, { Point position }) { 163 void hitTestChildren(HitTestResult result, { Point position }) {
156 for (ScaffoldSlots slot in ScaffoldSlots.values.reversed) { 164 for (ScaffoldSlots slot in ScaffoldSlots.values.reversed) {
157 RenderBox box = _slots[slot]; 165 RenderBox box = _slots[slot];
158 if (box != null) { 166 if (box != null) {
159 assert(box.parentData is BoxParentData); 167 assert(box.parentData is BoxParentData);
160 if ((box.parentData.position & box.size).contains(position)) { 168 if ((box.parentData.position & box.size).contains(position)) {
161 if (box.hitTest(result, position: (position - box.parentData.position) .toPoint())) 169 if (box.hitTest(result, position: (position - box.parentData.position) .toPoint()))
162 return; 170 return;
163 } 171 }
164 } 172 }
165 } 173 }
166 } 174 }
167 175
176 @override
168 String debugDescribeChildren(String prefix) { 177 String debugDescribeChildren(String prefix) {
169 return _slots.keys.map((slot) => '${prefix}${slot}: ${_slots[slot].toString( prefix)}').join(); 178 return _slots.keys.map((slot) => '${prefix}${slot}: ${_slots[slot].toString( prefix)}').join();
170 } 179 }
171 } 180 }
172 181
173 class Scaffold extends RenderObjectWrapper { 182 class Scaffold extends RenderObjectWrapper {
174 183
175 Scaffold({ 184 Scaffold({
176 String key, 185 String key,
177 Widget body, 186 Widget body,
178 Widget statusBar, 187 Widget statusBar,
179 Widget toolbar, 188 Widget toolbar,
180 Widget snackBar, 189 Widget snackBar,
181 Widget floatingActionButton, 190 Widget floatingActionButton,
182 Widget drawer 191 Widget drawer
183 }) : super(key: key) { 192 }) : super(key: key) {
184 _slots[ScaffoldSlots.body] = body; 193 _slots[ScaffoldSlots.body] = body;
185 _slots[ScaffoldSlots.statusBar] = statusBar; 194 _slots[ScaffoldSlots.statusBar] = statusBar;
186 _slots[ScaffoldSlots.toolbar] = toolbar; 195 _slots[ScaffoldSlots.toolbar] = toolbar;
187 _slots[ScaffoldSlots.snackBar] = snackBar; 196 _slots[ScaffoldSlots.snackBar] = snackBar;
188 _slots[ScaffoldSlots.floatingActionButton] = floatingActionButton; 197 _slots[ScaffoldSlots.floatingActionButton] = floatingActionButton;
189 _slots[ScaffoldSlots.drawer] = drawer; 198 _slots[ScaffoldSlots.drawer] = drawer;
190 } 199 }
191 200
192 Map<ScaffoldSlots, Widget> _slots = new Map<ScaffoldSlots, Widget>(); 201 Map<ScaffoldSlots, Widget> _slots = new Map<ScaffoldSlots, Widget>();
193 202
203 @override
194 RenderScaffold get root => super.root; 204 RenderScaffold get root => super.root;
205
206 @override
195 RenderScaffold createNode() => new RenderScaffold(); 207 RenderScaffold createNode() => new RenderScaffold();
196 208
209 @override
197 void walkChildren(WidgetTreeWalker walker) { 210 void walkChildren(WidgetTreeWalker walker) {
198 for (ScaffoldSlots slot in ScaffoldSlots.values) { 211 for (ScaffoldSlots slot in ScaffoldSlots.values) {
199 Widget widget = _slots[slot]; 212 Widget widget = _slots[slot];
200 if (widget != null) 213 if (widget != null)
201 walker(widget); 214 walker(widget);
202 } 215 }
203 } 216 }
204 217
218 @override
205 void insertChildRoot(RenderObjectWrapper child, ScaffoldSlots slot) { 219 void insertChildRoot(RenderObjectWrapper child, ScaffoldSlots slot) {
206 root[slot] = child != null ? child.root : null; 220 root[slot] = child != null ? child.root : null;
207 } 221 }
208 222
223 @override
209 void detachChildRoot(RenderObjectWrapper child) { 224 void detachChildRoot(RenderObjectWrapper child) {
210 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer 225 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer
211 assert(root is RenderScaffold); 226 assert(root is RenderScaffold);
212 assert(root == child.root.parent); 227 assert(root == child.root.parent);
213 root.remove(child.root); 228 root.remove(child.root);
214 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer 229 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer
215 } 230 }
216 231
232 @override
217 void remove() { 233 void remove() {
218 walkChildren((Widget child) => removeChild(child)); 234 walkChildren((Widget child) => removeChild(child));
219 super.remove(); 235 super.remove();
220 } 236 }
221 237
238 @override
222 void syncRenderObject(Widget old) { 239 void syncRenderObject(Widget old) {
223 super.syncRenderObject(old); 240 super.syncRenderObject(old);
224 for (ScaffoldSlots slot in ScaffoldSlots.values) { 241 for (ScaffoldSlots slot in ScaffoldSlots.values) {
225 Widget widget = _slots[slot]; 242 Widget widget = _slots[slot];
226 _slots[slot] = syncChild(widget, old is Scaffold ? old._slots[slot] : null , slot); 243 _slots[slot] = syncChild(widget, old is Scaffold ? old._slots[slot] : null , slot);
227 assert((_slots[slot] == null) == (widget == null)); 244 assert((_slots[slot] == null) == (widget == null));
228 assert(_slots[slot] == null || _slots[slot].parent == this); 245 assert(_slots[slot] == null || _slots[slot].parent == this);
229 } 246 }
230 } 247 }
231 248
232 } 249 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/raised_button.dart ('k') | sky/sdk/lib/widgets/scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698