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

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

Issue 1166363002: Position the popup menu in stocks2 correctly (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/rendering/flex.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/stack.dart
diff --git a/sky/sdk/lib/framework/rendering/stack.dart b/sky/sdk/lib/framework/rendering/stack.dart
index 466968b32980a57cd3898e08fdb505e679f5674e..c35020cf3f17596e1ea062b2abc9bb8df62f7cd5 100644
--- a/sky/sdk/lib/framework/rendering/stack.dart
+++ b/sky/sdk/lib/framework/rendering/stack.dart
@@ -5,7 +5,26 @@
import 'box.dart';
import 'object.dart';
-class StackParentData extends BoxParentData with ContainerParentDataMixin<RenderBox> { }
+class StackParentData extends BoxParentData with ContainerParentDataMixin<RenderBox> {
+ double top;
+ double right;
+ double bottom;
+ double left;
+
+ void merge(StackParentData other) {
+ if (other.top != null)
+ top = other.top;
+ if (other.right != null)
+ right = other.right;
+ if (other.bottom != null)
+ bottom = other.bottom;
+ if (other.left != null)
+ left = other.left;
+ super.merge(other);
+ }
+
+ String toString() => '${super.toString()}; top=$top; right=$right; bottom=$bottom, left=$left';
+}
class RenderStack extends RenderBox with ContainerRenderObjectMixin<RenderBox, StackParentData>,
RenderBoxContainerDefaultsMixin<RenderBox, StackParentData> {
@@ -45,9 +64,43 @@ class RenderStack extends RenderBox with ContainerRenderObjectMixin<RenderBox, S
RenderBox child = firstChild;
while (child != null) {
- child.layout(innerConstraints);
assert(child.parentData is StackParentData);
- child.parentData.position = Point.origin;
+ StackParentData parentData = child.parentData;
+
+ BoxConstraints childConstraints = innerConstraints;
+
+ if (parentData.left != null && parentData.right != null)
+ childConstraints = childConstraints.applyWidth(parentData.right - parentData.left);
+ else if (parentData.left != null)
+ childConstraints = childConstraints.applyMaxWidth(size.width - parentData.left);
+ else if (parentData.right != null)
+ childConstraints = childConstraints.applyMaxWidth(size.width - parentData.right);
+
+ if (parentData.top != null && parentData.bottom != null)
+ childConstraints = childConstraints.applyHeight(parentData.bottom - parentData.top);
+ else if (parentData.top != null)
+ childConstraints = childConstraints.applyMaxHeight(size.height - parentData.top);
+ else if (parentData.bottom != null)
+ childConstraints = childConstraints.applyMaxHeight(size.width - parentData.bottom);
+
+ child.layout(childConstraints);
+
+ double x = 0.0;
+ if (parentData.left != null)
+ x = parentData.left;
+ else if (parentData.right != null)
+ x = size.width - parentData.right - child.size.width;
+ assert(x >= 0.0 && x + child.size.width <= size.width);
+
+ double y = 0.0;
+ if (parentData.top != null)
+ y = parentData.top;
+ else if (parentData.bottom != null)
+ y = size.height - parentData.bottom - child.size.height;
+ assert(y >= 0.0 && y + child.size.height <= size.height);
+
+ parentData.position = new Point(x, y);
+
child = child.parentData.nextSibling;
}
}
« no previous file with comments | « sky/sdk/lib/framework/rendering/flex.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698