IDEA-126293 (set background recursively instead of toying with opacity)
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Fri, 31 Oct 2014 19:34:18 +0000 (20:34 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Fri, 31 Oct 2014 19:34:18 +0000 (20:34 +0100)
platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java
platform/platform-api/src/com/intellij/ui/GroupedElementsRenderer.java
platform/util/src/com/intellij/util/ui/UIUtil.java

index 44b4c8c5c3f097f69bcd01f1a196a72c89b9f7a2..e7c0c7aace78daaee1915577a41d9cacbbac095e 100644 (file)
@@ -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 {
     };
   }
 }
-
index 5fb4b53175c9442fec1b89a6b46253247690aa44..4a2abb304aa21d308a3e8ea910eacd66f91ef92b 100644 (file)
@@ -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());
   }
 
index 4ae0c69fc005fed79d88fd4bae7a2c68ded4134a..f9895a149168f9c5ef81a87dfb94228cd67bb32c 100644 (file)
@@ -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()));