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

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

Issue 1209413004: Instead of applying a transform for every RenderObject, pass down an Offset for where to paint. (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
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 '../rendering/box.dart'; 5 import '../rendering/box.dart';
6 import '../rendering/object.dart'; 6 import '../rendering/object.dart';
7 import '../theme/view_configuration.dart'; 7 import '../theme/view_configuration.dart';
8 import 'widget.dart'; 8 import 'widget.dart';
9 9
10 enum ScaffoldSlots { 10 enum ScaffoldSlots {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 if (_slots[ScaffoldSlots.floatingActionButton] != null) { 120 if (_slots[ScaffoldSlots.floatingActionButton] != null) {
121 RenderBox floatingActionButton = _slots[ScaffoldSlots.floatingActionButton ]; 121 RenderBox floatingActionButton = _slots[ScaffoldSlots.floatingActionButton ];
122 Size area = new Size(size.width - kButtonX, size.height - kButtonY); 122 Size area = new Size(size.width - kButtonX, size.height - kButtonY);
123 floatingActionButton.layout(new BoxConstraints.loose(area), parentUsesSize : true); 123 floatingActionButton.layout(new BoxConstraints.loose(area), parentUsesSize : true);
124 assert(floatingActionButton.parentData is BoxParentData); 124 assert(floatingActionButton.parentData is BoxParentData);
125 floatingActionButton.parentData.position = (area - floatingActionButton.si ze).toPoint(); 125 floatingActionButton.parentData.position = (area - floatingActionButton.si ze).toPoint();
126 } 126 }
127 } 127 }
128 128
129 void paint(RenderCanvas canvas) { 129 void paint(RenderCanvas canvas, Offset offset) {
130 for (ScaffoldSlots slot in [ScaffoldSlots.body, ScaffoldSlots.statusBar, Sca ffoldSlots.toolbar, ScaffoldSlots.floatingActionButton, ScaffoldSlots.drawer]) { 130 for (ScaffoldSlots slot in [ScaffoldSlots.body, ScaffoldSlots.statusBar, Sca ffoldSlots.toolbar, ScaffoldSlots.floatingActionButton, ScaffoldSlots.drawer]) {
131 RenderBox box = _slots[slot]; 131 RenderBox box = _slots[slot];
132 if (box != null) { 132 if (box != null) {
133 assert(box.parentData is BoxParentData); 133 assert(box.parentData is BoxParentData);
134 canvas.paintChild(box, box.parentData.position); 134 canvas.paintChild(box, box.parentData.position + offset);
135 } 135 }
136 } 136 }
137 } 137 }
138 138
139 void hitTestChildren(HitTestResult result, { Point position }) { 139 void hitTestChildren(HitTestResult result, { Point position }) {
140 for (ScaffoldSlots slot in [ScaffoldSlots.drawer, ScaffoldSlots.floatingActi onButton, ScaffoldSlots.toolbar, ScaffoldSlots.statusBar, ScaffoldSlots.body]) { 140 for (ScaffoldSlots slot in [ScaffoldSlots.drawer, ScaffoldSlots.floatingActi onButton, ScaffoldSlots.toolbar, ScaffoldSlots.statusBar, ScaffoldSlots.body]) {
141 RenderBox box = _slots[slot]; 141 RenderBox box = _slots[slot];
142 if (box != null) { 142 if (box != null) {
143 assert(box.parentData is BoxParentData); 143 assert(box.parentData is BoxParentData);
144 if (new Rect.fromPointAndSize(box.parentData.position, box.size).contain s(position)) { 144 if (new Rect.fromPointAndSize(box.parentData.position, box.size).contain s(position)) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 void syncRenderObject(Widget old) { 216 void syncRenderObject(Widget old) {
217 super.syncRenderObject(old); 217 super.syncRenderObject(old);
218 _toolbar = syncChild(_toolbar, old is Scaffold ? old._toolbar : null, Scaffo ldSlots.toolbar); 218 _toolbar = syncChild(_toolbar, old is Scaffold ? old._toolbar : null, Scaffo ldSlots.toolbar);
219 _body = syncChild(_body, old is Scaffold ? old._body : null, ScaffoldSlots.b ody); 219 _body = syncChild(_body, old is Scaffold ? old._body : null, ScaffoldSlots.b ody);
220 _statusBar = syncChild(_statusBar, old is Scaffold ? old._statusBar : null, ScaffoldSlots.statusBar); 220 _statusBar = syncChild(_statusBar, old is Scaffold ? old._statusBar : null, ScaffoldSlots.statusBar);
221 _drawer = syncChild(_drawer, old is Scaffold ? old._drawer : null, ScaffoldS lots.drawer); 221 _drawer = syncChild(_drawer, old is Scaffold ? old._drawer : null, ScaffoldS lots.drawer);
222 _floatingActionButton = syncChild(_floatingActionButton, old is Scaffold ? o ld._floatingActionButton : null, ScaffoldSlots.floatingActionButton); 222 _floatingActionButton = syncChild(_floatingActionButton, old is Scaffold ? o ld._floatingActionButton : null, ScaffoldSlots.floatingActionButton);
223 } 223 }
224 224
225 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698