IDEA-317864 Fix coordinate checks in SimpleToolWindowPanel

The top/left insets weren't taken into account: the toolbar height
isn't always the same as its bottom-edge coordinate.

Get its bounds and convert them to the panel's coordinate system
to make code more generic and layout-agnostic. This also factors in
the insets automatically.

Use case: the Remote Host tool window, it has a top border
on the panel.

GitOrigin-RevId: 04574d8a0f2b64a08e012fa600023e9b6891b971
This commit is contained in:
Sergei Tachenov
2024-03-29 11:41:22 +00:00
committed by intellij-monorepo-bot
parent f503db70f5
commit b478a4dc36
@@ -257,7 +257,8 @@ public class SimpleToolWindowPanel extends JBPanelWithEmptyText implements Quick
if (toolbar == null || !toolbar.isVisible() || !component.isShowing()) {
return false;
}
var expectedCoordinate = (myVertical ? toolbar.getHeight() : toolbar.getWidth()) + GAP;
var toolbarBounds = SwingUtilities.convertRectangle(toolbar.getParent(), toolbar.getBounds(), this);
var expectedCoordinate = (myVertical ? toolbarBounds.y + toolbarBounds.height : toolbarBounds.x + toolbarBounds.width) + GAP;
var paneLocation = SwingUtilities.convertPoint(component.getParent(), component.getLocation(), this);
var actualCoordinate = myVertical ? paneLocation.y : paneLocation.x;
return expectedCoordinate == actualCoordinate;