Skip to content

Commit

Permalink
AnchorLayout: throw exception if relativeTo doesn't have the same par…
Browse files Browse the repository at this point in the history
…ent as the item (closes #184)
  • Loading branch information
joshtynjala committed Jul 24, 2024
1 parent df4def5 commit fcb524d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/feathers/layout/AnchorLayout.hx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class AnchorLayout extends EventDispatcher implements ILayout {
var value = top.value;
var relativeTo = top.relativeTo;
if (relativeTo != null && doneItems.indexOf(relativeTo) == -1) {
if (item.parent != relativeTo.parent) {
throw new IllegalOperationError("relativeTo must have the same parent");
}
continue;
}
item.y = value;
Expand All @@ -131,6 +134,9 @@ class AnchorLayout extends EventDispatcher implements ILayout {
var value = left.value;
var relativeTo = left.relativeTo;
if (relativeTo != null && doneItems.indexOf(relativeTo) == -1) {
if (item.parent != relativeTo.parent) {
throw new IllegalOperationError("relativeTo must have the same parent");
}
continue;
}
item.x = value;
Expand Down Expand Up @@ -243,6 +249,9 @@ class AnchorLayout extends EventDispatcher implements ILayout {
var top = layoutData.top;
var relativeTo = top.relativeTo;
if (relativeTo != null && doneItems.indexOf(relativeTo) == -1) {
if (item.parent != relativeTo.parent) {
throw new IllegalOperationError("relativeTo must have the same parent");
}
continue;
}
var y = top.value;
Expand All @@ -255,6 +264,9 @@ class AnchorLayout extends EventDispatcher implements ILayout {
var left = layoutData.left;
var relativeTo = left.relativeTo;
if (relativeTo != null && doneItems.indexOf(relativeTo) == -1) {
if (item.parent != relativeTo.parent) {
throw new IllegalOperationError("relativeTo must have the same parent");
}
continue;
}
var x = left.value;
Expand All @@ -267,6 +279,9 @@ class AnchorLayout extends EventDispatcher implements ILayout {
var bottom = layoutData.bottom;
var relativeTo = bottom.relativeTo;
if (relativeTo != null && doneItems.indexOf(relativeTo) == -1) {
if (item.parent != relativeTo.parent) {
throw new IllegalOperationError("relativeTo must have the same parent");
}
continue;
}
var bottomPixels = bottom.value;
Expand Down Expand Up @@ -309,6 +324,9 @@ class AnchorLayout extends EventDispatcher implements ILayout {
var right = layoutData.right;
var relativeTo = right.relativeTo;
if (relativeTo != null && doneItems.indexOf(relativeTo) == -1) {
if (item.parent != relativeTo.parent) {
throw new IllegalOperationError("relativeTo must have the same parent");
}
continue;
}
var rightPixels = right.value;
Expand Down

0 comments on commit fcb524d

Please sign in to comment.