From fb250ef8866cf96cc6ebcd7ba46d63d90f4cbb4d Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Fri, 2 Mar 2012 18:05:22 +0400 Subject: [PATCH] IDEA-82025 Tree: Fix glitches with node tooltips --- .../com/intellij/ide/IdeTooltipManager.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java index f0b80d6c9f70..d0d773a199ec 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java @@ -176,6 +176,17 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener boolean centerStrict = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_STRICT)); int shift = centerStrict ? 0 : (centerDefault ? 4 : 0); + // Balloon may appear exactly above useful content, such behavior is rather annoying. + if (c instanceof JTree) { + javax.swing.tree.TreePath path = ((JTree)c).getClosestPathForLocation(me.getX(), me.getY()); + if (path != null) { + Rectangle pathBounds = ((JTree)c).getPathBounds(path); + if (pathBounds != null && pathBounds.y + 4 < me.getY()) { + shift += me.getY() - pathBounds.y - 4; + } + } + } + queueShow(comp, me, centerStrict || centerDefault, shift, -shift, -shift); } @@ -199,16 +210,6 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener } }.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY).setLayer(Balloon.Layer.top); - // Balloon may appear exactly above useful content, such behavior is rather annoying. - if (tooltip.getPreferredPosition() == Balloon.Position.above && c instanceof JTree) { - javax.swing.tree.TreePath path = ((JTree)c).getClosestPathForLocation(me.getX(), me.getY()); - if (path != null) { - Rectangle pathBounds = ((JTree)c).getPathBounds(path); - if (pathBounds != null && pathBounds.y + 4 < me.getY()) { - tooltip.setPositionChangeShift(tooltip.getPositionChangeX(), tooltip.getPositionChangeY() - ((me.getY() - pathBounds.y - 4))); - } - } - } show(tooltip, false); }