From 0074083ff35a11cd64850f7cd45a4817d14301c5 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Sun, 25 Dec 2016 00:52:03 +0300 Subject: [PATCH] [ui] fix fade-out in loading decorator with smooth scrolling enabled In order to have smooth scrolling, loading layer should not be on top of viewport, but rather added on demand. But since loading layer has fade-out, it can not be removed immediately when setLoadingLayerVisible is called. It should be removed only at the end of fade out. Before that removal, it should paint with zero alpha, in order not to leave artifacts after itself. --- .../intellij/openapi/ui/LoadingDecorator.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java index 6587cb4c8a11..1713920d1f26 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java @@ -66,7 +66,8 @@ public class LoadingDecorator { @Override protected void paintCycleEnd() { - setLoadingLayerVisible(false); + myLoadingLayer.setAlpha(0); // paint with zero alpha before hiding completely + hideLoadingLayer(); myLoadingLayer.setAlpha(-1); } }; @@ -81,16 +82,16 @@ public class LoadingDecorator { Disposer.register(parent, myLoadingLayer.myProgress); } - private void setLoadingLayerVisible(boolean visible) { + private void hideLoadingLayer() { if (SystemProperties.isTrueSmoothScrollingEnabled()) { - setLoadingLayerPresent(visible); + myPane.remove(myLoadingLayer); } - myLoadingLayer.setVisible(visible); + myLoadingLayer.setVisible(false); } public void setLoadingLayerVisible(boolean visible, boolean takeSnapshot) { - if (SystemProperties.isTrueSmoothScrollingEnabled()) { - setLoadingLayerPresent(visible); + if (SystemProperties.isTrueSmoothScrollingEnabled() && visible) { + setLoadingLayerPresent(); } myLoadingLayer.setVisible(visible, takeSnapshot); } @@ -102,13 +103,9 @@ public class LoadingDecorator { Blit-acceleration copies as much of the rendered area as possible and then repaints only newly exposed region. This helps to improve scrolling performance and to reduce CPU usage (especially if drawing is compute-intensive). */ - private void setLoadingLayerPresent(boolean present) { - if (present) { - if (myPane.getComponentCount() < 2) { - myPane.add(myLoadingLayer, JLayeredPane.DRAG_LAYER, 1); - } - } else { - myPane.remove(myLoadingLayer); + private void setLoadingLayerPresent() { + if (myPane.getComponentCount() < 2) { + myPane.add(myLoadingLayer, JLayeredPane.DRAG_LAYER, 1); } }