use utility methods to apply insets

This commit is contained in:
Sergey Malenkov
2016-12-27 11:36:19 +03:00
parent 8508e2cc5f
commit adcddeb944
3 changed files with 8 additions and 12 deletions
@@ -15,6 +15,8 @@
*/
package com.intellij.ui.components.panels;
import com.intellij.util.ui.JBInsets;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.Container;
@@ -247,9 +249,7 @@ public final class HorizontalLayout implements LayoutManager2 {
int rightWidth = right == null ? 0 : right.width;
result.width += Math.abs(leftWidth - rightWidth);
}
Insets insets = container.getInsets();
result.width += insets.left + insets.right;
result.height += insets.top + insets.bottom;
JBInsets.addTo(result, container.getInsets());
return result;
}
}
@@ -15,6 +15,8 @@
*/
package com.intellij.ui.components.panels;
import com.intellij.util.ui.JBInsets;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.Container;
@@ -247,9 +249,7 @@ public final class VerticalLayout implements LayoutManager2 {
int bottomHeight = bottom == null ? 0 : bottom.height;
result.width += Math.abs(topHeight - bottomHeight);
}
Insets insets = container.getInsets();
result.width += insets.left + insets.right;
result.height += insets.top + insets.bottom;
JBInsets.addTo(result, container.getInsets());
return result;
}
}
@@ -101,12 +101,8 @@ public class ScrollUtil {
visible.x = r.x - (visible.width - r.width) / 2;
visible.y = r.y - (visible.height - r.height) / 2;
final Rectangle bounds = c.getBounds();
final Insets i = withInsets ? new Insets(0, 0, 0, 0) : c.getInsets();
bounds.x = i.left;
bounds.y = i.top;
bounds.width -= i.left + i.right;
bounds.height -= i.top + i.bottom;
Rectangle bounds = new Rectangle(c.getWidth(), c.getHeight());
if (!withInsets) JBInsets.removeFrom(bounds, c.getInsets());
if (visible.x < bounds.x) {
visible.x = bounds.x;