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

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

Issue 1240573007: Make it possible to detect PopupMenuItem presses (Closed) Base URL: git@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 'dart:math' as math; 5 import 'dart:math' as math;
6 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 7
8 import 'package:sky/animation/animation_performance.dart'; 8 import 'package:sky/animation/animation_performance.dart';
9 import 'package:sky/painting/box_painter.dart'; 9 import 'package:sky/painting/box_painter.dart';
10 import 'package:sky/theme/colors.dart'; 10 import 'package:sky/theme/colors.dart';
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return 1.0; 114 return 1.0;
115 double unit = 1.0 / items.length; 115 double unit = 1.0 / items.length;
116 double duration = 1.5 * unit; 116 double duration = 1.5 * unit;
117 double start = i * unit; 117 double start = i * unit;
118 return math.max(0.0, math.min(1.0, (_position.value - start) / duration)); 118 return math.max(0.0, math.min(1.0, (_position.value - start) / duration));
119 } 119 }
120 120
121 Widget build() { 121 Widget build() {
122 int i = 0; 122 int i = 0;
123 List<Widget> children = new List.from(items.map((Widget item) { 123 List<Widget> children = new List.from(items.map((Widget item) {
124 double opacity = _opacityFor(i); 124 return new Opacity(opacity: _opacityFor(i++), child: item);
125 return new PopupMenuItem(child: item, opacity: opacity);
126 })); 125 }));
127 126
128 return new Opacity( 127 return new Opacity(
129 opacity: math.min(1.0, _position.value * 3.0), 128 opacity: math.min(1.0, _position.value * 3.0),
130 child: new Container( 129 child: new Container(
131 margin: new EdgeDims.all(_kMenuMargin), 130 margin: new EdgeDims.all(_kMenuMargin),
132 child: new CustomPaint( 131 child: new CustomPaint(
133 callback: (sky.Canvas canvas, Size size) { 132 callback: (sky.Canvas canvas, Size size) {
134 double width = math.min(size.width, size.width * (0.5 + _position.va lue * 2.0)); 133 double width = math.min(size.width, size.width * (0.5 + _position.va lue * 2.0));
135 double height = math.min(size.height, size.height * _position.value * 1.5); 134 double height = math.min(size.height, size.height * _position.value * 1.5);
(...skipping 16 matching lines...) Expand all
152 ) 151 )
153 ) 152 )
154 ) 153 )
155 ) 154 )
156 ) 155 )
157 ) 156 )
158 ); 157 );
159 } 158 }
160 159
161 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698