ExpUI: fix popup actions from invisible toolbar

GitOrigin-RevId: 8acd505c2d42c160c0fdb999e517dfe835b75103
This commit is contained in:
Sergey Malenkov
2021-12-09 14:58:53 +00:00
committed by intellij-monorepo-bot
parent f1c3734723
commit 67de402617
2 changed files with 19 additions and 22 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem.impl;
import com.intellij.icons.AllIcons;
@@ -157,8 +157,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
private boolean myShowSeparatorTitles;
private Image myCachedImage;
private final AlphaAnimationContext myAlphaContext = new AlphaAnimationContext(composite -> {
super.setVisible(composite != null);
@ApiStatus.Internal
@ApiStatus.Experimental
public final AlphaAnimationContext myAlphaContext = new AlphaAnimationContext(composite -> {
if (isShowing()) repaint();
});
@@ -296,13 +297,17 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
}
@Override
protected void paintComponent(final Graphics g) {
if (g instanceof Graphics2D) {
Graphics2D g2d = (Graphics2D)g;
AlphaComposite composite = myAlphaContext.getComposite();
if (composite == null) return; // do not paint a completely transparent component
g2d.setComposite(composite);
public void paint(Graphics g) {
if (g instanceof Graphics2D && ExperimentalUI.isNewUI()) {
myAlphaContext.paintWithComposite((Graphics2D)g, () -> super.paint(g));
}
else {
super.paint(g);
}
}
@Override
protected void paintComponent(final Graphics g) {
if (myCachedImage != null) {
UIUtil.drawImage(g, myCachedImage, 0, 0, null);
return;
@@ -1112,16 +1117,6 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
revalidate();
}
@Override
public void setVisible(boolean visible) {
if (ExperimentalUI.isNewUI()) {
myAlphaContext.setVisible(visible);
}
else {
super.setVisible(visible);
}
}
@Override
public void setOrientation(@MagicConstant(intValues = {SwingConstants.HORIZONTAL, SwingConstants.VERTICAL}) int orientation) {
if (SwingConstants.HORIZONTAL != orientation && SwingConstants.VERTICAL != orientation) {
@@ -1,9 +1,10 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.wm.impl;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.ui.Queryable;
@@ -546,8 +547,9 @@ public final class InternalDecoratorImpl extends InternalDecorator implements Qu
void updateActiveAndHoverState() {
ActionToolbar toolbar = getHeaderToolbar();
if (toolbar != null) {
toolbar.getComponent().setVisible(!isNewUI() || isWindowHovered || toolWindow.isActive());
if (toolbar instanceof ActionToolbarImpl) {
ActionToolbarImpl impl = (ActionToolbarImpl)toolbar;
impl.myAlphaContext.setVisible(!isNewUI() || isWindowHovered || toolWindow.isActive());
}
}