IDEA-69923 unnecessary tooltip animation

This commit is contained in:
Kirill Kalishev
2011-05-20 16:26:31 +04:00
parent f51e5bf5ce
commit bbdd39ea93
4 changed files with 27 additions and 9 deletions
@@ -47,6 +47,8 @@ public interface Balloon extends Disposable {
void hide();
void setAnimationEnabled(boolean enabled);
boolean wasFadedIn();
boolean wasFadedOut();
@@ -201,6 +201,10 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
}
public IdeTooltip show(final IdeTooltip tooltip, boolean now) {
return show(tooltip, now, true);
}
public IdeTooltip show(final IdeTooltip tooltip, boolean now, final boolean animationEnabled) {
myAlarm.cancelAllRequests();
hideCurrent(null, null, null);
@@ -216,15 +220,15 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
}
if (myQueuedComponent != tooltip.getComponent() || !tooltip.getComponent().isShowing()) {
hideCurrent(null, null, null);
hideCurrent(null, null, null, animationEnabled);
return;
}
if (tooltip.beforeShow()) {
show(tooltip, null);
show(tooltip, null, animationEnabled);
}
else {
hideCurrent(null, null, null);
hideCurrent(null, null, null, animationEnabled);
}
}
};
@@ -238,7 +242,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
return tooltip;
}
private void show(final IdeTooltip tooltip, Runnable beforeShow) {
private void show(final IdeTooltip tooltip, Runnable beforeShow, boolean animationEnabled) {
boolean toCenterX;
boolean toCenterY;
@@ -275,7 +279,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
.setPreferredPosition(tooltip.getPreferredPosition())
.setFillColor(bg)
.setBorderColor(border)
.setAnimationCycle(Registry.intValue("ide.tooltip.animationCycle"))
.setAnimationCycle(animationEnabled ? Registry.intValue("ide.tooltip.animationCycle") : 0)
.setShowCallout(true)
.setCalloutShift((small && tooltip.getCalloutShift() == 0) ? -2 : tooltip.getCalloutShift())
.setPositionChangeXShift(tooltip.getPositionChangeX())
@@ -362,6 +366,10 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
}
public boolean hideCurrent(@Nullable MouseEvent me, AnAction action, AnActionEvent event) {
return hideCurrent(me, action, event, true);
}
public boolean hideCurrent(@Nullable MouseEvent me, AnAction action, AnActionEvent event, final boolean animationEnabled) {
myShowRequest = null;
myQueuedComponent = null;
myQueuedTooltip = null;
@@ -385,7 +393,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
@Override
public void run() {
if (myHideRunnable != null) {
hideCurrentNow();
hideCurrentNow(animationEnabled);
myHideRunnable = null;
}
}
@@ -401,8 +409,9 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
return true;
}
private void hideCurrentNow() {
private void hideCurrentNow(boolean animationEnabled) {
if (myCurrentTipUi != null) {
myCurrentTipUi.setAnimationEnabled(animationEnabled);
myCurrentTipUi.hide();
myCurrentTooltip.onHidden();
myShowDelay = false;
@@ -153,6 +153,8 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
private String myTitle;
private JLabel myTitleLabel;
private boolean myAnimationEnabled = true;
public boolean isInsideBalloon(MouseEvent me) {
return isInside(new RelativePoint(me));
}
@@ -532,7 +534,7 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
if (myAnimator != null) {
Disposer.dispose(myAnimator);
}
myAnimator = new Animator("Balloon", 10, myAnimationCycle, false, 0, 1, forward) {
myAnimator = new Animator("Balloon", 10, myAnimationEnabled ? myAnimationCycle : 0, false, 0, 1, forward) {
public void paintNow(final float frame, final float totalFrames, final float cycle) {
if (myComp == null || myComp.getParent() == null) return;
myComp.setAlpha(frame / totalFrames);
@@ -1425,4 +1427,9 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
Point p = myPosition.getShiftedPoint(myTargetPoint, myCalloutshift * -1);
return new RelativePoint(myLayeredPane, p);
}
@Override
public void setAnimationEnabled(boolean enabled) {
myAnimationEnabled = enabled;
}
}
@@ -401,7 +401,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
if (!screenPoint.equals(new RelativePoint(myCurrentIdeTooltip.getComponent(), myCurrentIdeTooltip.getPoint()).getScreenPoint())) {
myCurrentIdeTooltip.setPoint(point.getPoint());
myCurrentIdeTooltip.setComponent(point.getComponent());
IdeTooltipManager.getInstance().show(myCurrentIdeTooltip, true);
IdeTooltipManager.getInstance().show(myCurrentIdeTooltip, true, false);
}
} else {
Point targetPoint = point.getPoint(myComponent.getParent());