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

Unified Diff: sky/sdk/lib/rendering/box.dart

Issue 1215613005: Improve the padding and sizing of popup menus. (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 | « no previous file | sky/sdk/lib/widgets/basic.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/rendering/box.dart
diff --git a/sky/sdk/lib/rendering/box.dart b/sky/sdk/lib/rendering/box.dart
index f6de4f4e61b2d15e7ffe112e9b3e8e9695d5a476..82351815aaf86cc8ead8c79281b4daa9eac6997f 100644
--- a/sky/sdk/lib/rendering/box.dart
+++ b/sky/sdk/lib/rendering/box.dart
@@ -494,7 +494,35 @@ class RenderConstrainedBox extends RenderProxyBox {
}
class RenderShrinkWrapWidth extends RenderProxyBox {
- RenderShrinkWrapWidth({ RenderBox child }) : super(child);
+ RenderShrinkWrapWidth({
+ stepWidth,
+ stepHeight,
abarth-chromium 2015/06/30 20:51:44 Types? Also, I wonder if we can think of a better
+ RenderBox child
+ }) : _stepWidth = stepWidth, _stepHeight = stepHeight, super(child);
+
+ double _stepWidth;
+ double get stepWidth => _stepWidth;
+ void set stepWidth(double value) {
+ if (value == _stepWidth)
+ return;
+ _stepWidth = value;
+ markNeedsLayout();
+ }
+
+ double _stepHeight;
+ double get stepHeight => _stepHeight;
+ void set stepHeight(double value) {
+ if (value == _stepHeight)
+ return;
+ _stepHeight = value;
+ markNeedsLayout();
+ }
+
+ static double applyStep(double input, double step) {
+ if (step == null)
+ return input;
+ return (input / step).ceil() * step;
+ }
BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
double width = child.getMaxIntrinsicWidth(constraints);
@@ -503,33 +531,37 @@ class RenderShrinkWrapWidth extends RenderProxyBox {
}
double getMinIntrinsicWidth(BoxConstraints constraints) {
- if (child != null)
- return child.getMaxIntrinsicWidth(constraints);
- return constraints.constrainWidth(0.0);
+ if (child == null)
+ return constraints.constrainWidth(0.0);
+ double childResult = child.getMinIntrinsicWidth(constraints);
+ return constraints.constrainWidth(applyStep(childResult, _stepWidth));
}
double getMaxIntrinsicWidth(BoxConstraints constraints) {
- if (child != null)
- return child.getMaxIntrinsicWidth(constraints);
- return constraints.constrainWidth(0.0);
+ if (child == null)
+ return constraints.constrainWidth(0.0);
+ double childResult = child.getMaxIntrinsicWidth(constraints);
+ return constraints.constrainWidth(applyStep(childResult, _stepWidth));
}
double getMinIntrinsicHeight(BoxConstraints constraints) {
- if (child != null)
- return child.getMinIntrinsicHeight(_getInnerConstraints(constraints));
- return constraints.constrainWidth(0.0);
+ if (child == null)
+ return constraints.constrainWidth(0.0);
+ double childResult = child.getMinIntrinsicHeight(_getInnerConstraints(constraints));
+ return constraints.constrainHeight(applyStep(childResult, _stepHeight));
}
double getMaxIntrinsicHeight(BoxConstraints constraints) {
- if (child != null)
- return child.getMaxIntrinsicHeight(_getInnerConstraints(constraints));
- return constraints.constrainWidth(0.0);
+ if (child == null)
+ return constraints.constrainWidth(0.0);
+ double childResult = child.getMaxIntrinsicHeight(_getInnerConstraints(constraints));
+ return constraints.constrainHeight(applyStep(childResult, _stepHeight));
}
void performLayout() {
if (child != null) {
child.layout(_getInnerConstraints(constraints), parentUsesSize: true);
- size = child.size;
+ size = new Size(applyStep(child.size.width, _stepWidth), applyStep(child.size.height, _stepHeight));
} else {
performResize();
}
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/basic.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698