mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[xena] tooltips shift and layout fix
This commit is contained in:
@@ -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) {
|
||||
|
||||
+3
-3
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user