mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
daemon tooltips
This commit is contained in:
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.daemon.impl;
|
||||
import com.intellij.codeInsight.hint.TooltipController;
|
||||
import com.intellij.codeInsight.hint.TooltipGroup;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.ui.HintHint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -41,13 +42,9 @@ public class DaemonTooltipUtil {
|
||||
public static void showInfoTooltip(@NotNull final HighlightInfo info, final Editor editor, final int defaultOffset, final int currentWidth) {
|
||||
if (info.toolTip == null) return;
|
||||
Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
|
||||
int startOffset = info.getActualStartOffset();
|
||||
int endOffset = info.getActualEndOffset();
|
||||
|
||||
Point top = editor.logicalPositionToXY(editor.offsetToLogicalPosition(startOffset));
|
||||
Point bottom = editor.logicalPositionToXY(editor.offsetToLogicalPosition(endOffset));
|
||||
|
||||
Point bestPoint = new Point(top.x, bottom.y + editor.getLineHeight());
|
||||
Point bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
|
||||
bestPoint.y += editor.getLineHeight() / 2;
|
||||
|
||||
if (!visibleArea.contains(bestPoint)) {
|
||||
bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
|
||||
@@ -58,6 +55,6 @@ public class DaemonTooltipUtil {
|
||||
bestPoint,
|
||||
editor.getComponent().getRootPane().getLayeredPane()
|
||||
);
|
||||
TooltipController.getInstance().showTooltip(editor, p, info.toolTip, currentWidth, false, DAEMON_INFO_GROUP);
|
||||
TooltipController.getInstance().showTooltip(editor, p, info.toolTip, currentWidth, false, DAEMON_INFO_GROUP, new HintHint(editor, bestPoint).setAwtTooltip(true).setHighlighterType(true));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -403,7 +403,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
|
||||
final int x,
|
||||
final int y,
|
||||
final JComponent focusBackComponent,
|
||||
@NotNull HintHint hintInfo) {
|
||||
@NotNull HintHint hintHint) {
|
||||
myVisible = true;
|
||||
if (myShouldDelay) {
|
||||
myAlarm.cancelAllRequests();
|
||||
|
||||
@@ -99,6 +99,11 @@ public class TooltipController {
|
||||
showTooltip(editor, p, tooltipRenderer, alignToRight, group);
|
||||
}
|
||||
|
||||
public void showTooltip(final Editor editor, Point p, String text, int currentWidth, boolean alignToRight, TooltipGroup group, HintHint hintHint) {
|
||||
TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
|
||||
showTooltip(editor, p, tooltipRenderer, alignToRight, group, hintHint);
|
||||
}
|
||||
|
||||
public void showTooltip(final Editor editor, Point p, TooltipRenderer tooltipRenderer, boolean alignToRight, TooltipGroup group) {
|
||||
showTooltip(editor, p, tooltipRenderer, alignToRight, group, new HintHint(editor, p));
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class IdeTooltip {
|
||||
|
||||
@@ -32,6 +32,7 @@ public class IdeTooltip {
|
||||
|
||||
private boolean myToCenter = false;
|
||||
private boolean myToCenterIfSmall = true;
|
||||
private boolean myHighlighter;
|
||||
|
||||
public IdeTooltip(Component component, Point point, JComponent tipComponent) {
|
||||
myComponent = component;
|
||||
@@ -98,5 +99,22 @@ public class IdeTooltip {
|
||||
public boolean canBeDismissedOnTimeout() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getShowDelay() {
|
||||
return myHighlighter ? Registry.intValue("ide.tooltip.initialDelay.highlighter") : Registry.intValue("ide.tooltip.initialDelay");
|
||||
}
|
||||
|
||||
public int getInitialReshowDelay() {
|
||||
return Registry.intValue("ide.tooltip.initialReshowDelay");
|
||||
}
|
||||
|
||||
public int getDismissDelay() {
|
||||
return Registry.intValue("ide.tooltip.dismissDelay");
|
||||
}
|
||||
|
||||
public IdeTooltip setHighlighterType(boolean isHighlighter) {
|
||||
myHighlighter = isHighlighter;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
if (now) {
|
||||
myShowRequest.run();
|
||||
} else {
|
||||
myAlarm.addRequest(myShowRequest, myShowDelay ? Registry.intValue("ide.tooltip.initialDelay") : Registry.intValue("ide.tooltip.initialReshowDelay"));
|
||||
myAlarm.addRequest(myShowRequest, myShowDelay ? tooltip.getShowDelay() : tooltip.getInitialReshowDelay());
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
@@ -258,7 +258,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
hideCurrent(null);
|
||||
}
|
||||
}
|
||||
}, Registry.intValue("ide.tooltip.dismissDelay"));
|
||||
}, tooltip.getDismissDelay());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ public class HintHint {
|
||||
|
||||
private boolean myContentActive = true;
|
||||
|
||||
private boolean myQuickHint = false;
|
||||
|
||||
public HintHint(MouseEvent e) {
|
||||
this(e.getComponent(), e.getPoint());
|
||||
}
|
||||
@@ -115,6 +117,15 @@ public class HintHint {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HintHint setHighlighterType(boolean highlighter) {
|
||||
myQuickHint = highlighter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isHightlighterType() {
|
||||
return myQuickHint;
|
||||
}
|
||||
|
||||
private IdeTooltipManager getTooltipManager() {
|
||||
return IdeTooltipManager.getInstance();
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
|
||||
final int x,
|
||||
final int y,
|
||||
final JComponent focusBackComponent,
|
||||
@NotNull final HintHint hintInfo) {
|
||||
@NotNull final HintHint hintHint) {
|
||||
myParentComponent = parentComponent;
|
||||
|
||||
myFocusBackComponent = focusBackComponent;
|
||||
@@ -124,12 +124,12 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
|
||||
final Dimension preferredSize = myComponent.getPreferredSize();
|
||||
|
||||
|
||||
if (hintInfo.isAwtTooltip()) {
|
||||
IdeTooltip tooltip = new IdeTooltip(hintInfo.getOriginalComponent(), hintInfo.getOriginalPoint(), myComponent) {
|
||||
if (hintHint.isAwtTooltip()) {
|
||||
IdeTooltip tooltip = new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent) {
|
||||
@Override
|
||||
protected boolean canAutohideOn(TooltipEvent event) {
|
||||
if (event.getInputEvent() instanceof MouseEvent) {
|
||||
return !(hintInfo.isContentActive() && event.isIsEventInsideBalloon());
|
||||
return !(hintHint.isContentActive() && event.isIsEventInsideBalloon());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
|
||||
public boolean canBeDismissedOnTimeout() {
|
||||
return false;
|
||||
}
|
||||
}.setToCenterIfSmall(false).setPreferredPosition(hintInfo.getPreferredPosition());
|
||||
}.setToCenterIfSmall(false).setPreferredPosition(hintHint.getPreferredPosition()).setHighlighterType(hintHint.isHightlighterType());
|
||||
|
||||
myComponent.validate();
|
||||
myCurrentIdeTooltip = IdeTooltipManager.getInstance().show(tooltip, false);
|
||||
|
||||
@@ -63,6 +63,7 @@ ide.tooltip.callout=true
|
||||
ide.tooltip.mode=default
|
||||
ide.tooltip.description=Available options are: default,system,graphite
|
||||
ide.tooltip.initialDelay=1200
|
||||
ide.tooltip.initialDelay.highlighter=150
|
||||
ide.tooltip.reshowDelay=500
|
||||
ide.tooltip.dismissDelay=4000
|
||||
ide.tooltip.initialReshowDelay=300
|
||||
|
||||
Reference in New Issue
Block a user