@@ -176,11 +176,19 @@ public Expression<Boolean> overlaps(UIElement other) {
176176 );
177177 }
178178
179- public boolean notOverlaps (UIElement other , Context context ) {
180- return Condition .greaterOrEqualTo (other .end (RIGHT )).applyTo (end (LEFT )).evaluateIn (context , RIGHT ) ||
181- Condition .greaterOrEqualTo (end (RIGHT )).applyTo (other .end (LEFT )).evaluateIn (context , RIGHT ) ||
182- Condition .greaterOrEqualTo (other .end (DOWN )).applyTo (end (UP )).evaluateIn (context , DOWN ) ||
183- Condition .greaterOrEqualTo (end (DOWN )).applyTo (other .end (UP )).evaluateIn (context , DOWN );
179+ public boolean doesNotOverlap (UIElement other , Context context ) {
180+ return notOverlaps (other ).evaluateIn (context , DOWN );
181+ }
182+
183+ public Expression <Boolean > notOverlaps (UIElement other ) {
184+ return Expression .or (
185+ Expression .or (
186+ Condition .greaterOrEqualTo (other .end (RIGHT )).applyTo (end (LEFT )),
187+ Condition .greaterOrEqualTo (end (RIGHT )).applyTo (other .end (LEFT ))),
188+ Expression .or (
189+ Condition .greaterOrEqualTo (other .end (DOWN )).applyTo (end (UP )),
190+ Condition .greaterOrEqualTo (end (DOWN )).applyTo (other .end (UP )))
191+ );
184192 }
185193
186194 private <V extends MetricSpace <V >> Expression <V > offset (UIElement page , ExtendGiving <V > direction ) {
@@ -359,7 +367,7 @@ public void validateOverlappingWithElement(UIElement element, Context context) {
359367 }
360368
361369 public void validateNotOverlappingWithElement (UIElement element , Context context ) {
362- if (!notOverlaps (element , context )) {
370+ if (!notOverlaps (element ). evaluateIn ( context , DOWN )) {
363371 context .add (String .format ("Element %s is overlapped with element %s but should not" ,
364372 getQuotedName (),
365373 element .getQuotedName ()));
0 commit comments