From d71908d43db360dbca9cfe3219a48ac022e5a89b Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Tue, 29 Sep 2026 20:48:11 +0200 Subject: [PATCH] Calculate absolute component info location without screen coordinates Similarly to 56f77aecc022d76f8f2df7c1f7e27fbde4f7bacf, the calculation of the absolute bounds of a component may produce inconsistent results when translated to screen bounds. Translation is now only done up until the direct children of the root info. If the absolute bounds of the root info is requested, the bounds have to be normalized. --- .../wb/core/model/AbstractComponentInfo.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/core/model/AbstractComponentInfo.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/core/model/AbstractComponentInfo.java index fd0f54d294..184a766bb9 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/core/model/AbstractComponentInfo.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/core/model/AbstractComponentInfo.java @@ -83,19 +83,19 @@ public final void setModelBounds(Rectangle bounds) { */ public final Rectangle getAbsoluteBounds() { Rectangle bounds = getBounds().getCopy(); - // make relative to screen + // normalize screen location if root component + if (isRoot()) { + bounds.setLocation(0, 0); + return bounds; + } + // make relative to root component { AbstractComponentInfo parent = (AbstractComponentInfo) getParent(); - while (parent != null) { + while (parent != null && !parent.isRoot()) { bounds.performTranslate(parent.getBounds().getLocation()); parent = (AbstractComponentInfo) parent.getParent(); } } - // make relative to root component - { - AbstractComponentInfo rootComponent = (AbstractComponentInfo) getRoot(); - bounds.performTranslate(rootComponent.getBounds().getLocation().getNegated()); - } // OK, final result return bounds; }