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

Side by Side Diff: sky/sdk/lib/framework/components2/scaffold.dart

Issue 1161983004: Refactor layout/relayout into a single method. (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/sdk/lib/framework/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 '../fn2.dart'; 5 import '../fn2.dart';
6 import '../layout2.dart'; 6 import '../layout2.dart';
7 import '../theme/typography.dart' as typography; 7 import '../theme/typography.dart' as typography;
8 8
9 // RenderNode 9 // RenderNode
10 class RenderScaffold extends RenderDecoratedBox { 10 class RenderScaffold extends RenderDecoratedBox {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 RenderBox get floatingActionButton => _floatingActionButton; 72 RenderBox get floatingActionButton => _floatingActionButton;
73 void set floatingActionButton (RenderBox value) { 73 void set floatingActionButton (RenderBox value) {
74 if (_floatingActionButton != null) 74 if (_floatingActionButton != null)
75 dropChild(_floatingActionButton); 75 dropChild(_floatingActionButton);
76 _floatingActionButton = value; 76 _floatingActionButton = value;
77 if (_floatingActionButton != null) 77 if (_floatingActionButton != null)
78 adoptChild(_floatingActionButton); 78 adoptChild(_floatingActionButton);
79 markNeedsLayout(); 79 markNeedsLayout();
80 } 80 }
81 81
82 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { 82 bool get sizedByParent => true;
83 void performResize() {
83 width = constraints.constrainWidth(double.INFINITY); 84 width = constraints.constrainWidth(double.INFINITY);
84 assert(width < double.INFINITY); 85 assert(width < double.INFINITY);
85 height = constraints.constrainHeight(double.INFINITY); 86 height = constraints.constrainHeight(double.INFINITY);
86 assert(height < double.INFINITY); 87 assert(height < double.INFINITY);
87 relayout();
88 } 88 }
89 89
90 static const kToolbarHeight = 100.0; 90 static const kToolbarHeight = 100.0;
91 static const kStatusbarHeight = 50.0; 91 static const kStatusbarHeight = 50.0;
92 static const kButtonX = -16.0; // from right edge of body 92 static const kButtonX = -16.0; // from right edge of body
93 static const kButtonY = -16.0; // from bottom edge of body 93 static const kButtonY = -16.0; // from bottom edge of body
94 94
95 void relayout() { 95 void performLayout() {
96 double bodyHeight = height; 96 double bodyHeight = height;
97 double bodyPosition = 0.0; 97 double bodyPosition = 0.0;
98 if (toolbar != null) { 98 if (toolbar != null) {
99 toolbar.layout(new BoxConstraints.tight(width: width, height: kToolbarHeig ht)); 99 toolbar.layout(new BoxConstraints.tight(width: width, height: kToolbarHeig ht));
100 assert(toolbar.parentData is BoxParentData); 100 assert(toolbar.parentData is BoxParentData);
101 toolbar.parentData.x = 0.0; 101 toolbar.parentData.x = 0.0;
102 toolbar.parentData.y = 0.0; 102 toolbar.parentData.y = 0.0;
103 bodyPosition = kToolbarHeight; 103 bodyPosition = kToolbarHeight;
104 bodyHeight -= kToolbarHeight; 104 bodyHeight -= kToolbarHeight;
105 } 105 }
(...skipping 15 matching lines...) Expand all
121 assert(drawer.parentData is BoxParentData); 121 assert(drawer.parentData is BoxParentData);
122 drawer.parentData.x = 0.0; 122 drawer.parentData.x = 0.0;
123 drawer.parentData.y = 0.0; 123 drawer.parentData.y = 0.0;
124 } 124 }
125 if (floatingActionButton != null) { 125 if (floatingActionButton != null) {
126 floatingActionButton.layout(new BoxConstraints(minWidth: 0.0, maxWidth: wi dth, minHeight: height, maxHeight: height)); 126 floatingActionButton.layout(new BoxConstraints(minWidth: 0.0, maxWidth: wi dth, minHeight: height, maxHeight: height));
127 assert(floatingActionButton.parentData is BoxParentData); 127 assert(floatingActionButton.parentData is BoxParentData);
128 floatingActionButton.parentData.x = width - xButtonX; 128 floatingActionButton.parentData.x = width - xButtonX;
129 floatingActionButton.parentData.y = bodyPosition + bodyHeight - kButtonY; 129 floatingActionButton.parentData.y = bodyPosition + bodyHeight - kButtonY;
130 } 130 }
131 layoutDone();
132 } 131 }
133 132
134 void paint(RenderNodeDisplayList canvas) { 133 void paint(RenderNodeDisplayList canvas) {
135 if (body != null) 134 if (body != null)
136 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parent Data as BoxParentData).y); 135 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parent Data as BoxParentData).y);
137 if (statusbar != null) 136 if (statusbar != null)
138 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y); 137 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y);
139 if (toolbar != null) 138 if (toolbar != null)
140 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y); 139 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y);
141 if (floatingActionButton != null) 140 if (floatingActionButton != null)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 void syncRenderNode(UINode old) { 219 void syncRenderNode(UINode old) {
221 super.syncRenderNode(old); 220 super.syncRenderNode(old);
222 syncChild(toolbar, old is Scaffold ? old.toolbar : null, #toolbar); 221 syncChild(toolbar, old is Scaffold ? old.toolbar : null, #toolbar);
223 syncChild(body, old is Scaffold ? old.body : null, #body); 222 syncChild(body, old is Scaffold ? old.body : null, #body);
224 syncChild(statusbar, old is Scaffold ? old.statusbar : null, #statusbar); 223 syncChild(statusbar, old is Scaffold ? old.statusbar : null, #statusbar);
225 syncChild(drawer, old is Scaffold ? old.drawer : null, #drawer); 224 syncChild(drawer, old is Scaffold ? old.drawer : null, #drawer);
226 syncChild(floatingActionButton, old is Scaffold ? old.floatingActionButton : null, #floatingActionButton); 225 syncChild(floatingActionButton, old is Scaffold ? old.floatingActionButton : null, #floatingActionButton);
227 } 226 }
228 227
229 } 228 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/app.dart ('k') | sky/sdk/lib/framework/fn2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698