IDEA-126293 (set background recursively instead of toying with opacity)

This commit is contained in:
Roman Shevchenko
2014-10-31 20:34:18 +01:00
parent d856838121
commit 449e5088c6
3 changed files with 14 additions and 9 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -84,8 +84,6 @@ public class BranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup {
myBranchLabel.setBackground(getBackground());
myBranchLabel.setForeground(JBColor.GRAY); // different foreground than for other elements
}
adjustOpacity(myBranchLabel, isSelected);
}
else {
myBranchLabel.setVisible(false);
@@ -111,4 +109,3 @@ public class BranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup {
};
}
}
@@ -73,13 +73,13 @@ public abstract class GroupedElementsRenderer {
setDeselected(myTextLabel);
}
adjustOpacity(myTextLabel, isSelected);
myRendererComponent.setPrefereedWidth(preferredForcedWidth);
return myRendererComponent;
}
/** @deprecated backgrounds are set uniformly via setSelected() / setDeselected() (to be removed in IDEA 16) */
@SuppressWarnings("UnusedDeclaration")
protected static void adjustOpacity(JComponent component, boolean selected) {
if (selected) {
if (UIUtil.isUnderNimbusLookAndFeel()) {
@@ -94,13 +94,12 @@ public abstract class GroupedElementsRenderer {
}
protected final void setSelected(JComponent aComponent) {
aComponent.setBackground(getSelectionBackground());
UIUtil.setBackgroundRecursively(aComponent, getSelectionBackground());
aComponent.setForeground(getSelectionForeground());
}
protected final void setDeselected(JComponent aComponent) {
aComponent.setBackground(getBackground());
UIUtil.setBackgroundRecursively(aComponent, getBackground());
aComponent.setForeground(getForeground());
}
@@ -2880,6 +2880,15 @@ public class UIUtil {
}
}
public static void setBackgroundRecursively(@NotNull Component component, @NotNull Color bg) {
component.setBackground(bg);
if (component instanceof Container) {
for (Component c : ((Container)component).getComponents()) {
setBackgroundRecursively(c, bg);
}
}
}
public static void addInsets(@NotNull JComponent component, @NotNull Insets insets) {
if (component.getBorder() != null) {
component.setBorder(new CompoundBorder(new EmptyBorder(insets), component.getBorder()));