[xena] tooltips shift and layout fix

This commit is contained in:
Kirill Kalishev
2011-05-20 15:42:46 +04:00
parent 6ec3d4b8bf
commit f26487517f
4 changed files with 23 additions and 10 deletions
@@ -35,6 +35,7 @@ import com.intellij.ui.BalloonImpl;
import com.intellij.ui.HintHint;
import com.intellij.ui.ScreenUtil;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.Alarm;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.ui.UIUtil;
@@ -45,6 +46,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.text.*;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLEditorKit;
@@ -166,10 +168,16 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
String tooltipText = comp.getToolTipText(me);
if (tooltipText == null || tooltipText.trim().length() == 0) return;
queueShow(comp, me, Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP)));
boolean centerDefault = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT));
boolean centerStrict = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_STRICT));
int shift = centerStrict ? 0 : (centerDefault ? -4 : 0);
queueShow(comp, me, centerStrict || centerDefault, shift, -shift, -shift);
}
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter) {
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter, int shift, int posChangeX, int posChangeY) {
final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null, new Object()) {
@Override
protected boolean beforeShow() {
@@ -182,10 +190,12 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
JLayeredPane layeredPane = IJSwingUtilities.findParentOfType(c, JLayeredPane.class);
setTipComponent(initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane));
final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane);
final Wrapper wrapper = new Wrapper(pane);
setTipComponent(wrapper);
return true;
}
}.setToCenter(toCenter);
}.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY);
show(tooltip, false);
}
@@ -233,11 +243,13 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
boolean toCenterY;
boolean toCenter = tooltip.isToCenter();
boolean small = false;
if (!toCenter && tooltip.isToCenterIfSmall()) {
Dimension size = tooltip.getComponent().getSize();
toCenterX = size.width < 64;
toCenterY = size.height < 64;
toCenter = toCenterX || toCenterY;
small = true;
} else {
toCenterX = true;
toCenterY = true;
@@ -265,7 +277,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
.setBorderColor(border)
.setAnimationCycle(Registry.intValue("ide.tooltip.animationCycle"))
.setShowCallout(true)
.setCalloutShift(tooltip.getCalloutShift())
.setCalloutShift((small && tooltip.getCalloutShift() == 0) ? -2 : tooltip.getCalloutShift())
.setPositionChangeXShift(tooltip.getPositionChangeX())
.setPositionChangeYShift(tooltip.getPositionChangeY())
.setHideOnKeyOutside(!tooltip.isExplicitClose())
@@ -70,7 +70,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent {
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
myMinimumButtonSize = minimumSize;
putClientProperty(UIUtil.CENTER_TOOLTIP, Boolean.TRUE);
putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
}
public void setNoIconsInPopup(boolean noIconsInPopup) {
@@ -605,7 +605,7 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
super(presentation.getMaxValue());
myPresentation = presentation;
putClientProperty(UIUtil.CENTER_TOOLTIP, Boolean.TRUE);
putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
setToolTipText(presentation.getTooltipText());
addMouseListener(new MouseAdapter() {
@@ -663,7 +663,7 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
setTextAlignment(presentation.getAlignment());
putClientProperty(UIUtil.CENTER_TOOLTIP, Boolean.TRUE);
putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
setToolTipText(presentation.getTooltipText());
addMouseListener(new MouseAdapter() {
@@ -709,7 +709,7 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
myClickConsumer = myPresentation.getClickConsumer();
myIcon = myPresentation.getIcon();
putClientProperty(UIUtil.CENTER_TOOLTIP, Boolean.TRUE);
putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
setToolTipText(presentation.getTooltipText());
addMouseListener(new MouseAdapter() {
@@ -89,7 +89,8 @@ public class UIUtil {
// accessed only from EDT
private static final HashMap<Color, BufferedImage> ourAppleDotSamples = new HashMap<Color, BufferedImage>();
@NonNls public static final String CENTER_TOOLTIP = "ToCenterTooltip";
@NonNls public static final String CENTER_TOOLTIP_DEFAULT = "ToCenterTooltip";
@NonNls public static final String CENTER_TOOLTIP_STRICT = "ToCenterTooltip.default";
private static final String ROOT_PANE = "JRootPane.future";