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

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

Issue 1190793002: Rename UINode to Widget. (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/widgets/navigator.dart ('k') | sky/sdk/lib/widgets/popup_menu_item.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:async'; 5 import 'dart:async';
6 import 'dart:math' as math; 6 import 'dart:math' as math;
7 import 'dart:sky' as sky; 7 import 'dart:sky' as sky;
8 8
9 import '../framework/animation/animated_value.dart'; 9 import '../framework/animation/animated_value.dart';
10 import '../painting/box_painter.dart'; 10 import '../painting/box_painter.dart';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 backgroundColor: Grey[50], 60 backgroundColor: Grey[50],
61 borderRadius: 2.0, 61 borderRadius: 2.0,
62 boxShadow: shadows[level])); 62 boxShadow: shadows[level]));
63 63
64 animate(controller.position, (double value) { 64 animate(controller.position, (double value) {
65 _position = value; 65 _position = value;
66 }); 66 });
67 } 67 }
68 68
69 PopupMenuController controller; 69 PopupMenuController controller;
70 List<UINode> items; 70 List<Widget> items;
71 int level; 71 int level;
72 72
73 void syncFields(PopupMenu source) { 73 void syncFields(PopupMenu source) {
74 controller = source.controller; 74 controller = source.controller;
75 items = source.items; 75 items = source.items;
76 level = source.level; 76 level = source.level;
77 _painter = source._painter; 77 _painter = source._painter;
78 super.syncFields(source); 78 super.syncFields(source);
79 } 79 }
80 80
81 double _position; 81 double _position;
82 BoxPainter _painter; 82 BoxPainter _painter;
83 83
84 double _opacityFor(int i) { 84 double _opacityFor(int i) {
85 if (_position == null || _position == 1.0) 85 if (_position == null || _position == 1.0)
86 return 1.0; 86 return 1.0;
87 double unit = 1.0 / items.length; 87 double unit = 1.0 / items.length;
88 double duration = 1.5 * unit; 88 double duration = 1.5 * unit;
89 double start = i * unit; 89 double start = i * unit;
90 return math.max(0.0, math.min(1.0, (_position - start) / duration)); 90 return math.max(0.0, math.min(1.0, (_position - start) / duration));
91 } 91 }
92 92
93 UINode build() { 93 Widget build() {
94 int i = 0; 94 int i = 0;
95 List<UINode> children = new List.from(items.map((UINode item) { 95 List<Widget> children = new List.from(items.map((Widget item) {
96 double opacity = _opacityFor(i); 96 double opacity = _opacityFor(i);
97 return new PopupMenuItem(key: '${key}-${item.key}', 97 return new PopupMenuItem(key: '${key}-${item.key}',
98 child: item, 98 child: item,
99 opacity: opacity); 99 opacity: opacity);
100 })); 100 }));
101 101
102 return new Opacity( 102 return new Opacity(
103 opacity: math.min(1.0, _position * 3.0), 103 opacity: math.min(1.0, _position * 3.0),
104 child: new ShrinkWrapWidth( 104 child: new ShrinkWrapWidth(
105 child: new CustomPaint( 105 child: new CustomPaint(
106 callback: (sky.Canvas canvas, Size size) { 106 callback: (sky.Canvas canvas, Size size) {
107 double width = math.min(size.width, size.width * (0.5 + _position * 2.0)); 107 double width = math.min(size.width, size.width * (0.5 + _position * 2.0));
108 double height = math.min(size.height, size.height * _position * 1.5) ; 108 double height = math.min(size.height, size.height * _position * 1.5) ;
109 _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, wi dth, height)); 109 _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, wi dth, height));
110 }, 110 },
111 child: new Container( 111 child: new Container(
112 padding: const EdgeDims.all(8.0), 112 padding: const EdgeDims.all(8.0),
113 child: new Block(children) 113 child: new Block(children)
114 ) 114 )
115 ) 115 )
116 ) 116 )
117 ); 117 );
118 } 118 }
119 119
120 } 120 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/navigator.dart ('k') | sky/sdk/lib/widgets/popup_menu_item.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698