Skip to content

Conversation

@ptziegler
Copy link
Contributor

The MoveHandleLocatorshrinks the size of the target figure by one, handles the insets and then expands it by one again. The problem is that the first operation is done before translating the bounds to absolute coordinates. Instead of shrinking the size by one, it is therefore shrunk by one times the zoom factor.

As a result, the bounds of the target figure don't fully enclose the bounds of the figure owned by the locator.

To reproduce: Open the Logic editor and select e.g. a Gate. When selecting the element, the selection box doesn't fully enclose the right and bottom of the figure.

The `MoveHandleLocator`shrinks the size of the target figure by one,
handles the insets and then expands it by one again. The problem is that
the first operation is done before translating the bounds to absolute
coordinates. Instead of shrinking the size by one, it is therefore
shrunk by one times the zoom factor.

As a result, the bounds of the target figure don't fully enclose the
bounds of the figure owned by the locator.

To reproduce: Open the Logic editor and select e.g. a Gate. When
selecting the element, the selection box doesn't fully enclose the right
and bottom of the figure.
@ptziegler ptziegler added this to the 3.27.0 milestone Jan 1, 2026
@ptziegler
Copy link
Contributor Author

For illustration, I've updated the Gate figure to draw a simple rectangle. As you can see, the selection box is too small:

image

The initial change was done with 7a79061 and e7a9fda. But due to the poor commit message, I can't say anything about why it was done like this.

Copy link
Contributor

@azoitl azoitl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that the -1 +1 thingy somehow wants to address the line border width. However this should be handled by the insets or? Couldn't we remove the -1 +1?

@ptziegler
Copy link
Contributor Author

Could it be that the -1 +1 thingy somehow wants to address the line border width. However this should be handled by the insets or? Couldn't we remove the -1 +1?

That's what I meant... If you look at how it was originally, the insets were taken into consideration. The +1/-1 was then added for the sake of some "zoom changes", but without any explanation what they're supposed to fix.

public void relocate(IFigure target) {
Insets insets = target.getInsets();
Rectangle bounds;
if (getReference() instanceof HandleBounds)
bounds = ((HandleBounds)getReference()).getHandleBounds();
else
bounds = getReference().getBounds();
bounds = bounds.getExpanded(insets.left, insets.top);
getReference().translateToAbsolute(bounds);
target.translateToRelative(bounds);
target.setBounds(bounds);
}

I don't see why it was added but I also can't predict the side-effects that would be introduced by removing them. My current guess is that it likely avoids some rounding errors when scaling the figures.

All I can say is that it not a +1/-1, but rather a +1/(-1*zoom), which is causing these artifacts.

@azoitl
Copy link
Contributor

azoitl commented Jan 5, 2026

I don't see why it was added but I also can't predict the side-effects that would be introduced by removing them. My current guess is that it likely avoids some rounding errors when scaling the figures.

All I can say is that it not a +1/-1, but rather a +1/(-1*zoom), which is causing these artifacts.

Me neither. I only fear that now that you changed it to PrecisionRectangle that we have now more or different rounding issues and that the +1/(-1*zoom) adds to that. However I have no clue how to find that out.

@ptziegler
Copy link
Contributor Author

I only fear that now that you changed it to PrecisionRectangle that we have now more or different rounding issues and that the +1/(-1*zoom) adds to that

I'm not sure what you mean. The class was using a PrecisionRectangle even before my change.

Copy link
Contributor

@azoitl azoitl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm stupid.

@azoitl azoitl merged commit 4463d9d into eclipse-gef:master Jan 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants