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

Unified Diff: sky/sdk/lib/widgets/popup_menu.dart

Issue 1219113003: Make popup menus line up to their baseline per the Material spec. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/widgets/basic.dart ('k') | sky/sdk/lib/widgets/popup_menu_item.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/popup_menu.dart
diff --git a/sky/sdk/lib/widgets/popup_menu.dart b/sky/sdk/lib/widgets/popup_menu.dart
index 6fdf366dc30b714aa751a5e1cb46622032552b89..bf357eece3917eefdeef1d56a1781fbc1d208ba2 100644
--- a/sky/sdk/lib/widgets/popup_menu.dart
+++ b/sky/sdk/lib/widgets/popup_menu.dart
@@ -18,7 +18,9 @@ const double _kMenuOpenDuration = 300.0;
const double _kMenuCloseDuration = 200.0;
const double _kMenuCloseDelay = 100.0;
const double _kMenuWidthStep = 56.0;
-const double _kMenuMinWidth = 1.5 * _kMenuWidthStep;
+const double _kMenuMargin = 16.0; // 24.0 on tablet
+const double _kMenuMinWidth = 2.0 * _kMenuWidthStep;
+const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep;
const double _kMenuHorizontalPadding = 16.0;
const double _kMenuVerticalPadding = 8.0;
@@ -82,6 +84,7 @@ class PopupMenu extends AnimatedComponent {
BoxPainter _painter;
double _opacityFor(int i) {
+ assert(controller.position.value != null);
if (controller.position.value == null || controller.position.value == 1.0)
return 1.0;
double unit = 1.0 / items.length;
@@ -99,24 +102,28 @@ class PopupMenu extends AnimatedComponent {
return new Opacity(
opacity: math.min(1.0, controller.position.value * 3.0),
- child: new CustomPaint(
- callback: (sky.Canvas canvas, Size size) {
- double width = math.min(size.width, size.width * (0.5 + controller.position.value * 2.0));
- double height = math.min(size.height, size.height * controller.position.value * 1.5);
- _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, width, height));
- },
- child: new ConstrainedBox(
- constraints: new BoxConstraints(
- minWidth: _kMenuMinWidth
- ),
- child: new ShrinkWrapWidth(
- stepWidth: _kMenuWidthStep,
- child: new Container(
- padding: const EdgeDims.symmetric(
- horizontal: _kMenuHorizontalPadding,
- vertical: _kMenuVerticalPadding
- ),
- child: new Block(children)
+ child: new Container(
+ margin: new EdgeDims.all(_kMenuMargin),
+ child: new CustomPaint(
+ callback: (sky.Canvas canvas, Size size) {
+ double width = math.min(size.width, size.width * (0.5 + controller.position.value * 2.0));
+ double height = math.min(size.height, size.height * controller.position.value * 1.5);
+ _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, width, height));
+ },
+ child: new ConstrainedBox(
+ constraints: new BoxConstraints(
+ minWidth: _kMenuMinWidth,
+ maxWidth: _kMenuMaxWidth
+ ),
+ child: new ShrinkWrapWidth(
+ stepWidth: _kMenuWidthStep,
+ child: new Container(
+ padding: const EdgeDims.symmetric(
+ horizontal: _kMenuHorizontalPadding,
+ vertical: _kMenuVerticalPadding
+ ),
+ child: new Block(children)
+ )
)
)
)
« no previous file with comments | « sky/sdk/lib/widgets/basic.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