mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
balloon positioning fixes + option to use system colors
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.BalloonBuilder;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.registry.RegistryValue;
|
||||
import com.intellij.openapi.util.registry.RegistryValueListener;
|
||||
@@ -99,6 +100,12 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
if (me.getComponent() == myCurrentComponent) {
|
||||
myX = me.getX();
|
||||
myY = me.getY();
|
||||
} else if (myCurrentComponent == null) {
|
||||
maybeShowFor(c, me);
|
||||
}
|
||||
} else if (me.getID() == MouseEvent.MOUSE_PRESSED) {
|
||||
if (me.getComponent() == myCurrentComponent) {
|
||||
hideCurrent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +137,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
public void run() {
|
||||
show(c, e, tooltipText, toCenter);
|
||||
}
|
||||
}, myShowDelay ? 750 : 250);
|
||||
}, myShowDelay ? 1200 : 750);
|
||||
}
|
||||
|
||||
private void show(Component c, MouseEvent e, String tooltipText, boolean toCenter) {
|
||||
@@ -138,15 +145,20 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
|
||||
myTipLabel.setText(tooltipText);
|
||||
|
||||
Color bg = new Color(100, 100, 100, 230);
|
||||
boolean useSystem = Registry.is("ide.tooltip.useSystemColors") || (!UIUtil.isUnderAquaLookAndFeel());
|
||||
|
||||
Color bg = useSystem ? UIManager.getColor("ToolTip.background") : new Color(100, 100, 100, 230);
|
||||
Color fg = useSystem ? UIManager.getColor("ToolTip.foreground") : Color.white;
|
||||
Color border = useSystem ? Color.darkGray : bg;
|
||||
|
||||
BalloonBuilder builder = myPopupFactory.createBalloonBuilder(myTipLabel)
|
||||
.setPreferredPosition(Balloon.Position.above)
|
||||
.setFillColor(bg)
|
||||
.setBorderColor(bg)
|
||||
.setBorderColor(border)
|
||||
.setAnimationCycle(150)
|
||||
.setShowCallout(true);
|
||||
myTipLabel.setForeground(Color.white);
|
||||
myTipLabel.setBorder(new EmptyBorder(0, 2, 0, 2));
|
||||
myTipLabel.setForeground(fg);
|
||||
myTipLabel.setBorder(new EmptyBorder(1, 3, 2, 3));
|
||||
Font font = UIManager.getFont("Label.font");
|
||||
myTipLabel.setFont(font.deriveFont(Font.PLAIN, font.getSize() - 2));
|
||||
myCurrentTip = builder.createBalloon();
|
||||
@@ -168,7 +180,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
if (toCenter) {
|
||||
Rectangle bounds = e.getComponent().getBounds();
|
||||
point.x = toCenterX ? bounds.width / 2 : point.x;
|
||||
point.y = toCenterY ? (bounds.height / 2 - (bounds.height / 5)) : point.y;
|
||||
point.y = toCenterY ? (bounds.height / 2) : point.y;
|
||||
}
|
||||
|
||||
myCurrentTip.show(new RelativePoint(c, point), Balloon.Position.above);
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.Range;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.ui.*;
|
||||
@@ -234,17 +235,17 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
|
||||
myTracker = tracker;
|
||||
myTracker.init(this);
|
||||
|
||||
final Window window = SwingUtilities.getWindowAncestor(tracker.getComponent());
|
||||
|
||||
JRootPane root = null;
|
||||
if (window instanceof JFrame) {
|
||||
root = ((JFrame)window).getRootPane();
|
||||
}
|
||||
else if (window instanceof JDialog) {
|
||||
root = ((JDialog)window).getRootPane();
|
||||
}
|
||||
else {
|
||||
assert false : window;
|
||||
JDialog dialog = IJSwingUtilities.findParentOfType(tracker.getComponent(), JDialog.class);
|
||||
if (dialog != null) {
|
||||
root = dialog.getRootPane();
|
||||
} else {
|
||||
JFrame frame = IJSwingUtilities.findParentOfType(tracker.getComponent(), JFrame.class);
|
||||
if (frame != null) {
|
||||
root = frame.getRootPane();
|
||||
} else {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
|
||||
myVisible = true;
|
||||
@@ -263,7 +264,9 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
|
||||
if (!myPosition.isOkToHavePointer(myTargetPoint, rec, getPointerLength(), getPointerWidth(), getArc(), getNormalInset())) {
|
||||
rec = getRecForPosition(myPosition, false);
|
||||
|
||||
Rectangle lp = new Rectangle(new Point(0, 0), myLayeredPane.getSize());
|
||||
Rectangle lp = new Rectangle(new Point(myContainerInsets.left, myContainerInsets.top), myLayeredPane.getSize());
|
||||
lp.width -= myContainerInsets.right;
|
||||
lp.height -= myContainerInsets.bottom;
|
||||
|
||||
if (!lp.contains(rec)) {
|
||||
Rectangle2D currentSquare = lp.createIntersection(rec);
|
||||
@@ -435,15 +438,15 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
|
||||
|
||||
|
||||
int getArc() {
|
||||
return 6;
|
||||
return 3;
|
||||
}
|
||||
|
||||
int getPointerWidth() {
|
||||
return 12;
|
||||
return 11;
|
||||
}
|
||||
|
||||
int getNormalInset() {
|
||||
return 4;
|
||||
return 3;
|
||||
}
|
||||
|
||||
int getShadowShift() {
|
||||
@@ -451,7 +454,7 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
|
||||
}
|
||||
|
||||
int getPointerLength() {
|
||||
return 12;
|
||||
return 8;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
@@ -587,28 +590,20 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
|
||||
final BalloonImpl balloon);
|
||||
|
||||
public boolean isOkToHavePointer(Point targetPoint, Rectangle bounds, int pointerLength, int pointerWidth, int arc, int normalInset) {
|
||||
if (bounds.contains(targetPoint)) {
|
||||
return false;
|
||||
}
|
||||
if (bounds.x < targetPoint.x && bounds.x + bounds.width > targetPoint.x && bounds.y < targetPoint.y && bounds.y + bounds.height < targetPoint.y) return false;
|
||||
|
||||
Rectangle pointless = getPointlessContentRec(bounds, pointerLength);
|
||||
|
||||
pointless.x += (arc + 1);
|
||||
pointless.width -= (arc * 2 + 2);
|
||||
pointless.y += (arc + 1);
|
||||
pointless.height -= (arc * 2 + 2);
|
||||
|
||||
|
||||
int size = getDistanceToTarget(pointless, targetPoint);
|
||||
if (size < pointerLength) return false;
|
||||
|
||||
Range<Integer> balloonRange;
|
||||
Range<Integer> pointerRange;
|
||||
if (isTopBottomPointer()) {
|
||||
balloonRange = new Range<Integer>(bounds.x, bounds.x + bounds.width);
|
||||
balloonRange = new Range<Integer>(bounds.x + arc, bounds.x + bounds.width - arc * 2);
|
||||
pointerRange = new Range<Integer>(targetPoint.x - pointerWidth / 2, targetPoint.x + pointerWidth / 2);
|
||||
} else {
|
||||
balloonRange = new Range<Integer>(bounds.y, bounds.y + bounds.height);
|
||||
balloonRange = new Range<Integer>(bounds.y + arc, bounds.y + bounds.height - arc * 2);
|
||||
pointerRange = new Range<Integer>(targetPoint.y - pointerWidth / 2, targetPoint.y + pointerWidth / 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ ide.tree.uiLockAttempt=250
|
||||
ide.splitter.mouseZone=6
|
||||
|
||||
ide.tooltip.callout=true
|
||||
ide.tooltip.useSystemColors=false
|
||||
|
||||
ide.tabbedPane.bufferedPaint=true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user