From d879451de78de6e8a5956c9ccb85a2ebe538765a Mon Sep 17 00:00:00 2001 From: Sergei Tachenov Date: Thu, 28 Mar 2024 12:00:10 +0200 Subject: [PATCH] IDEA-317864 Fix insets handling in Splitter They were ignored by the layout code, making it impossible to use borders on splitters. And we need one for the Build tool window. GitOrigin-RevId: d730e55ec16de38a4d5280266238932923e1c58d --- .../src/com/intellij/openapi/ui/Splitter.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/platform/util/ui/src/com/intellij/openapi/ui/Splitter.java b/platform/util/ui/src/com/intellij/openapi/ui/Splitter.java index 1cce617d12cd..e4019eb39686 100644 --- a/platform/util/ui/src/com/intellij/openapi/ui/Splitter.java +++ b/platform/util/ui/src/com/intellij/openapi/ui/Splitter.java @@ -418,8 +418,9 @@ public class Splitter extends JPanel implements Splittable { mySkipNextLayout = false; return; } - int width = getWidth(); - int height = getHeight(); + var insets = getInsets(); + int width = getWidth() - insets.left - insets.right; + int height = getHeight() - insets.top - insets.bottom; int total = isVertical() ? height : width; if (total <= 0) return; @@ -445,14 +446,14 @@ public class Splitter extends JPanel implements Splittable { int iSize2 = Math.max(0, total - iSize1 - d); if (isVertical()) { - firstRect.setBounds(0, 0, width, iSize1); - dividerRect.setBounds(0, iSize1, width, d); - secondRect.setBounds(0, iSize1 + d, width, iSize2); + firstRect.setBounds(insets.left, insets.top, width, iSize1); + dividerRect.setBounds(insets.left, insets.top + iSize1, width, d); + secondRect.setBounds(insets.left, insets.top + iSize1 + d, width, iSize2); } else { - firstRect.setBounds(0, 0, iSize1, height); - dividerRect.setBounds(iSize1, 0, d, height); - secondRect.setBounds((iSize1 + d), 0, iSize2, height); + firstRect.setBounds(insets.left, insets.top, iSize1, height); + dividerRect.setBounds(insets.left + iSize1, insets.top, d, height); + secondRect.setBounds((insets.left + iSize1 + d), insets.top, iSize2, height); } myDivider.setVisible(true); myFirstComponent.setBounds(firstRect); @@ -464,26 +465,26 @@ public class Splitter extends JPanel implements Splittable { else if (!isNull(myFirstComponent) && myFirstComponent.isVisible()) { // only first component is visible hideNull(mySecondComponent); myDivider.setVisible(false); - myFirstComponent.setBounds(0, 0, width, height); + myFirstComponent.setBounds(insets.left, insets.top, width, height); //myFirstComponent.revalidate(); } else if (!isNull(mySecondComponent) && mySecondComponent.isVisible()) { // only second component is visible hideNull(myFirstComponent); myDivider.setVisible(false); - mySecondComponent.setBounds(0, 0, width, height); + mySecondComponent.setBounds(insets.left, insets.top, width, height); //mySecondComponent.revalidate(); } else { // both components are null or invisible myDivider.setVisible(false); if (myFirstComponent != null) { - myFirstComponent.setBounds(0, 0, 0, 0); + myFirstComponent.setBounds(insets.left, insets.top, 0, 0); //myFirstComponent.revalidate(); } else { hideNull(myFirstComponent); } if (mySecondComponent != null) { - mySecondComponent.setBounds(0, 0, 0, 0); + mySecondComponent.setBounds(insets.left, insets.top, 0, 0); //mySecondComponent.revalidate(); } else {