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

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

Issue 1155683011: Add |constraints| to Container for PopupMenuItem (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/framework/fn2.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/rendering/box.dart
diff --git a/sky/sdk/lib/framework/rendering/box.dart b/sky/sdk/lib/framework/rendering/box.dart
index 7364a46e197d72f57e8c41263956ba7c58eef003..02a1893dfe5d80bf1269d4ca660626c8662bee8a 100644
--- a/sky/sdk/lib/framework/rendering/box.dart
+++ b/sky/sdk/lib/framework/rendering/box.dart
@@ -77,6 +77,14 @@ class BoxConstraints {
);
}
+ BoxConstraints apply(BoxConstraints constraints) {
+ return new BoxConstraints(
+ minWidth: math.max(minWidth, constraints.minWidth),
+ maxWidth: math.min(maxWidth, constraints.maxWidth),
+ minHeight: math.max(minHeight, constraints.minHeight),
+ maxHeight: math.min(maxHeight, constraints.maxHeight));
+ }
+
final double minWidth;
final double maxWidth;
final double minHeight;
@@ -192,9 +200,8 @@ class RenderSizedBox extends RenderProxyBox {
RenderSizedBox({
RenderBox child,
Size desiredSize: Size.infinite
- }) : super(child) {
+ }) : super(child), _desiredSize = desiredSize {
assert(desiredSize != null);
- this.desiredSize = desiredSize;
}
Size _desiredSize;
@@ -220,6 +227,42 @@ class RenderSizedBox extends RenderProxyBox {
String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(prefix)}${prefix}desiredSize: ${desiredSize}\n';
}
+class RenderConstrainedBox extends RenderProxyBox {
+ RenderConstrainedBox({
+ RenderBox child,
+ BoxConstraints additionalConstraints
+ }) : super(child), _additionalConstraints = additionalConstraints {
+ assert(additionalConstraints != null);
+ }
+
+ BoxConstraints _additionalConstraints;
+ BoxConstraints get additionalConstraints => _additionalConstraints;
+ void set additionalConstraints (BoxConstraints value) {
+ assert(value != null);
+ if (_additionalConstraints == value)
+ return;
+ _additionalConstraints = value;
+ markNeedsLayout();
+ }
+
+ Size getIntrinsicDimensions(BoxConstraints constraints) {
+ if (child == null)
+ return constraints.constrain(Size.zero);
+ return child.getIntrinsicDimensions(constraints.apply(_additionalConstraints));
+ }
+
+ void performLayout() {
+ if (child != null) {
+ child.layout(constraints.apply(_additionalConstraints));
+ size = child.size;
+ } else {
+ performResize();
+ }
+ }
+
+ String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(prefix)}${prefix}additionalConstraints: ${additionalConstraints}\n';
+}
+
class RenderClip extends RenderProxyBox {
RenderClip({ RenderBox child }) : super(child);
« no previous file with comments | « sky/sdk/lib/framework/fn2.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698