From 43b8dcb72d00d603f79673426eba67383dabcf05 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Mon, 18 Dec 2017 22:55:32 +0300 Subject: [PATCH] update animated icon even for getIconWidth/Height --- .../src/com/intellij/ui/AnimatedIcon.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/AnimatedIcon.java b/platform/platform-impl/src/com/intellij/ui/AnimatedIcon.java index 3b7aaf16229f..886c3ea60014 100644 --- a/platform/platform-impl/src/com/intellij/ui/AnimatedIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AnimatedIcon.java @@ -143,13 +143,17 @@ public class AnimatedIcon implements Icon { time = current; } + private Icon getUpdatedIcon() { + long current = System.currentTimeMillis(); + if (frame.getDelay() <= (current - time)) updateFrameAt(current); + return frame.getIcon(); + } + @Override public final void paintIcon(Component c, Graphics g, int x, int y) { - int delay = frame.getDelay(); - long current = System.currentTimeMillis(); - if (delay <= (current - time)) updateFrameAt(current); - + Icon icon = getUpdatedIcon(); if (!requested && canRefresh(c)) { + int delay = frame.getDelay(); if (delay > 0) { requested = true; Timer timer = new Timer(delay, event -> { @@ -165,17 +169,17 @@ public class AnimatedIcon implements Icon { doRefresh(c); } } - frame.getIcon().paintIcon(c, g, x, y); + icon.paintIcon(c, g, x, y); } @Override public final int getIconWidth() { - return frame.getIcon().getIconWidth(); + return getUpdatedIcon().getIconWidth(); } @Override public final int getIconHeight() { - return frame.getIcon().getIconHeight(); + return getUpdatedIcon().getIconHeight(); } protected boolean canRefresh(Component component) {