Skip to content

Commit 1f4339b

Browse files
committed
fix for not overlaps
1 parent 106f86d commit 1f4339b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/java/net/itarray/automotion/internal/ResponsiveUIChunkValidatorBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private void validateElementsAreNotOverlapped(List<UIElement> elements) {
281281
UIElement first = elements.get(firstIndex);
282282
for (int secondIndex = firstIndex+1; secondIndex < elements.size(); secondIndex++) {
283283
UIElement second = elements.get(secondIndex);
284-
if (first.overlaps(second, context)) {
284+
if (!first.notOverlaps(second, context)) {
285285
context.add("Elements are overlapped");
286286
context.draw(first);
287287
break;

src/main/java/net/itarray/automotion/internal/UIElement.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ public boolean overlaps(UIElement other, Context context) {
172172
Condition.lessThan(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
173173
}
174174

175+
public boolean notOverlaps(UIElement other, Context context) {
176+
return Condition.greaterOrEqualTo(other.getRight()).isSatisfiedOn(getLeft(), context, RIGHT) ||
177+
Condition.greaterOrEqualTo(getRight()).isSatisfiedOn(other.getLeft(), context, RIGHT) ||
178+
Condition.greaterOrEqualTo(other.getBottom()).isSatisfiedOn(getTop(), context, DOWN) ||
179+
Condition.greaterOrEqualTo(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
180+
}
181+
175182
private Scalar getOffset(Direction direction, UIElement page) {
176183
return direction.signedDistance(getEnd(direction), page.getEnd(direction));
177184
}
@@ -347,7 +354,7 @@ public void validateOverlappingWithElement(UIElement element, Context context) {
347354
}
348355

349356
public void validateNotOverlappingWithElement(UIElement element, Context context) {
350-
if (overlaps(element, context)) {
357+
if (!notOverlaps(element, context)) {
351358
context.add(String.format("Element %s is overlapped with element %s but should not",
352359
getQuotedName(),
353360
element.getQuotedName()));

0 commit comments

Comments
 (0)