Last active
December 29, 2018 02:01
-
-
Save 13steinj/93750ec642842426eca9bf06d5fb076a to your computer and use it in GitHub Desktop.
Patch to revert Native LaF removal (Jetbrains IDEs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a2b400805644075765a66e8747af6cbb4262bb12 Mon Sep 17 00:00:00 2001 | |
From: 13steinj <[email protected]> | |
Date: Sun, 16 Dec 2018 01:10:40 -0500 | |
Subject: [PATCH] Resurrection | |
--- | |
.../NotificationMessageElement.java | 3 +- | |
.../daemon/impl/HectorComponent.java | 8 +- | |
.../intellij/find/SearchReplaceComponent.java | 10 ++ | |
.../src/com/intellij/find/SearchTextArea.java | 17 ++- | |
.../commander/ColoredCommanderRenderer.java | 5 + | |
.../ide/navigationToolbar/NavBarPanel.java | 4 +- | |
.../ide/navigationToolbar/ui/GtkNavBarUI.java | 28 +++++ | |
.../navigationToolbar/ui/NavBarUIManager.java | 4 +- | |
.../ide/util/gotoByName/ChooseByNameBase.java | 2 +- | |
.../intellij/ide/wizard/AbstractWizard.java | 5 +- | |
.../openapi/actionSystem/ToggleAction.java | 3 +- | |
.../intellij/openapi/ui/DialogWrapper.java | 3 + | |
.../src/com/intellij/ui/CheckboxTreeBase.java | 4 + | |
.../intellij/ui/ColoredListCellRenderer.java | 24 +++- | |
.../intellij/ui/ColoredTreeCellRenderer.java | 6 +- | |
.../intellij/ui/ListCellRendererWrapper.java | 10 +- | |
.../src/com/intellij/ui/SearchTextField.java | 2 +- | |
.../src/com/intellij/ui/table/JBTable.java | 10 +- | |
.../intellij/ui/treeStructure/SimpleTree.java | 2 +- | |
.../com/intellij/ui/treeStructure/Tree.java | 17 ++- | |
.../src/com/intellij/ide/IdeEventQueue.java | 20 ++- | |
.../customize/CustomizeUIThemeStepPanel.java | 3 + | |
.../ide/errorTreeView/NewErrorTreeEditor.java | 3 +- | |
.../com/intellij/ide/ui/laf/IntelliJLaf.java | 9 ++ | |
.../intellij/ide/ui/laf/LafManagerImpl.java | 116 ++++++++++++++++-- | |
.../ui/laf/darcula/ui/DarculaComboBoxUI.java | 1 + | |
.../openapi/actionSystem/impl/ActionMenu.java | 53 +++++++- | |
.../actionSystem/impl/ActionMenuItem.java | 28 ++++- | |
.../openapi/actionSystem/impl/Utils.java | 13 +- | |
.../editor/actions/ContentChooser.java | 6 +- | |
.../intellij/openapi/wm/impl/IdeMenuBar.java | 7 +- | |
.../intellij/ui/plaf/gtk/GtkMenuItemUI.java | 103 ++++++++++++++++ | |
.../com/intellij/ui/plaf/gtk/GtkMenuUI.java | 58 +++++++++ | |
.../intellij/ui/plaf/gtk/GtkPaintingUtil.java | 52 ++++++++ | |
.../com/intellij/ui/plaf/gtk/IconWrapper.java | 49 ++++++++ | |
.../util/src/com/intellij/util/ui/JBUI.java | 2 +- | |
.../util/src/com/intellij/util/ui/UIUtil.java | 25 ++-- | |
.../openapi/vcs/changes/ui/ChangesTree.java | 14 ++- | |
.../vcs/changes/ui/IgnoredSettingsPanel.java | 7 ++ | |
.../impl/frame/XDebuggerFramesList.java | 6 + | |
40 files changed, 673 insertions(+), 69 deletions(-) | |
create mode 100644 platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/GtkNavBarUI.java | |
create mode 100644 platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuItemUI.java | |
create mode 100644 platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuUI.java | |
create mode 100644 platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkPaintingUtil.java | |
create mode 100644 platform/platform-impl/src/com/intellij/ui/plaf/gtk/IconWrapper.java | |
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationMessageElement.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationMessageElement.java | |
index 13cf0a8ba204..19c935b22554 100644 | |
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationMessageElement.java | |
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationMessageElement.java | |
@@ -128,7 +128,8 @@ public class NotificationMessageElement extends NavigatableMessageElement { | |
} | |
} | |
- if (tree != null && WideSelectionTreeUI.isWideSelection(tree)) { | |
+ if (UIUtil.isUnderGTKLookAndFeel() || | |
+ tree != null && WideSelectionTreeUI.isWideSelection(tree)) { | |
editorPane.setOpaque(false); | |
} | |
else { | |
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java | |
index d18bc27a0a34..ff8179bdcf40 100644 | |
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java | |
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java | |
@@ -52,10 +52,11 @@ import org.jetbrains.annotations.NotNull; | |
import org.jetbrains.annotations.Nullable; | |
import javax.swing.*; | |
+import javax.swing.plaf.basic.BasicSliderUI; | |
import java.awt.*; | |
import java.lang.ref.WeakReference; | |
-import java.util.List; | |
import java.util.*; | |
+import java.util.List; | |
public class HectorComponent extends JPanel { | |
private static final Logger LOG = Logger.getInstance("com.intellij.openapi.editor.impl.HectorComponent"); | |
@@ -90,6 +91,11 @@ public class HectorComponent extends JPanel { | |
} | |
final JSlider slider = new JSlider(SwingConstants.VERTICAL, 1, notInLibrary ? 3 : 2, 1); | |
+ if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ // default GTK+ slider UI is way too ugly | |
+ slider.putClientProperty("Slider.paintThumbArrowShape", true); | |
+ slider.setUI(new BasicSliderUI(slider)); | |
+ } | |
slider.setLabelTable(sliderLabels); | |
UIUtil.setSliderIsFilled(slider, true); | |
slider.setPaintLabels(true); | |
diff --git a/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java b/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java | |
index b04599eedca0..a6509b2ae804 100644 | |
--- a/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java | |
+++ b/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java | |
@@ -252,6 +252,16 @@ public class SearchReplaceComponent extends EditorHeaderComponent implements Dat | |
mySearchTextComponent.setBackground(LightColors.RED); | |
} | |
+ @Override | |
+ public Insets getInsets() { | |
+ Insets insets = super.getInsets(); | |
+ if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ insets.top += 1; | |
+ insets.bottom += 2; | |
+ } | |
+ return insets; | |
+ } | |
+ | |
@Nullable | |
@Override | |
public Object getData(@NotNull @NonNls String dataId) { | |
diff --git a/platform/lang-impl/src/com/intellij/find/SearchTextArea.java b/platform/lang-impl/src/com/intellij/find/SearchTextArea.java | |
index 23b50aa762c6..277d7dedf916 100644 | |
--- a/platform/lang-impl/src/com/intellij/find/SearchTextArea.java | |
+++ b/platform/lang-impl/src/com/intellij/find/SearchTextArea.java | |
@@ -181,7 +181,11 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList | |
private void updateFont() { | |
if (myTextArea != null) { | |
- Utils.setSmallerFont(myTextArea); | |
+ if (UIUtil.isUnderWindowsLookAndFeel()) { | |
+ myTextArea.setFont(UIManager.getFont("TextField.font")); | |
+ } else { | |
+ Utils.setSmallerFont(myTextArea); | |
+ } | |
} | |
} | |
@@ -318,6 +322,17 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList | |
g.dispose(); | |
} | |
super.paint(graphics); | |
+ | |
+ if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ graphics.setColor(myTextArea.getBackground()); | |
+ Rectangle bounds = myScrollPane.getViewport().getBounds(); | |
+ if (myScrollPane.getVerticalScrollBar().isVisible()) { | |
+ bounds.width -= myScrollPane.getVerticalScrollBar().getWidth(); | |
+ } | |
+ bounds = SwingUtilities.convertRectangle(myScrollPane.getViewport()/*myTextArea*/, bounds, this); | |
+ JBInsets.addTo(bounds, new JBInsets(2, 2, -1, -1)); | |
+ ((Graphics2D)graphics).draw(bounds); | |
+ } | |
} | |
private class ShowHistoryAction extends DumbAwareAction { | |
diff --git a/platform/lang-impl/src/com/intellij/ide/commander/ColoredCommanderRenderer.java b/platform/lang-impl/src/com/intellij/ide/commander/ColoredCommanderRenderer.java | |
index 7b81433d5515..96e31f8fa96a 100644 | |
--- a/platform/lang-impl/src/com/intellij/ide/commander/ColoredCommanderRenderer.java | |
+++ b/platform/lang-impl/src/com/intellij/ide/commander/ColoredCommanderRenderer.java | |
@@ -52,6 +52,11 @@ final class ColoredCommanderRenderer extends ColoredListCellRenderer { | |
@Override | |
protected void customizeCellRenderer(@NotNull final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) { | |
+ // Fix GTK background | |
+ if (UIUtil.isUnderGTKLookAndFeel()){ | |
+ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); | |
+ UIUtil.changeBackGround(this, background); | |
+ } | |
Color color = UIUtil.getListForeground(); | |
SimpleTextAttributes attributes = null; | |
String locationString = null; | |
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java | |
index 3c5394b99cc9..c29555faaed9 100644 | |
--- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java | |
+++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java | |
@@ -76,8 +76,8 @@ import javax.swing.tree.TreeNode; | |
import java.awt.*; | |
import java.awt.event.*; | |
import java.io.File; | |
-import java.util.List; | |
import java.util.*; | |
+import java.util.List; | |
/** | |
* @author Konstantin Bulenkov | |
@@ -793,7 +793,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis | |
final JPanel panel = new JPanel(new BorderLayout()); | |
panel.add(this); | |
panel.setOpaque(true); | |
- panel.setBackground(UIUtil.getListBackground()); | |
+ panel.setBackground(UIUtil.isUnderGTKLookAndFeel() ? Color.WHITE : UIUtil.getListBackground()); | |
myHint = new LightweightHint(panel) { | |
@Override | |
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/GtkNavBarUI.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/GtkNavBarUI.java | |
new file mode 100644 | |
index 000000000000..aeb2b3b34dde | |
--- /dev/null | |
+++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/GtkNavBarUI.java | |
@@ -0,0 +1,28 @@ | |
+/* | |
+ * Copyright 2000-2011 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. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed on an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+package com.intellij.ide.navigationToolbar.ui; | |
+ | |
+import java.awt.*; | |
+ | |
+/** | |
+ * @author Konstantin Bulenkov | |
+ */ | |
+public class GtkNavBarUI extends CommonNavBarUI { | |
+ @Override | |
+ public Color getBackground(boolean selected, boolean focused) { | |
+ return selected && focused ? super.getBackground(selected, focused) : Color.WHITE; | |
+ } | |
+} | |
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/NavBarUIManager.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/NavBarUIManager.java | |
index 96ab1c19d505..824ad179be45 100644 | |
--- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/NavBarUIManager.java | |
+++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/NavBarUIManager.java | |
@@ -24,10 +24,12 @@ public class NavBarUIManager { | |
public static final NavBarUI AQUA = new AquaNavBarUI(); | |
public static final NavBarUI COMMON = new CommonNavBarUI(); | |
public static final NavBarUI DARCULA = new DarculaNavBarUI(); | |
- | |
+ public static final NavBarUI GTK = new GtkNavBarUI(); | |
+ | |
public static NavBarUI getUI() { | |
if (UIUtil.isUnderAquaLookAndFeel()) return AQUA; | |
+ if (UIUtil.isUnderGTKLookAndFeel()) return GTK; | |
if (UIUtil.isUnderDarcula()) return DARCULA; | |
return COMMON; | |
} | |
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java | |
index cf9bf918962c..227383f0f1b9 100644 | |
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java | |
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java | |
@@ -1099,7 +1099,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel { | |
private MyTextField() { | |
super(40); | |
// Set UI and border for Darcula and all except Win10, Mac and GTK | |
- if (!UIUtil.isUnderDefaultMacTheme() && !UIUtil.isUnderWin10LookAndFeel()) { | |
+ if (!UIUtil.isUnderGTKLookAndFeel() && !UIUtil.isUnderDefaultMacTheme() && !UIUtil.isUnderWin10LookAndFeel()) { | |
if (!(getUI() instanceof DarculaTextFieldUI)) { | |
setUI(DarculaTextFieldUI.createUI(this)); | |
} | |
diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java | |
index 30f7fac5eccd..7f1f7e8a29de 100644 | |
--- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java | |
+++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java | |
@@ -165,12 +165,15 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper { | |
final Collection<Component> buttons = ContainerUtil.newArrayListWithCapacity(5); | |
final boolean helpAvailable = ApplicationInfo.contextHelpAvailable(); | |
+ if (helpAvailable && UIUtil.isUnderGTKLookAndFeel()) { | |
+ add(hGroup, vGroup, buttons, myHelpButton); | |
+ } | |
add(hGroup, vGroup, null, Box.createHorizontalGlue()); | |
if (mySteps.size() > 1) { | |
add(hGroup, vGroup, buttons, myPreviousButton); | |
} | |
add(hGroup, vGroup, buttons, myNextButton, myCancelButton); | |
- if (helpAvailable) { | |
+ if (helpAvailable && !UIUtil.isUnderGTKLookAndFeel()) { | |
add(hGroup, vGroup, buttons, myHelpButton); | |
} | |
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java | |
index e1e9624b194b..03ac65e07c8e 100644 | |
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java | |
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java | |
@@ -15,6 +15,7 @@ | |
*/ | |
package com.intellij.openapi.actionSystem; | |
+import com.intellij.util.ui.UIUtil; | |
import org.jetbrains.annotations.NotNull; | |
import org.jetbrains.annotations.Nullable; | |
@@ -64,7 +65,7 @@ public abstract class ToggleAction extends AnAction implements Toggleable { | |
boolean selected = isSelected(e); | |
final Presentation presentation = e.getPresentation(); | |
presentation.putClientProperty(SELECTED_PROPERTY, selected); | |
- if (e.isFromContextMenu()) { | |
+ if (e.isFromContextMenu() && !UIUtil.isUnderGTKLookAndFeel()) { | |
//force to show check marks instead of toggled icons in context menu | |
presentation.setIcon(null); | |
} | |
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java | |
index f724d4f9d6f7..78795c567c82 100644 | |
--- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java | |
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java | |
@@ -493,6 +493,9 @@ public abstract class DialogWrapper { | |
actions.add(okNdx < 0 ? 0 : actions.size() - 1, getCancelAction()); | |
} | |
} | |
+ else if (UIUtil.isUnderGTKLookAndFeel() && actions.remove(helpAction)) { | |
+ leftSideActions.add(helpAction); | |
+ } | |
if (!UISettings.getShadowInstance().getAllowMergeButtons()) { | |
actions = flattenOptionsActions(actions); | |
diff --git a/platform/platform-api/src/com/intellij/ui/CheckboxTreeBase.java b/platform/platform-api/src/com/intellij/ui/CheckboxTreeBase.java | |
index 45d177f7d55a..b270ad788e16 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/CheckboxTreeBase.java | |
+++ b/platform/platform-api/src/com/intellij/ui/CheckboxTreeBase.java | |
@@ -177,6 +177,10 @@ public class CheckboxTreeBase extends Tree { | |
} | |
myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); | |
+ if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); | |
+ UIUtil.changeBackGround(this, background); | |
+ } | |
customizeRenderer(tree, value, selected, expanded, leaf, row, hasFocus); | |
revalidate(); | |
diff --git a/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java b/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java | |
index d2fd9694a872..b7d55cdfdb62 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java | |
+++ b/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java | |
@@ -14,6 +14,7 @@ import java.awt.*; | |
*/ | |
public abstract class ColoredListCellRenderer<T> extends SimpleColoredComponent implements ListCellRenderer<T> { | |
private final @Nullable JComboBox myComboBox; | |
+ private final @Nullable ListCellRenderer<? super T> myDefaultGtkRenderer; | |
protected boolean mySelected; | |
protected Color myForeground; | |
@@ -25,6 +26,8 @@ public abstract class ColoredListCellRenderer<T> extends SimpleColoredComponent | |
public ColoredListCellRenderer(@Nullable JComboBox comboBox) { | |
myComboBox = comboBox; | |
+ //noinspection UndesirableClassUsage | |
+ myDefaultGtkRenderer = UIUtil.isUnderGTKLookAndFeel() ? new JComboBox<T>().getRenderer() : null; | |
setFocusBorderAroundIcon(true); | |
getIpad().left = getIpad().right = UIUtil.isUnderWin10LookAndFeel() ? 0 : JBUI.scale(UIUtil.getListCellHPadding()); | |
} | |
@@ -42,7 +45,18 @@ public abstract class ColoredListCellRenderer<T> extends SimpleColoredComponent | |
myForeground = isEnabled() ? list.getForeground() : UIManager.getColor("Label.disabledForeground"); | |
mySelectionForeground = list.getSelectionForeground(); | |
- if (UIUtil.isUnderWin10LookAndFeel()) { | |
+ if (UIUtil.isWinLafOnVista()) { | |
+ // the system draws a gradient background on the combobox selected item - don't overdraw it with our solid background | |
+ if (index == -1) { | |
+ setOpaque(false); | |
+ mySelected = false; | |
+ } | |
+ else { | |
+ setOpaque(true); | |
+ setBackground(selected ? list.getSelectionBackground() : null); | |
+ } | |
+ } | |
+ else if (UIUtil.isUnderWin10LookAndFeel()) { | |
setBackground(selected ? list.getSelectionBackground() : list.getBackground()); | |
} | |
else { | |
@@ -50,8 +64,16 @@ public abstract class ColoredListCellRenderer<T> extends SimpleColoredComponent | |
} | |
setPaintFocusBorder(hasFocus); | |
+ | |
customizeCellRenderer(list, value, index, selected, hasFocus); | |
+ if (myDefaultGtkRenderer != null && list.getModel() instanceof ComboBoxModel) { | |
+ Component component = myDefaultGtkRenderer.getListCellRendererComponent(list, value, index, selected, hasFocus); | |
+ if (component instanceof JLabel) { | |
+ return formatToLabel((JLabel)component); | |
+ } | |
+ } | |
+ | |
return this; | |
} | |
diff --git a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java | |
index 5deb4bfc1b6f..71ce565e224b 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java | |
+++ b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java | |
@@ -84,7 +84,11 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp | |
setIcon(null); | |
} | |
- if (WideSelectionTreeUI.isWideSelection(tree)) { | |
+ if (UIUtil.isUnderGTKLookAndFeel()){ | |
+ super.setOpaque(false); // avoid nasty background | |
+ super.setIconOpaque(false); | |
+ } | |
+ else if (WideSelectionTreeUI.isWideSelection(tree)) { | |
super.setOpaque(false); // avoid erasing Nimbus focus frame | |
super.setIconOpaque(false); | |
} | |
diff --git a/platform/platform-api/src/com/intellij/ui/ListCellRendererWrapper.java b/platform/platform-api/src/com/intellij/ui/ListCellRendererWrapper.java | |
index 97fc7f9622cf..22c0df27588b 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/ListCellRendererWrapper.java | |
+++ b/platform/platform-api/src/com/intellij/ui/ListCellRendererWrapper.java | |
@@ -96,10 +96,12 @@ public abstract class ListCellRendererWrapper<T> implements ListCellRenderer<T> | |
public static Component createSeparator(@Nullable String text) { | |
final TitledSeparator separator = new TitledSeparator(text); | |
separator.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); | |
- separator.setOpaque(false); | |
- separator.setBackground(UIUtil.TRANSPARENT_COLOR); | |
- separator.getLabel().setOpaque(false); | |
- separator.getLabel().setBackground(UIUtil.TRANSPARENT_COLOR); | |
+ if (!UIUtil.isUnderGTKLookAndFeel()) { | |
+ separator.setOpaque(false); | |
+ separator.setBackground(UIUtil.TRANSPARENT_COLOR); | |
+ separator.getLabel().setOpaque(false); | |
+ separator.getLabel().setBackground(UIUtil.TRANSPARENT_COLOR); | |
+ } | |
return separator; | |
} | |
diff --git a/platform/platform-api/src/com/intellij/ui/SearchTextField.java b/platform/platform-api/src/com/intellij/ui/SearchTextField.java | |
index 8a8c821d8a60..f21b683d4220 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/SearchTextField.java | |
+++ b/platform/platform-api/src/com/intellij/ui/SearchTextField.java | |
@@ -290,7 +290,7 @@ public class SearchTextField extends JPanel { | |
} | |
protected boolean hasIconsOutsideOfTextField() { | |
- return false; | |
+ return UIUtil.isUnderGTKLookAndFeel(); | |
} | |
protected boolean customSetupUIAndTextField(@NotNull TextFieldWithProcessing textField, @NotNull Consumer<? super TextUI> uiConsumer) { | |
diff --git a/platform/platform-api/src/com/intellij/ui/table/JBTable.java b/platform/platform-api/src/com/intellij/ui/table/JBTable.java | |
index 732985760f3e..6dfe137c679a 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/table/JBTable.java | |
+++ b/platform/platform-api/src/com/intellij/ui/table/JBTable.java | |
@@ -235,7 +235,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component | |
@Override | |
public void setRowHeight(int rowHeight) { | |
- if (!myUiUpdating) { | |
+ if (!myUiUpdating || !UIUtil.isUnderGTKLookAndFeel()) { | |
myRowHeight = rowHeight; | |
myRowHeightIsExplicitlySet = true; | |
} | |
@@ -537,7 +537,8 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component | |
private static boolean isTableDecorationSupported() { | |
return UIUtil.isUnderNativeMacLookAndFeel() | |
|| UIUtil.isUnderDarcula() | |
- || UIUtil.isUnderIntelliJLaF(); | |
+ || UIUtil.isUnderIntelliJLaF() | |
+ || UIUtil.isUnderWindowsLookAndFeel(); | |
} | |
@NotNull | |
@@ -545,6 +546,11 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component | |
public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) { | |
Component result = super.prepareRenderer(renderer, row, column); | |
+ // Fix GTK background | |
+ if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ UIUtil.changeBackGround(this, UIUtil.getTreeTextBackground()); | |
+ } | |
+ | |
if (isTableDecorationSupported() && isStriped() && result instanceof JComponent) { | |
final Color bg = row % 2 == 1 ? getBackground() : UIUtil.getDecoratedRowColor(); | |
final JComponent c = (JComponent)result; | |
diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java | |
index cc8217246067..7119223fa69f 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java | |
+++ b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java | |
@@ -86,7 +86,7 @@ public class SimpleTree extends Tree implements CellEditorListener { | |
setUI(new BasicTreeUI()); // In WindowsXP UI handles are not shown :( | |
} | |
- setOpaque(false); | |
+ setOpaque(UIUtil.isUnderGTKLookAndFeel()); | |
} | |
public SimpleTree(TreeModel aModel) { | |
diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java | |
index 995d2e6a1a62..26cd776fa018 100644 | |
--- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java | |
+++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java | |
@@ -119,7 +119,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith | |
public void setUI(TreeUI ui) { | |
TreeUI actualUI = ui; | |
if (!isCustomUI()) { | |
- if (!(ui instanceof WideSelectionTreeUI) && isWideSelection()) { | |
+ if (!(ui instanceof WideSelectionTreeUI) && isWideSelection() && !UIUtil.isUnderGTKLookAndFeel()) { | |
actualUI = new WideSelectionTreeUI(isWideSelection(), getWideSelectionBackgroundCondition()); | |
} | |
} | |
@@ -406,6 +406,21 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith | |
true, MouseEvent.BUTTON3); | |
} | |
} | |
+ else if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ if (SwingUtilities.isLeftMouseButton(e) && (e.getID() == MouseEvent.MOUSE_PRESSED || e.getID() == MouseEvent.MOUSE_CLICKED)) { | |
+ TreePath path = getClosestPathForLocation(e.getX(), e.getY()); | |
+ if (path != null) { | |
+ Rectangle bounds = getPathBounds(path); | |
+ if (bounds != null && | |
+ e.getY() > bounds.y && e.getY() < bounds.y + bounds.height && | |
+ (e.getX() >= bounds.x + bounds.width || | |
+ e.getX() < bounds.x && !isLocationInExpandControl(path, e.getX(), e.getY()))) { | |
+ int newX = bounds.x + bounds.width - 2; | |
+ e2 = MouseEventAdapter.convert(e, e.getComponent(), newX, e.getY()); | |
+ } | |
+ } | |
+ } | |
+ } | |
super.processMouseEvent(e2); | |
} | |
diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java | |
index 3b45967e8b5b..31a250f0d515 100644 | |
--- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java | |
+++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java | |
@@ -61,8 +61,8 @@ import java.awt.event.*; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Method; | |
-import java.util.List; | |
import java.util.*; | |
+import java.util.List; | |
import java.util.concurrent.ConcurrentLinkedQueue; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
@@ -738,8 +738,22 @@ public class IdeEventQueue extends EventQueue { | |
} | |
private static void fixStickyAlt(@NotNull AWTEvent e) { | |
- if (!Registry.is("actionSystem.win.suppressAlt.new") && | |
- SystemInfo.isWinXpOrNewer && !SystemInfo.isWinVistaOrNewer && e instanceof KeyEvent && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ALT) { | |
+ if (Registry.is("actionSystem.win.suppressAlt.new")) { | |
+ if (UIUtil.isUnderWindowsLookAndFeel() && | |
+ e instanceof InputEvent && | |
+ (((InputEvent)e).getModifiers() & (InputEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)) != 0 && | |
+ !(e instanceof KeyEvent && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ALT)) { | |
+ try { | |
+ if (FieldHolder.ourStickyAltField != null) { | |
+ FieldHolder.ourStickyAltField.set(null, true); | |
+ } | |
+ } | |
+ catch (Exception exception) { | |
+ LOG.error(exception); | |
+ } | |
+ } | |
+ } | |
+ else if (SystemInfo.isWinXpOrNewer && !SystemInfo.isWinVistaOrNewer && e instanceof KeyEvent && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ALT) { | |
((KeyEvent)e).consume(); // IDEA-17359 | |
} | |
} | |
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java | |
index 1408e8026c5d..4e250fec5dad 100644 | |
--- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java | |
+++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java | |
@@ -61,6 +61,7 @@ public class CustomizeUIThemeStepPanel extends AbstractCustomizeWizardStep { | |
protected static final ThemeInfo AQUA = new ThemeInfo("Aqua", "Aqua", "com.apple.laf.AquaLookAndFeel"); | |
protected static final ThemeInfo DARCULA = new ThemeInfo("Darcula", "Darcula", DarculaLaf.class.getName()); | |
protected static final ThemeInfo INTELLIJ = new ThemeInfo("Light", "IntelliJ", IntelliJLaf.class.getName()); | |
+ protected static final ThemeInfo GTK = new ThemeInfo("GTK+", "GTK", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); | |
private final boolean myColumnMode; | |
private final JLabel myPreviewLabel; | |
@@ -126,6 +127,7 @@ public class CustomizeUIThemeStepPanel extends AbstractCustomizeWizardStep { | |
else { | |
result.add(DARCULA); | |
result.add(INTELLIJ); | |
+ result.add(GTK); | |
} | |
} | |
@@ -139,6 +141,7 @@ public class CustomizeUIThemeStepPanel extends AbstractCustomizeWizardStep { | |
if (ApplicationManager.getApplication() != null) { | |
if (UIUtil.isUnderAquaLookAndFeel()) return AQUA; | |
if (UIUtil.isUnderDarcula()) return DARCULA; | |
+ if (UIUtil.isUnderGTKLookAndFeel()) return GTK; | |
return INTELLIJ; | |
} | |
CloudConfigProvider provider = CloudConfigProvider.getProvider(); | |
diff --git a/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeEditor.java b/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeEditor.java | |
index 432e281a9496..d52c888f6095 100644 | |
--- a/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeEditor.java | |
+++ b/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeEditor.java | |
@@ -154,7 +154,8 @@ public class NewErrorTreeEditor extends AbstractCellEditor implements TreeCellEd | |
myPanel.setForeground(tree.getForeground()); | |
} | |
- if (WideSelectionTreeUI.isWideSelection(tree)) { | |
+ if (UIUtil.isUnderGTKLookAndFeel() || | |
+ WideSelectionTreeUI.isWideSelection(tree)) { | |
myPanel.setOpaque(false); | |
} | |
return myPanel; | |
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java | |
index cc96b9f13e3e..6153d2d04c20 100644 | |
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java | |
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java | |
@@ -57,6 +57,15 @@ public class IntelliJLaf extends DarculaLaf { | |
} | |
}, myDisposable); | |
+ if (UIUtil.isUnderWindowsLookAndFeel()) { | |
+ try { | |
+ final String name = UIManager.getSystemLookAndFeelClassName(); | |
+ return (BasicLookAndFeel)Class.forName(name).newInstance(); | |
+ } | |
+ catch (Exception e) { | |
+ log(e); | |
+ } | |
+ } | |
return super.createBaseLookAndFeel(); | |
} | |
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java | |
index 6256984a6b42..529c0d7150ce 100644 | |
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java | |
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java | |
@@ -16,9 +16,11 @@ import com.intellij.openapi.Disposable; | |
import com.intellij.openapi.components.*; | |
import com.intellij.openapi.diagnostic.Logger; | |
import com.intellij.openapi.ui.DialogWrapper; | |
+import com.intellij.openapi.ui.JBPopupMenu; | |
import com.intellij.openapi.ui.Messages; | |
import com.intellij.openapi.ui.popup.util.PopupUtil; | |
import com.intellij.openapi.util.Comparing; | |
+import com.intellij.openapi.util.Disposer; | |
import com.intellij.openapi.util.IconLoader; | |
import com.intellij.openapi.util.SystemInfo; | |
import com.intellij.openapi.util.registry.Registry; | |
@@ -27,10 +29,7 @@ import com.intellij.ui.ScreenUtil; | |
import com.intellij.ui.components.BasicOptionButtonUI; | |
import com.intellij.ui.mac.MacPopupMenuUI; | |
import com.intellij.ui.popup.OurHeavyWeightPopup; | |
-import com.intellij.util.EventDispatcher; | |
-import com.intellij.util.IJSwingUtilities; | |
-import com.intellij.util.IconUtil; | |
-import com.intellij.util.ObjectUtils; | |
+import com.intellij.util.*; | |
import com.intellij.util.containers.ContainerUtil; | |
import com.intellij.util.ui.JBInsets; | |
import com.intellij.util.ui.JBUI; | |
@@ -48,12 +47,19 @@ import javax.swing.plaf.FontUIResource; | |
import javax.swing.plaf.UIResource; | |
import javax.swing.plaf.metal.DefaultMetalTheme; | |
import javax.swing.plaf.metal.MetalLookAndFeel; | |
+import javax.swing.plaf.synth.Region; | |
+import javax.swing.plaf.synth.SynthLookAndFeel; | |
+import javax.swing.plaf.synth.SynthStyle; | |
+import javax.swing.plaf.synth.SynthStyleFactory; | |
import javax.swing.text.DefaultEditorKit; | |
import java.awt.*; | |
import java.awt.event.InputEvent; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
+import java.beans.PropertyChangeEvent; | |
+import java.beans.PropertyChangeListener; | |
+import java.lang.reflect.Method; | |
import java.util.List; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
@@ -117,9 +123,9 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
if (!"Metal".equalsIgnoreCase(name) | |
&& !"CDE/Motif".equalsIgnoreCase(name) | |
&& !"Nimbus".equalsIgnoreCase(name) | |
- && !name.startsWith("Windows") | |
- && !"GTK+".equalsIgnoreCase(name) | |
- && !name.startsWith("JGoodies")) { | |
+ && !"Windows Classic".equalsIgnoreCase(name) | |
+ && !name.startsWith("JGoodies") | |
+ && !("Windows".equalsIgnoreCase(name) && SystemInfo.isWin8OrNewer)) { | |
lafList.add(laf); | |
} | |
} | |
@@ -180,6 +186,26 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
} | |
updateUI(); | |
+ | |
+ if (SystemInfo.isXWindow) { | |
+ PropertyChangeListener themeChangeListener = new PropertyChangeListener() { | |
+ @Override | |
+ public void propertyChange(final PropertyChangeEvent evt) { | |
+ //noinspection SSBasedInspection | |
+ SwingUtilities.invokeLater(() -> { | |
+ fixGtkPopupStyle(); | |
+ patchGtkDefaults(UIManager.getLookAndFeelDefaults()); | |
+ }); | |
+ } | |
+ }; | |
+ Toolkit.getDefaultToolkit().addPropertyChangeListener(GNOME_THEME_PROPERTY_NAME, themeChangeListener); | |
+ Disposer.register(this, new Disposable() { | |
+ @Override | |
+ public void dispose() { | |
+ Toolkit.getDefaultToolkit().removePropertyChangeListener(GNOME_THEME_PROPERTY_NAME, themeChangeListener); | |
+ } | |
+ }); | |
+ } | |
} | |
public void updateWizardLAF(boolean wasUnderDarcula) { | |
@@ -432,11 +458,16 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
fixPopupWeight(); | |
+ fixGtkPopupStyle(); | |
+ | |
fixMenuIssues(uiDefaults); | |
if (UIUtil.isUnderAquaLookAndFeel()) { | |
uiDefaults.put("Panel.opaque", Boolean.TRUE); | |
} | |
+ else if (UIUtil.isWinLafOnVista()) { | |
+ uiDefaults.put("ComboBox.border", null); | |
+ } | |
initInputMapDefaults(uiDefaults); | |
@@ -449,6 +480,8 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
patchHiDPI(uiDefaults); | |
+ patchGtkDefaults(uiDefaults); | |
+ | |
fixSeparatorColor(uiDefaults); | |
fixProgressBar(uiDefaults); | |
@@ -636,6 +669,32 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
PopupUtil.setPopupType(factory, popupWeight); | |
} | |
+ private static void fixGtkPopupStyle() { | |
+ if (!UIUtil.isUnderGTKLookAndFeel()) return; | |
+ | |
+ final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory(); | |
+ | |
+ SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() { | |
+ @Override | |
+ public SynthStyle getStyle(final JComponent c, final Region id) { | |
+ final SynthStyle style = original.getStyle(c, id); | |
+ if (id == Region.POPUP_MENU) { | |
+ final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness"); | |
+ if (x != null && x == 0) { | |
+ // workaround for Sun bug #6636964 | |
+ ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1); | |
+ ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3); | |
+ } | |
+ } | |
+ return style; | |
+ } | |
+ }); | |
+ | |
+ new JBPopupMenu(); // invokes updateUI() -> updateStyle() | |
+ | |
+ SynthLookAndFeel.setStyleFactory(original); | |
+ } | |
+ | |
private static void patchFileChooserStrings(final UIDefaults defaults) { | |
if (!defaults.containsKey(ourFileChooserTextKeys[0])) { | |
// Alloy L&F does not define strings for names of context menu actions, so we have to patch them in here | |
@@ -645,6 +704,28 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
} | |
} | |
+ private static void patchGtkDefaults(UIDefaults defaults) { | |
+ if (!UIUtil.isUnderGTKLookAndFeel()) return; | |
+ | |
+ Map<String, Icon> map = ContainerUtil.newHashMap( | |
+ Arrays.asList("OptionPane.errorIcon", "OptionPane.informationIcon", "OptionPane.warningIcon", "OptionPane.questionIcon"), | |
+ Arrays.asList(AllIcons.General.ErrorDialog, AllIcons.General.InformationDialog, AllIcons.General.WarningDialog, AllIcons.General.QuestionDialog)); | |
+ // GTK+ L&F keeps icons hidden in style | |
+ SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON); | |
+ for (String key : map.keySet()) { | |
+ if (defaults.get(key) != null) continue; | |
+ | |
+ Object icon = style == null ? null : style.get(null, key); | |
+ defaults.put(key, icon instanceof Icon ? icon : map.get(key)); | |
+ } | |
+ | |
+ Color fg = defaults.getColor("Label.foreground"); | |
+ Color bg = defaults.getColor("Label.background"); | |
+ if (fg != null && bg != null) { | |
+ defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5)); | |
+ } | |
+ } | |
+ | |
private void patchLafFonts(UIDefaults uiDefaults) { | |
//if (JBUI.isHiDPI()) { | |
// HashMap<Object, Font> newFonts = new HashMap<Object, Font>(); | |
@@ -799,7 +880,7 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
public Popup getPopup(final Component owner, final Component contents, final int x, final int y) { | |
final Point point = fixPopupLocation(contents, x, y); | |
- final int popupType = PopupUtil.getPopupType(this); | |
+ final int popupType = UIUtil.isUnderGTKLookAndFeel() ? WEIGHT_HEAVY : PopupUtil.getPopupType(this); | |
if (popupType == WEIGHT_HEAVY && OurHeavyWeightPopup.isEnabled()) { | |
return new OurHeavyWeightPopup(owner, contents, point.x, point.y); | |
} | |
@@ -837,6 +918,7 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
} | |
}); | |
} | |
+ fixPopupSize(popup, contents); | |
return popup; | |
} | |
@@ -869,6 +951,24 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC | |
return rec.getLocation(); | |
} | |
+ | |
+ private static void fixPopupSize(final Popup popup, final Component contents) { | |
+ if (!UIUtil.isUnderGTKLookAndFeel() || !(contents instanceof JPopupMenu)) return; | |
+ | |
+ for (Class<?> aClass = popup.getClass(); aClass != null && Popup.class.isAssignableFrom(aClass); aClass = aClass.getSuperclass()) { | |
+ try { | |
+ final Method getComponent = aClass.getDeclaredMethod("getComponent"); | |
+ getComponent.setAccessible(true); | |
+ final Object component = getComponent.invoke(popup); | |
+ if (component instanceof JWindow) { | |
+ ((JWindow)component).setSize(new Dimension(0, 0)); | |
+ } | |
+ break; | |
+ } | |
+ catch (Exception ignored) { | |
+ } | |
+ } | |
+ } | |
} | |
private abstract static class MenuArrowIcon implements Icon, UIResource { | |
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java | |
index 4b84ffdb3c83..4913ddee0d99 100644 | |
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java | |
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java | |
@@ -31,6 +31,7 @@ import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.*; | |
/** | |
* @author Konstantin Bulenkov | |
*/ | |
+@SuppressWarnings("GtkPreferredJComboBoxRenderer") | |
public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorBorderCapable { | |
private static final Color NON_EDITABLE_BACKGROUND = JBColor.namedColor("ComboBox.darcula.nonEditableBackground", new JBColor(0xfcfcfc, 0x3c3f41)); | |
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java | |
index b78624d37fd8..81ecda081649 100644 | |
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java | |
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java | |
@@ -19,14 +19,18 @@ import com.intellij.openapi.wm.StatusBar; | |
import com.intellij.ui.components.JBMenu; | |
import com.intellij.ui.mac.foundation.NSDefaults; | |
import com.intellij.ui.plaf.beg.IdeaMenuUI; | |
+import com.intellij.ui.plaf.gtk.GtkMenuUI; | |
import com.intellij.util.ReflectionUtil; | |
import com.intellij.util.SingleAlarm; | |
+import com.intellij.util.ui.JBUI; | |
import com.intellij.util.ui.UIUtil; | |
import org.jetbrains.annotations.NotNull; | |
import javax.swing.*; | |
import javax.swing.event.MenuEvent; | |
import javax.swing.event.MenuListener; | |
+import javax.swing.plaf.MenuItemUI; | |
+import javax.swing.plaf.synth.SynthMenuUI; | |
import java.awt.*; | |
import java.awt.event.AWTEventListener; | |
import java.awt.event.ComponentEvent; | |
@@ -44,6 +48,7 @@ public final class ActionMenu extends JBMenu { | |
private boolean myMnemonicEnabled; | |
private MenuItemSynchronizer myMenuItemSynchronizer; | |
private StubItem myStubItem; // A PATCH!!! Do not remove this code, otherwise you will lose all keyboard navigation in JMenuBar. | |
+ private final boolean myTopLevel; | |
private final boolean myUseDarkIcons; | |
private Disposable myDisposable; | |
@@ -52,6 +57,7 @@ public final class ActionMenu extends JBMenu { | |
final ActionGroup group, | |
final PresentationFactory presentationFactory, | |
final boolean enableMnemonics, | |
+ final boolean topLevel, | |
final boolean useDarkIcons | |
) { | |
myContext = context; | |
@@ -60,6 +66,7 @@ public final class ActionMenu extends JBMenu { | |
myPresentationFactory = presentationFactory; | |
myPresentation = myPresentationFactory.getPresentation(group); | |
myMnemonicEnabled = enableMnemonics; | |
+ myTopLevel = topLevel; | |
myUseDarkIcons = useDarkIcons; | |
updateUI(); | |
@@ -128,13 +135,47 @@ public final class ActionMenu extends JBMenu { | |
@Override | |
public void updateUI() { | |
- setUI(IdeaMenuUI.createUI(this)); | |
- setFont(UIUtil.getMenuFont()); | |
+ boolean isAmbiance = UIUtil.isUnderGTKLookAndFeel() && "Ambiance".equalsIgnoreCase(UIUtil.getGtkThemeName()); | |
+ if (myTopLevel && !isAmbiance && UIUtil.GTK_AMBIANCE_TEXT_COLOR.equals(getForeground())) { | |
+ setForeground(null); | |
+ } | |
+ | |
+ if (UIUtil.isStandardMenuLAF()) { | |
+ super.updateUI(); | |
+ } | |
+ else { | |
+ setUI(IdeaMenuUI.createUI(this)); | |
+ setFont(UIUtil.getMenuFont()); | |
- JPopupMenu popupMenu = getPopupMenu(); | |
- if (popupMenu != null) { | |
- popupMenu.updateUI(); | |
+ JPopupMenu popupMenu = getPopupMenu(); | |
+ if (popupMenu != null) { | |
+ popupMenu.updateUI(); | |
+ } | |
+ } | |
+ | |
+ if (myTopLevel && isAmbiance) { | |
+ setForeground(UIUtil.GTK_AMBIANCE_TEXT_COLOR); | |
} | |
+ | |
+ if (myTopLevel && UIUtil.isUnderGTKLookAndFeel()) { | |
+ Insets insets = getInsets(); | |
+ @SuppressWarnings("UseDPIAwareInsets") Insets newInsets = new Insets(insets.top, insets.left, insets.bottom, insets.right); | |
+ if (insets.top + insets.bottom < JBUI.scale(6)) { | |
+ newInsets.top = newInsets.bottom = JBUI.scale(3); | |
+ } | |
+ if (insets.left + insets.right < JBUI.scale(12)) { | |
+ newInsets.left = newInsets.right = JBUI.scale(6); | |
+ } | |
+ if (!newInsets.equals(insets)) { | |
+ setBorder(BorderFactory.createEmptyBorder(newInsets.top, newInsets.left, newInsets.bottom, newInsets.right)); | |
+ } | |
+ } | |
+ } | |
+ | |
+ @Override | |
+ public void setUI(MenuItemUI ui) { | |
+ MenuItemUI newUi = !myTopLevel && UIUtil.isUnderGTKLookAndFeel() && ui instanceof SynthMenuUI ? new GtkMenuUI((SynthMenuUI)ui) : ui; | |
+ super.setUI(newUi); | |
} | |
private void init() { | |
@@ -276,7 +317,7 @@ public final class ActionMenu extends JBMenu { | |
mayContextBeInvalid = true; | |
} | |
- final boolean isDarkMenu = SystemInfo.isMacSystemMenu && NSDefaults.isDarkMenuBar(); | |
+ final boolean isDarkMenu = SystemInfo.isMacSystemMenu ? NSDefaults.isDarkMenuBar() : false; | |
Utils.fillMenu(myGroup.getAction(), this, myMnemonicEnabled, myPresentationFactory, context, myPlace, true, mayContextBeInvalid, LaterInvocator.isInModalContext(), isDarkMenu); | |
} | |
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java | |
index e64666e89c0d..2e7c7e388290 100644 | |
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java | |
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java | |
@@ -16,9 +16,11 @@ import com.intellij.openapi.util.ActionCallback; | |
import com.intellij.openapi.util.Disposer; | |
import com.intellij.openapi.util.IconLoader; | |
import com.intellij.openapi.util.SystemInfo; | |
+import com.intellij.openapi.util.registry.Registry; | |
import com.intellij.openapi.wm.IdeFocusManager; | |
import com.intellij.ui.components.JBCheckBoxMenuItem; | |
import com.intellij.ui.plaf.beg.BegMenuItemUI; | |
+import com.intellij.ui.plaf.gtk.GtkMenuItemUI; | |
import com.intellij.util.ui.EmptyIcon; | |
import com.intellij.util.ui.LafIconLookup; | |
import com.intellij.util.ui.UIUtil; | |
@@ -26,6 +28,8 @@ import org.jetbrains.annotations.NonNls; | |
import org.jetbrains.annotations.NotNull; | |
import javax.swing.*; | |
+import javax.swing.plaf.MenuItemUI; | |
+import javax.swing.plaf.synth.SynthMenuItemUI; | |
import java.awt.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
@@ -155,8 +159,10 @@ public class ActionMenuItem extends JBCheckBoxMenuItem { | |
setAcceleratorFromShortcuts(getActiveKeymapShortcuts(id).getShortcuts()); | |
} | |
else { | |
- ShortcutSet shortcutSet = action.getShortcutSet(); | |
- setAcceleratorFromShortcuts(shortcutSet.getShortcuts()); | |
+ final ShortcutSet shortcutSet = action.getShortcutSet(); | |
+ if (shortcutSet != null) { | |
+ setAcceleratorFromShortcuts(shortcutSet.getShortcuts()); | |
+ } | |
} | |
} | |
@@ -175,7 +181,18 @@ public class ActionMenuItem extends JBCheckBoxMenuItem { | |
@Override | |
public void updateUI() { | |
- setUI(BegMenuItemUI.createUI(this)); | |
+ if (UIUtil.isStandardMenuLAF()) { | |
+ super.updateUI(); | |
+ } | |
+ else { | |
+ setUI(BegMenuItemUI.createUI(this)); | |
+ } | |
+ } | |
+ | |
+ @Override | |
+ public void setUI(MenuItemUI ui) { | |
+ MenuItemUI newUi = UIUtil.isUnderGTKLookAndFeel() && ui instanceof SynthMenuItemUI ? new GtkMenuItemUI((SynthMenuItemUI)ui) : ui; | |
+ super.setUI(newUi); | |
} | |
/** | |
@@ -200,10 +217,11 @@ public class ActionMenuItem extends JBCheckBoxMenuItem { | |
if (isToggleable() && (myPresentation.getIcon() == null || myInsideCheckedGroup || !UISettings.getInstance().getShowIconsInMenus())) { | |
action.update(myEvent); | |
myToggled = Boolean.TRUE.equals(myEvent.getPresentation().getClientProperty(Toggleable.SELECTED_PROPERTY)); | |
- if (ActionPlaces.MAIN_MENU.equals(myPlace) && SystemInfo.isMacSystemMenu) { | |
+ if (ActionPlaces.MAIN_MENU.equals(myPlace) && SystemInfo.isMacSystemMenu || | |
+ UIUtil.isUnderWindowsLookAndFeel() && SystemInfo.isWin7OrNewer) { | |
setState(myToggled); | |
} | |
- else { | |
+ else if (!(getUI() instanceof GtkMenuItemUI)) { | |
if (myToggled) { | |
setIcon(LafIconLookup.getIcon("checkmark")); | |
setSelectedIcon(LafIconLookup.getSelectedIcon("checkmark")); | |
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java | |
index 62cfff563a95..02593ed9ad1f 100644 | |
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java | |
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java | |
@@ -306,6 +306,14 @@ public class Utils{ | |
if (!StringUtil.isEmpty(text) || (i > 0 && i < size - 1)) { | |
component.add(new JPopupMenu.Separator() { | |
private final JMenuItem myMenu = !StringUtil.isEmpty(text) ? new JMenuItem(text) : null; | |
+ @Override | |
+ public Insets getInsets() { | |
+ final Insets insets = super.getInsets(); | |
+ final boolean fix = UIUtil.isUnderGTKLookAndFeel() && | |
+ getBorder() != null && | |
+ insets.top + insets.bottom == 0; | |
+ return fix ? new Insets(2, insets.left, 3, insets.right) : insets; // workaround for Sun bug #6636964 | |
+ } | |
@Override | |
public void doLayout() { | |
@@ -317,7 +325,8 @@ public class Utils{ | |
@Override | |
protected void paintComponent(Graphics g) { | |
- if (UIUtil.isUnderDarcula() || UIUtil.isUnderWin10LookAndFeel()) { | |
+ if (UIUtil.isUnderWindowsClassicLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderWindowsLookAndFeel() | |
+ || UIUtil.isUnderWin10LookAndFeel()) { | |
g.setColor(component.getBackground()); | |
g.fillRect(0, 0, getWidth(), getHeight()); | |
} | |
@@ -346,7 +355,7 @@ public class Utils{ | |
else if (action instanceof ActionGroup && | |
!(((ActionGroup)action).canBePerformed(context) && | |
!hasVisibleChildren((ActionGroup)action, presentationFactory, context, place))) { | |
- ActionMenu menu = new ActionMenu(context, place, (ActionGroup)action, presentationFactory, enableMnemonics, useDarkIcons); | |
+ ActionMenu menu = new ActionMenu(context, place, (ActionGroup)action, presentationFactory, enableMnemonics, false, useDarkIcons); | |
component.add(menu); | |
children.add(menu); | |
} | |
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ContentChooser.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ContentChooser.java | |
index 9c930d0c341b..f78262b1a36a 100644 | |
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ContentChooser.java | |
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ContentChooser.java | |
@@ -338,7 +338,11 @@ public abstract class ContentChooser<Data> extends DialogWrapper { | |
String prefix = indexString + new String(spaces) + " "; | |
append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES, false); | |
} | |
- | |
+ else if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ // Fix GTK background | |
+ Color background = selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground(); | |
+ UIUtil.changeBackGround(this, background); | |
+ } | |
String text = value.getShortText(previewChars); | |
append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES, true); | |
SpeedSearchUtil.applySpeedSearchHighlighting(list, this, true, selected); | |
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java | |
index a8a0df29c590..305bbfc3f348 100644 | |
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java | |
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java | |
@@ -329,9 +329,9 @@ public class IdeMenuBar extends JMenuBar implements IdeEventQueue.EventDispatche | |
removeAll(); | |
final boolean enableMnemonics = !UISettings.getInstance().getDisableMnemonics(); | |
- final boolean isDarkMenu = SystemInfo.isMacSystemMenu && NSDefaults.isDarkMenuBar(); | |
+ final boolean isDarkMenu = SystemInfo.isMacSystemMenu ? NSDefaults.isDarkMenuBar() : false; | |
for (final AnAction action : myVisibleActions) { | |
- add(new ActionMenu(null, ActionPlaces.MAIN_MENU, (ActionGroup)action, myPresentationFactory, enableMnemonics, isDarkMenu)); | |
+ add(new ActionMenu(null, ActionPlaces.MAIN_MENU, (ActionGroup)action, myPresentationFactory, enableMnemonics, true, isDarkMenu)); | |
} | |
updateMnemonicsVisibility(); | |
@@ -448,6 +448,9 @@ public class IdeMenuBar extends JMenuBar implements IdeEventQueue.EventDispatche | |
} | |
updateMenuActions(); | |
+ if (UIUtil.isWinLafOnVista()) { | |
+ repaint(); | |
+ } | |
} | |
} | |
diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuItemUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuItemUI.java | |
new file mode 100644 | |
index 000000000000..e47797729099 | |
--- /dev/null | |
+++ b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuItemUI.java | |
@@ -0,0 +1,103 @@ | |
+/* | |
+ * Copyright 2000-2016 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. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed on an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+package com.intellij.ui.plaf.gtk; | |
+ | |
+import com.intellij.openapi.actionSystem.impl.ActionMenuItem; | |
+import com.intellij.util.ui.EmptyIcon; | |
+import com.intellij.util.ui.UIUtil; | |
+ | |
+import javax.swing.*; | |
+import javax.swing.plaf.basic.BasicMenuItemUI; | |
+import javax.swing.plaf.synth.ColorType; | |
+import javax.swing.plaf.synth.SynthContext; | |
+import javax.swing.plaf.synth.SynthMenuItemUI; | |
+import java.awt.*; | |
+ | |
+public class GtkMenuItemUI extends BasicMenuItemUI { | |
+ private static Icon myCachedCheckIcon = null; | |
+ | |
+ private final SynthMenuItemUI myOriginalUI; | |
+ private JCheckBoxMenuItem myHiddenItem; | |
+ | |
+ public GtkMenuItemUI(SynthMenuItemUI originalUI) { | |
+ myOriginalUI = originalUI; | |
+ } | |
+ | |
+ @Override | |
+ public void installUI(final JComponent c) { | |
+ super.installUI(c); | |
+ | |
+ myHiddenItem = new JCheckBoxMenuItem(); | |
+ myOriginalUI.installUI(myHiddenItem); | |
+ menuItem.setBorder(myHiddenItem.getBorder()); | |
+ final Icon icon = getCheckIconFromContext(myOriginalUI, myHiddenItem); | |
+ checkIcon = isCheckBoxItem() ? icon : EmptyIcon.create(icon); | |
+ } | |
+ | |
+ @Override | |
+ public void uninstallUI(final JComponent c) { | |
+ super.uninstallUI(c); | |
+ | |
+ myOriginalUI.uninstallUI(myHiddenItem); | |
+ myHiddenItem = null; | |
+ resetCachedCheckIcon(); | |
+ } | |
+ | |
+ private static Icon getCheckIconFromContext(final SynthMenuItemUI ui, final JCheckBoxMenuItem item) { | |
+ if (myCachedCheckIcon == null) { | |
+ SynthContext context = ui.getContext(item); | |
+ myCachedCheckIcon = context.getStyle().getIcon(context, "CheckBoxMenuItem.checkIcon"); | |
+ } | |
+ return myCachedCheckIcon; | |
+ } | |
+ | |
+ private boolean isCheckBoxItem() { | |
+ return menuItem instanceof ActionMenuItem && ((ActionMenuItem)menuItem).isToggleable(); | |
+ } | |
+ | |
+ private static void resetCachedCheckIcon() { | |
+ myCachedCheckIcon = null; | |
+ } | |
+ | |
+ @Override | |
+ public void update(final Graphics g, final JComponent c) { | |
+ myHiddenItem.setSelected(menuItem.isSelected()); | |
+ | |
+ if (UIUtil.isMurrineBasedTheme()) { | |
+ acceleratorFont = menuItem.getFont(); | |
+ SynthContext context = myOriginalUI.getContext(menuItem); | |
+ Color fg = context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND); | |
+ acceleratorForeground = UIUtil.mix(fg, menuItem.getBackground(), menuItem.isSelected() ? 0.4 : 0.2); | |
+ disabledForeground = fg; | |
+ } | |
+ | |
+ if (checkIcon != null && !(checkIcon instanceof IconWrapper) && !(checkIcon instanceof EmptyIcon)) { | |
+ checkIcon = new IconWrapper(checkIcon, myOriginalUI); | |
+ } | |
+ | |
+ super.update(g, c); | |
+ } | |
+ | |
+ @Override | |
+ protected void paintText(final Graphics g, final JMenuItem menuItem, final Rectangle textRect, final String text) { | |
+ if (!menuItem.isEnabled() && UIUtil.isMurrineBasedTheme()) { | |
+ GtkPaintingUtil.paintDisabledText(myOriginalUI, g, menuItem, textRect, text); | |
+ } | |
+ else { | |
+ super.paintText(g, menuItem, textRect, text); | |
+ } | |
+ } | |
+} | |
\ No newline at end of file | |
diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuUI.java | |
new file mode 100644 | |
index 000000000000..d2f887d3e0f3 | |
--- /dev/null | |
+++ b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuUI.java | |
@@ -0,0 +1,58 @@ | |
+/* | |
+ * Copyright 2000-2016 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. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed on an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+package com.intellij.ui.plaf.gtk; | |
+ | |
+import com.intellij.util.ui.UIUtil; | |
+ | |
+import javax.swing.*; | |
+import javax.swing.plaf.basic.BasicMenuUI; | |
+import javax.swing.plaf.synth.SynthMenuUI; | |
+import java.awt.*; | |
+ | |
+public class GtkMenuUI extends BasicMenuUI { | |
+ private final SynthMenuUI myOriginalUI; | |
+ | |
+ public GtkMenuUI(SynthMenuUI originalUI) { | |
+ myOriginalUI = originalUI; | |
+ } | |
+ | |
+ @Override | |
+ public void installUI(final JComponent c) { | |
+ super.installUI(c); | |
+ | |
+ final JMenu temp = new JMenu(); | |
+ myOriginalUI.installUI(temp); | |
+ menuItem.setBorder(temp.getBorder()); | |
+ } | |
+ | |
+ @Override | |
+ public void update(final Graphics g, final JComponent c) { | |
+ if (arrowIcon != null && !(arrowIcon instanceof IconWrapper)) { | |
+ arrowIcon = new IconWrapper(arrowIcon, myOriginalUI); | |
+ } | |
+ super.update(g, c); | |
+ } | |
+ | |
+ @Override | |
+ protected void paintText(final Graphics g, final JMenuItem menuItem, final Rectangle textRect, final String text) { | |
+ if (!menuItem.isEnabled() && UIUtil.isMurrineBasedTheme()) { | |
+ GtkPaintingUtil.paintDisabledText(myOriginalUI, g, menuItem, textRect, text); | |
+ } | |
+ else { | |
+ super.paintText(g, menuItem, textRect, text); | |
+ } | |
+ } | |
+} | |
\ No newline at end of file | |
diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkPaintingUtil.java b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkPaintingUtil.java | |
new file mode 100644 | |
index 000000000000..b5656f1671e8 | |
--- /dev/null | |
+++ b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkPaintingUtil.java | |
@@ -0,0 +1,52 @@ | |
+/* | |
+ * Copyright 2000-2016 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. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed on an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+package com.intellij.ui.plaf.gtk; | |
+ | |
+import com.intellij.util.ui.UIUtil; | |
+import sun.swing.SwingUtilities2; | |
+ | |
+import javax.swing.*; | |
+import javax.swing.plaf.MenuItemUI; | |
+import javax.swing.plaf.synth.ColorType; | |
+import javax.swing.plaf.synth.SynthContext; | |
+import javax.swing.plaf.synth.SynthUI; | |
+import java.awt.*; | |
+ | |
+public class GtkPaintingUtil { | |
+ private GtkPaintingUtil() { } | |
+ | |
+ public static void paintDisabledText(final SynthUI originalUI, | |
+ final Graphics g, | |
+ final JMenuItem menuItem, | |
+ final Rectangle textRect, | |
+ final String text) { | |
+ final FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); | |
+ final int index = menuItem.getDisplayedMnemonicIndex(); | |
+ | |
+ final SynthContext context = originalUI.getContext(menuItem); | |
+ final Color fg = context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND); | |
+ final Color shadow = UIUtil.shade(menuItem.getBackground(), 1.24, 0.5); | |
+ | |
+ g.setColor(shadow); | |
+ SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, index, textRect.x + 1, textRect.y + fm.getAscent() + 1); | |
+ g.setColor(fg); | |
+ SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, index, textRect.x, textRect.y + fm.getAscent()); | |
+ } | |
+ | |
+ public static SynthContext getSynthContext(final MenuItemUI ui, final JComponent item) { | |
+ return ((SynthUI)ui).getContext(item); | |
+ } | |
+} | |
\ No newline at end of file | |
diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/gtk/IconWrapper.java b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/IconWrapper.java | |
new file mode 100644 | |
index 000000000000..b36e950b2067 | |
--- /dev/null | |
+++ b/platform/platform-impl/src/com/intellij/ui/plaf/gtk/IconWrapper.java | |
@@ -0,0 +1,49 @@ | |
+/* | |
+ * Copyright 2000-2016 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. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed on an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+package com.intellij.ui.plaf.gtk; | |
+ | |
+import sun.swing.plaf.synth.SynthIcon; | |
+ | |
+import javax.swing.*; | |
+import javax.swing.plaf.synth.SynthContext; | |
+import javax.swing.plaf.synth.SynthUI; | |
+import java.awt.*; | |
+ | |
+class IconWrapper implements Icon { | |
+ private final Icon myIcon; | |
+ private final SynthUI myOriginalUI; | |
+ | |
+ IconWrapper(final Icon icon, final SynthUI originalUI) { | |
+ myIcon = icon; | |
+ myOriginalUI = originalUI; | |
+ } | |
+ | |
+ @Override | |
+ public void paintIcon(final Component c, final Graphics g, final int x, final int y) { | |
+ SynthContext context = myOriginalUI.getContext((JComponent)c); | |
+ ((SynthIcon)myIcon).paintIcon(context, g, x, y, getIconWidth(), getIconHeight()); | |
+ } | |
+ | |
+ @Override | |
+ public int getIconWidth() { | |
+ return myIcon.getIconWidth(); | |
+ } | |
+ | |
+ @Override | |
+ public int getIconHeight() { | |
+ return myIcon.getIconHeight(); | |
+ } | |
+} | |
\ No newline at end of file | |
diff --git a/platform/util/src/com/intellij/util/ui/JBUI.java b/platform/util/src/com/intellij/util/ui/JBUI.java | |
index c883369e3080..1a306f5f5844 100644 | |
--- a/platform/util/src/com/intellij/util/ui/JBUI.java | |
+++ b/platform/util/src/com/intellij/util/ui/JBUI.java | |
@@ -653,7 +653,7 @@ public class JBUI { | |
@NotNull | |
public static JBFont toolbarSmallComboBoxFont() { | |
- return label(11); | |
+ return UIUtil.isUnderGTKLookAndFeel() ? label() : label(11); | |
} | |
} | |
diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java | |
index 0f4c3efb23ab..e4b6c21dc7d2 100644 | |
--- a/platform/util/src/com/intellij/util/ui/UIUtil.java | |
+++ b/platform/util/src/com/intellij/util/ui/UIUtil.java | |
@@ -1275,7 +1275,8 @@ public class UIUtil { | |
} | |
public static Color getTableBackground() { | |
- return UIManager.getColor("Table.background"); | |
+ // Under GTK+ L&F "Table.background" often has main panel color, which looks ugly | |
+ return isUnderGTKLookAndFeel() ? getTreeTextBackground() : UIManager.getColor("Table.background"); | |
} | |
public static Color getTableBackground(final boolean isSelected) { | |
@@ -1299,7 +1300,8 @@ public class UIUtil { | |
} | |
public static Color getListBackground() { | |
- return UIManager.getColor("List.background"); | |
+ // Under GTK+ L&F "Table.background" often has main panel color, which looks ugly | |
+ return isUnderGTKLookAndFeel() ? getTreeTextBackground() : UIManager.getColor("List.background"); | |
} | |
public static Color getListBackground(boolean isSelected) { | |
@@ -1360,7 +1362,7 @@ public class UIUtil { | |
} | |
public static Color getTextFieldBackground() { | |
- return UIManager.getColor("TextField.background"); | |
+ return UIManager.getColor(isUnderGTKLookAndFeel() ? "EditorPane.background" : "TextField.background"); | |
} | |
public static Font getButtonFont() { | |
@@ -1416,7 +1418,7 @@ public class UIUtil { | |
} | |
public static Color getSeparatorColor() { | |
- return getSeparatorForeground(); | |
+ return isUnderGTKLookAndFeel() ? Gray._215 : getSeparatorForeground(); | |
} | |
public static Border getTableFocusCellHighlightBorder() { | |
@@ -1515,6 +1517,7 @@ public class UIUtil { | |
public static Icon getTreeSelectedCollapsedIcon() { | |
if (isUnderAquaBasedLookAndFeel() || | |
+ isUnderGTKLookAndFeel() || | |
isUnderDarcula() || | |
isUnderIntelliJLaF() && | |
!isUnderWin10LookAndFeel()) { | |
@@ -1525,6 +1528,7 @@ public class UIUtil { | |
public static Icon getTreeSelectedExpandedIcon() { | |
if (isUnderAquaBasedLookAndFeel() || | |
+ isUnderGTKLookAndFeel() || | |
isUnderDarcula() || | |
isUnderIntelliJLaF() && | |
!isUnderWin10LookAndFeel()) { | |
@@ -1571,13 +1575,11 @@ public class UIUtil { | |
return false; | |
} | |
- @Deprecated | |
@SuppressWarnings("HardCodedStringLiteral") | |
public static boolean isUnderWindowsLookAndFeel() { | |
return SystemInfo.isWindows && UIManager.getLookAndFeel().getName().equals("Windows"); | |
} | |
- @Deprecated | |
@SuppressWarnings("HardCodedStringLiteral") | |
public static boolean isUnderWindowsClassicLookAndFeel() { | |
return UIManager.getLookAndFeel().getName().equals("Windows Classic"); | |
@@ -1650,13 +1652,9 @@ public class UIUtil { | |
} | |
} | |
- @Deprecated | |
public static final Color GTK_AMBIANCE_TEXT_COLOR = new Color(223, 219, 210); | |
- | |
- @Deprecated | |
public static final Color GTK_AMBIANCE_BACKGROUND_COLOR = new Color(67, 66, 63); | |
- @Deprecated | |
@SuppressWarnings("HardCodedStringLiteral") | |
@Nullable | |
public static String getGtkThemeName() { | |
@@ -1681,7 +1679,6 @@ public class UIUtil { | |
return SystemInfo.isMac ? getLabelFont(UIUtil.FontSize.SMALL) : getLabelFont(); | |
} | |
- @Deprecated | |
@SuppressWarnings("HardCodedStringLiteral") | |
public static boolean isMurrineBasedTheme() { | |
final String gtkTheme = getGtkThemeName(); | |
@@ -1714,7 +1711,7 @@ public class UIUtil { | |
} | |
public static boolean isFullRowSelectionLAF() { | |
- return false; | |
+ return isUnderGTKLookAndFeel(); | |
} | |
public static boolean isUnderNativeMacLookAndFeel() { | |
@@ -2660,12 +2657,10 @@ public class UIUtil { | |
return builder.append("</style>").toString(); | |
} | |
- @Deprecated | |
public static boolean isWinLafOnVista() { | |
return SystemInfo.isWinVistaOrNewer && "Windows".equals(UIManager.getLookAndFeel().getName()); | |
} | |
- @Deprecated | |
public static boolean isStandardMenuLAF() { | |
return isWinLafOnVista() || | |
isUnderGTKLookAndFeel(); | |
@@ -3250,7 +3245,6 @@ public class UIUtil { | |
if (systemLaFClassName != null) { | |
return systemLaFClassName; | |
} | |
- | |
if (SystemInfo.isLinux) { | |
// Normally, GTK LaF is considered "system" when: | |
// 1) Gnome session is run | |
@@ -3269,7 +3263,6 @@ public class UIUtil { | |
catch (Exception ignore) { | |
} | |
} | |
- | |
return systemLaFClassName = UIManager.getSystemLookAndFeelClassName(); | |
} | |
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTree.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTree.java | |
index 73a93e4ca7a2..d9961ef1f8ce 100644 | |
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTree.java | |
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTree.java | |
@@ -27,6 +27,7 @@ import com.intellij.ui.DoubleClickListener; | |
import com.intellij.ui.PopupHandler; | |
import com.intellij.ui.SmartExpander; | |
import com.intellij.ui.TreeSpeedSearch; | |
+import com.intellij.ui.components.panels.NonOpaquePanel; | |
import com.intellij.ui.treeStructure.Tree; | |
import com.intellij.util.ObjectUtils; | |
import com.intellij.util.containers.ContainerUtil; | |
@@ -49,8 +50,8 @@ import javax.swing.tree.*; | |
import java.awt.*; | |
import java.awt.event.*; | |
import java.beans.PropertyChangeListener; | |
-import java.util.List; | |
import java.util.*; | |
+import java.util.List; | |
import static com.intellij.openapi.vcs.changes.ui.ChangesGroupingSupport.DIRECTORY_GROUPING; | |
import static com.intellij.openapi.vcs.changes.ui.ChangesGroupingSupport.MODULE_GROUPING; | |
@@ -575,9 +576,14 @@ public abstract class ChangesTree extends Tree implements DataProvider { | |
int row, | |
boolean hasFocus) { | |
- setBackground(null); | |
- myCheckBox.setBackground(null); | |
- myCheckBox.setOpaque(false); | |
+ if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ NonOpaquePanel.setTransparent(this); | |
+ NonOpaquePanel.setTransparent(myCheckBox); | |
+ } else { | |
+ setBackground(null); | |
+ myCheckBox.setBackground(null); | |
+ myCheckBox.setOpaque(false); | |
+ } | |
myTextRenderer.setOpaque(false); | |
myTextRenderer.setTransparentIconBackground(true); | |
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java | |
index ce982a92f2ce..aef04a8ec2ee 100644 | |
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java | |
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java | |
@@ -14,11 +14,13 @@ import com.intellij.ui.*; | |
import com.intellij.ui.components.JBList; | |
import com.intellij.ui.speedSearch.SpeedSearchUtil; | |
import com.intellij.util.Function; | |
+import com.intellij.util.ui.UIUtil; | |
import org.jetbrains.annotations.Nls; | |
import org.jetbrains.annotations.NotNull; | |
import org.jetbrains.annotations.Nullable; | |
import javax.swing.*; | |
+import java.awt.*; | |
import java.util.HashSet; | |
import java.util.Set; | |
@@ -181,6 +183,11 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl | |
private static class MyCellRenderer extends ColoredListCellRenderer<IgnoredFileBean> { | |
@Override | |
protected void customizeCellRenderer(@NotNull JList list, IgnoredFileBean bean, int index, boolean selected, boolean hasFocus) { | |
+ if (UIUtil.isUnderGTKLookAndFeel()) { | |
+ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); | |
+ UIUtil.changeBackGround(this, background); | |
+ } | |
+ | |
String text = getBeanTextPresentation(bean); | |
if (text != null) { | |
append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES); | |
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java | |
index e1d13c58acf5..4a95b1bdd683 100644 | |
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java | |
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java | |
@@ -19,6 +19,7 @@ import com.intellij.ui.SimpleTextAttributes; | |
import com.intellij.ui.popup.list.GroupedItemsListRenderer; | |
import com.intellij.util.containers.ContainerUtil; | |
import com.intellij.util.ui.TextTransferable; | |
+import com.intellij.util.ui.UIUtil; | |
import com.intellij.xdebugger.XDebuggerBundle; | |
import com.intellij.xdebugger.XSourcePosition; | |
import com.intellij.xdebugger.frame.XStackFrame; | |
@@ -201,6 +202,11 @@ public class XDebuggerFramesList extends DebuggerFramesList { | |
final int index, | |
final boolean selected, | |
final boolean hasFocus) { | |
+ // Fix GTK background | |
+ if (UIUtil.isUnderGTKLookAndFeel()){ | |
+ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); | |
+ UIUtil.changeBackGround(this, background); | |
+ } | |
if (value == null) { | |
append(XDebuggerBundle.message("stack.frame.loading.text"), SimpleTextAttributes.GRAY_ATTRIBUTES); | |
return; | |
-- | |
2.20.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment