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

Side by Side Diff: sky/examples/lib/solid_color_box.dart

Issue 1167293003: Split getIntrinsicDimensions into four pieces (Closed) Base URL: git@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
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'; 5 import 'dart:sky';
6 import 'package:sky/framework/rendering/box.dart'; 6 import 'package:sky/framework/rendering/box.dart';
7 7
8 class RenderSolidColorBox extends RenderDecoratedBox { 8 class RenderSolidColorBox extends RenderDecoratedBox {
9 final Size desiredSize; 9 final Size desiredSize;
10 final Color backgroundColor; 10 final Color backgroundColor;
11 11
12 RenderSolidColorBox(Color backgroundColor, { this.desiredSize: const Size.infi nite() }) 12 RenderSolidColorBox(Color backgroundColor, { this.desiredSize: const Size.infi nite() })
13 : backgroundColor = backgroundColor, 13 : backgroundColor = backgroundColor,
14 super(decoration: new BoxDecoration(backgroundColor: backgroundColor)); 14 super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
15 15
16 Size getIntrinsicDimensions(BoxConstraints constraints) { 16 double getMinIntrinsicWidth(BoxConstraints constraints) {
Hixie 2015/06/08 21:35:32 this seems wrong.
17 return constraints.constrain(desiredSize); 17 return constraints.constrain(desiredSize.width);
18 }
19
20 double getMaxIntrinsicWidth(BoxConstraints constraints) {
21 return constraints.constrain(desiredSize.width);
22 }
23
24 double getMinIntrinsicHeight(BoxConstraints constraints) {
25 return constraints.constrain(desiredSize.height);
26 }
27
28 double getMaxIntrinsicHeight(BoxConstraints constraints) {
29 return constraints.constrain(desiredSize.height);
18 } 30 }
19 31
20 void performLayout() { 32 void performLayout() {
21 size = constraints.constrain(desiredSize); 33 size = constraints.constrain(desiredSize);
22 } 34 }
23 35
24 void handlePointer(PointerEvent event) { 36 void handlePointer(PointerEvent event) {
25 if (event.type == 'pointerdown') 37 if (event.type == 'pointerdown')
26 decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000)); 38 decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
27 else if (event.type == 'pointerup') 39 else if (event.type == 'pointerup')
28 decoration = new BoxDecoration(backgroundColor: backgroundColor); 40 decoration = new BoxDecoration(backgroundColor: backgroundColor);
29 } 41 }
30 } 42 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/framework/rendering/block.dart » ('j') | sky/sdk/lib/framework/rendering/block.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698