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

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

Issue 1161323004: Export Point, Size, Rect, Color, Paint, Path, BoxDecoration, Border, BorderSide, EdgeDims, and Flex… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: without analyser changes 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
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 'dart:sky' as sky;
7 import '../rendering/box.dart'; 6 import '../rendering/box.dart';
8 import '../rendering/object.dart'; 7 import '../rendering/object.dart';
9 8
10
11 enum ScaffoldSlots { 9 enum ScaffoldSlots {
12 toolbar, 10 toolbar,
13 body, 11 body,
14 statusBar, 12 statusBar,
15 drawer, 13 drawer,
16 floatingActionButton 14 floatingActionButton
17 } 15 }
18 16
19 class RenderScaffold extends RenderBox { 17 class RenderScaffold extends RenderBox {
20 18
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (_slots[slot] == child) { 66 if (_slots[slot] == child) {
69 this[slot] = null; 67 this[slot] = null;
70 return slot; 68 return slot;
71 } 69 }
72 } 70 }
73 return null; 71 return null;
74 } 72 }
75 73
76 bool get sizedByParent => true; 74 bool get sizedByParent => true;
77 void performResize() { 75 void performResize() {
78 size = constraints.constrain(sky.Size.infinite); 76 size = constraints.constrain(Size.infinite);
79 assert(size.width < double.INFINITY); 77 assert(size.width < double.INFINITY);
80 assert(size.height < double.INFINITY); 78 assert(size.height < double.INFINITY);
81 } 79 }
82 80
83 static const kToolbarHeight = 100.0; 81 static const kToolbarHeight = 100.0;
84 static const kStatusbarHeight = 50.0; 82 static const kStatusbarHeight = 50.0;
85 static const kButtonX = -16.0; // from right edge of body 83 static const kButtonX = -16.0; // from right edge of body
86 static const kButtonY = -16.0; // from bottom edge of body 84 static const kButtonY = -16.0; // from bottom edge of body
87 85
88 void performLayout() { 86 void performLayout() {
89 double bodyHeight = size.height; 87 double bodyHeight = size.height;
90 double bodyPosition = 0.0; 88 double bodyPosition = 0.0;
91 if (_slots[ScaffoldSlots.toolbar] != null) { 89 if (_slots[ScaffoldSlots.toolbar] != null) {
92 RenderBox toolbar = _slots[ScaffoldSlots.toolbar]; 90 RenderBox toolbar = _slots[ScaffoldSlots.toolbar];
93 toolbar.layout(new BoxConstraints.tight(new sky.Size(size.width, kToolbarH eight))); 91 toolbar.layout(new BoxConstraints.tight(new Size(size.width, kToolbarHeigh t)));
94 assert(toolbar.parentData is BoxParentData); 92 assert(toolbar.parentData is BoxParentData);
95 toolbar.parentData.position = new sky.Point(0.0, 0.0); 93 toolbar.parentData.position = new Point(0.0, 0.0);
96 bodyPosition = kToolbarHeight; 94 bodyPosition = kToolbarHeight;
97 bodyHeight -= kToolbarHeight; 95 bodyHeight -= kToolbarHeight;
98 } 96 }
99 if (_slots[ScaffoldSlots.statusBar] != null) { 97 if (_slots[ScaffoldSlots.statusBar] != null) {
100 RenderBox statusbar = _slots[ScaffoldSlots.statusBar]; 98 RenderBox statusbar = _slots[ScaffoldSlots.statusBar];
101 statusbar.layout(new BoxConstraints.tight(new sky.Size(size.width, kStatus barHeight))); 99 statusbar.layout(new BoxConstraints.tight(new Size(size.width, kStatusbarH eight)));
102 assert(statusbar.parentData is BoxParentData); 100 assert(statusbar.parentData is BoxParentData);
103 statusbar.parentData.position = new sky.Point(0.0, size.height - kStatusba rHeight); 101 statusbar.parentData.position = new Point(0.0, size.height - kStatusbarHei ght);
104 bodyHeight -= kStatusbarHeight; 102 bodyHeight -= kStatusbarHeight;
105 } 103 }
106 if (_slots[ScaffoldSlots.body] != null) { 104 if (_slots[ScaffoldSlots.body] != null) {
107 RenderBox body = _slots[ScaffoldSlots.body]; 105 RenderBox body = _slots[ScaffoldSlots.body];
108 body.layout(new BoxConstraints.tight(new sky.Size(size.width, bodyHeight)) ); 106 body.layout(new BoxConstraints.tight(new Size(size.width, bodyHeight)));
109 assert(body.parentData is BoxParentData); 107 assert(body.parentData is BoxParentData);
110 body.parentData.position = new sky.Point(0.0, bodyPosition); 108 body.parentData.position = new Point(0.0, bodyPosition);
111 } 109 }
112 if (_slots[ScaffoldSlots.drawer] != null) { 110 if (_slots[ScaffoldSlots.drawer] != null) {
113 RenderBox drawer = _slots[ScaffoldSlots.drawer]; 111 RenderBox drawer = _slots[ScaffoldSlots.drawer];
114 drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: size.width, minH eight: size.height, maxHeight: size.height)); 112 drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: size.width, minH eight: size.height, maxHeight: size.height));
115 assert(drawer.parentData is BoxParentData); 113 assert(drawer.parentData is BoxParentData);
116 drawer.parentData.position = new sky.Point(0.0, 0.0); 114 drawer.parentData.position = new Point(0.0, 0.0);
117 } 115 }
118 if (_slots[ScaffoldSlots.floatingActionButton] != null) { 116 if (_slots[ScaffoldSlots.floatingActionButton] != null) {
119 RenderBox floatingActionButton = _slots[ScaffoldSlots.floatingActionButton ]; 117 RenderBox floatingActionButton = _slots[ScaffoldSlots.floatingActionButton ];
120 sky.Size area = new sky.Size(size.width + kButtonX, size.height + kButtonY ); 118 sky.Size area = new sky.Size(size.width + kButtonX, size.height + kButtonY );
121 floatingActionButton.layout(new BoxConstraints.loose(area)); 119 floatingActionButton.layout(new BoxConstraints.loose(area));
122 assert(floatingActionButton.parentData is BoxParentData); 120 assert(floatingActionButton.parentData is BoxParentData);
123 floatingActionButton.parentData.position = (area - floatingActionButton.si ze).toPoint(); 121 floatingActionButton.parentData.position = (area - floatingActionButton.si ze).toPoint();
124 } 122 }
125 } 123 }
126 124
127 void paint(RenderObjectDisplayList canvas) { 125 void paint(RenderObjectDisplayList canvas) {
128 for (ScaffoldSlots slot in [ScaffoldSlots.body, ScaffoldSlots.statusBar, Sca ffoldSlots.toolbar, ScaffoldSlots.floatingActionButton, ScaffoldSlots.drawer]) { 126 for (ScaffoldSlots slot in [ScaffoldSlots.body, ScaffoldSlots.statusBar, Sca ffoldSlots.toolbar, ScaffoldSlots.floatingActionButton, ScaffoldSlots.drawer]) {
129 RenderBox box = _slots[slot]; 127 RenderBox box = _slots[slot];
130 if (box != null) { 128 if (box != null) {
131 assert(box.parentData is BoxParentData); 129 assert(box.parentData is BoxParentData);
132 canvas.paintChild(box, box.parentData.position); 130 canvas.paintChild(box, box.parentData.position);
133 } 131 }
134 } 132 }
135 } 133 }
136 134
137 void hitTestChildren(HitTestResult result, { sky.Point position }) { 135 void hitTestChildren(HitTestResult result, { Point position }) {
138 for (ScaffoldSlots slot in [ScaffoldSlots.drawer, ScaffoldSlots.floatingActi onButton, ScaffoldSlots.toolbar, ScaffoldSlots.statusBar, ScaffoldSlots.body]) { 136 for (ScaffoldSlots slot in [ScaffoldSlots.drawer, ScaffoldSlots.floatingActi onButton, ScaffoldSlots.toolbar, ScaffoldSlots.statusBar, ScaffoldSlots.body]) {
139 RenderBox box = _slots[slot]; 137 RenderBox box = _slots[slot];
140 if (box != null) { 138 if (box != null) {
141 assert(box.parentData is BoxParentData); 139 assert(box.parentData is BoxParentData);
142 if (new sky.Rect.fromPointAndSize(box.parentData.position, box.size).con tains(position)) { 140 if (new Rect.fromPointAndSize(box.parentData.position, box.size).contain s(position)) {
143 if (box.hitTest(result, position: (position - box.parentData.position) .toPoint())) 141 if (box.hitTest(result, position: (position - box.parentData.position) .toPoint()))
144 return; 142 return;
145 } 143 }
146 } 144 }
147 } 145 }
148 } 146 }
149 147
150 String debugDescribeChildren(String prefix) { 148 String debugDescribeChildren(String prefix) {
151 return _slots.keys.map((slot) => '${prefix}${slot}: ${_slots[slot].toString( prefix)}').join(); 149 return _slots.keys.map((slot) => '${prefix}${slot}: ${_slots[slot].toString( prefix)}').join();
152 } 150 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void syncRenderObject(UINode old) { 203 void syncRenderObject(UINode old) {
206 super.syncRenderObject(old); 204 super.syncRenderObject(old);
207 syncChild(toolbar, old is Scaffold ? old.toolbar : null, ScaffoldSlots.toolb ar); 205 syncChild(toolbar, old is Scaffold ? old.toolbar : null, ScaffoldSlots.toolb ar);
208 syncChild(body, old is Scaffold ? old.body : null, ScaffoldSlots.body); 206 syncChild(body, old is Scaffold ? old.body : null, ScaffoldSlots.body);
209 syncChild(statusbar, old is Scaffold ? old.statusbar : null, ScaffoldSlots.s tatusBar); 207 syncChild(statusbar, old is Scaffold ? old.statusbar : null, ScaffoldSlots.s tatusBar);
210 syncChild(drawer, old is Scaffold ? old.drawer : null, ScaffoldSlots.drawer) ; 208 syncChild(drawer, old is Scaffold ? old.drawer : null, ScaffoldSlots.drawer) ;
211 syncChild(floatingActionButton, old is Scaffold ? old.floatingActionButton : null, ScaffoldSlots.floatingActionButton); 209 syncChild(floatingActionButton, old is Scaffold ? old.floatingActionButton : null, ScaffoldSlots.floatingActionButton);
212 } 210 }
213 211
214 } 212 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/radio.dart ('k') | sky/sdk/lib/framework/components2/tool_bar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698