Browse Source

smoother tooltip fade in

Signed-off-by: weisj <weisj@arcor.de>
pull/60/head
weisj 5 years ago
parent
commit
23a38f0d94
  1. 8
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/DarkToolTip.java
  2. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java

8
core/src/main/java/com/github/weisj/darklaf/components/tooltip/DarkToolTip.java

@ -54,12 +54,16 @@ public class DarkToolTip extends JToolTip implements PropertyChangeListener {
addAncestorListener(new AncestorAdapter() { addAncestorListener(new AncestorAdapter() {
@Override @Override
public void ancestorAdded(final AncestorEvent event) { public void ancestorAdded(final AncestorEvent event) {
setVisible(true); boolean resume = false;
notifyToolTipListeners(ToolTipEvent.SHOWN);
if (Math.abs(System.currentTimeMillis() - lastHidden) < REPAINT_THRESHOLD) { if (Math.abs(System.currentTimeMillis() - lastHidden) < REPAINT_THRESHOLD) {
alpha = 1.0f; alpha = 1.0f;
} else { } else {
alpha = 0; alpha = 0;
resume = true;
}
setVisible(true);
notifyToolTipListeners(ToolTipEvent.SHOWN);
if (resume) {
fadeAnimator.reset(); fadeAnimator.reset();
fadeAnimator.resume(); fadeAnimator.resume();
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java

@ -193,7 +193,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe
@Override @Override
public void hierarchyChanged(final HierarchyEvent e) { public void hierarchyChanged(final HierarchyEvent e) {
Window w = SwingUtilities.getWindowAncestor(toolTip); Window w = SwingUtilities.getWindowAncestor(toolTip);
if (w != null && !isDecorated(w) && w.getClass().getEnclosingClass().equals(Popup.class)) { if (w != null && !isDecorated(w) && (w.getClass().getEnclosingClass().equals(Popup.class))) {
w.setBackground(DarkUIUtil.TRANSPARENT_COLOR); w.setBackground(DarkUIUtil.TRANSPARENT_COLOR);
} }
} }

Loading…
Cancel
Save