From b16e74703813664fe145bd5e8aed39b20fc02e12 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 21 Jun 2012 12:29:51 +0200 Subject: [PATCH] fix switcher for darcula --- .../com/intellij/ide/actions/Switcher.java | 8 +- .../SwitcherToolWindowsListRenderer.java | 10 +- .../com/intellij/ide/ui/laf/IdeaDarkLaf.java | 138 +++++++----------- .../intellij/ide/ui/laf/darcula.properties | 50 +++++++ .../ide/ui/laf/darcula_linux.properties | 0 .../ide/ui/laf/darcula_mac.properties | 49 +------ .../ide/ui/laf/darcula_windows.properties | 1 + 7 files changed, 110 insertions(+), 146 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties create mode 100644 platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_linux.properties create mode 100644 platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_windows.properties diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java index eb56e045f9ac..ca8f805fb552 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java @@ -225,7 +225,7 @@ public class Switcher extends AnAction implements DumbAware { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); - g.setColor(BORDER_COLOR); + g.setColor(UIUtil.isUnderDarcula() ? Gray._68 : BORDER_COLOR); g.drawLine(0, 0, getWidth(), 0); } }; @@ -284,7 +284,7 @@ public class Switcher extends AnAction implements DumbAware { if (selected) { return renderer; } - final Color bgColor = list == mouseMoveSrc && index == mouseMoveListIndex ? ON_MOUSE_OVER_BG_COLOR : Color.WHITE; + final Color bgColor = list == mouseMoveSrc && index == mouseMoveListIndex ? ON_MOUSE_OVER_BG_COLOR : list.getBackground(); UIUtil.changeBackGround(renderer, bgColor); return renderer; } @@ -309,7 +309,7 @@ public class Switcher extends AnAction implements DumbAware { g.drawLine(0, 0, 0, getHeight()); } }; - separator.setBackground(Color.WHITE); + separator.setBackground(UIUtil.getControlColor()); int selectionIndex = -1; final FileEditorManagerImpl editorManager = (FileEditorManagerImpl)FileEditorManager.getInstance(project); @@ -961,7 +961,7 @@ public class Switcher extends AnAction implements DumbAware { append(name, SimpleTextAttributes.fromTextAttributes(attributes)); if (!selected && myPinned && FileEditorManager.getInstance(myProject).isFileOpen(virtualFile)) { - setBackground(LightColors.SLIGHTLY_GREEN); + setBackground(UIUtil.isUnderDarcula() ? list.getBackground().brighter() : LightColors.SLIGHTLY_GREEN); } } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java index 93c69f572abc..d371320c5c29 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java @@ -15,11 +15,9 @@ */ package com.intellij.ide.actions; -import com.intellij.openapi.editor.markup.EffectType; -import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.ToolWindow; -import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.SpeedSearchBase; @@ -36,7 +34,6 @@ import java.util.Map; */ class SwitcherToolWindowsListRenderer extends ColoredListCellRenderer { private static final Map iconCache = new HashMap(); - private static final SimpleTextAttributes ID_STYLE = new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, Color.black); private final SpeedSearchBase mySpeedSearch; private final Map ids; private final Map shortcuts; @@ -62,12 +59,11 @@ class SwitcherToolWindowsListRenderer extends ColoredListCellRenderer { if (myPinned) { name = ids.get(tw); } else { - append(shortcuts.get(tw), ID_STYLE); + append(shortcuts.get(tw), new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, null)); name = ": " + ids.get(tw); } - final TextAttributes attributes = new TextAttributes(Color.BLACK, null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); - append(name, SimpleTextAttributes.fromTextAttributes(attributes)); + append(name); if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) { hide = mySpeedSearch.matchingFragments(ids.get(tw)) == null && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix()); } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaDarkLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaDarkLaf.java index c2b3639e1430..d4cee0d5c0a9 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaDarkLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaDarkLaf.java @@ -15,13 +15,15 @@ */ package com.intellij.ide.ui.laf; -import com.intellij.icons.AllIcons; +import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.ColorUtil; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.IconUIResource; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.basic.BasicLookAndFeel; import java.awt.*; @@ -38,8 +40,12 @@ final class IdeaDarkLaf extends BasicLookAndFeel { BasicLookAndFeel base; public IdeaDarkLaf() { try { - final String name = UIManager.getSystemLookAndFeelClassName(); - base = (BasicLookAndFeel)Class.forName(name).newInstance(); + if (SystemInfo.isWindows) { + base = new IdeaLaf(); + } else { + final String name = UIManager.getSystemLookAndFeelClassName(); + base = (BasicLookAndFeel)Class.forName(name).newInstance(); + } } catch (Exception ignore) { log(ignore); @@ -48,7 +54,7 @@ final class IdeaDarkLaf extends BasicLookAndFeel { private void callInit(String method, UIDefaults defaults) { try { - final Method superMethod = base.getClass().getDeclaredMethod(method, UIDefaults.class); + final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method, UIDefaults.class); superMethod.setAccessible(true); superMethod.invoke(base, defaults); } @@ -65,17 +71,11 @@ final class IdeaDarkLaf extends BasicLookAndFeel { @Override public UIDefaults getDefaults() { try { - final Method superMethod = base.getClass().getDeclaredMethod("getDefaults"); + final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults defaults = (UIDefaults)superMethod.invoke(base); LafManagerImpl.initInputMapDefaults(defaults); initIdeaDefaults(defaults); - if (SystemInfo.isMac) { - defaults.put("Menu.arrowIcon", AllIcons.Mac.Tree_white_right_arrow); - defaults.put("MenuItem.acceleratorForeground", new ColorUIResource(255, 255, 255)); - defaults.put("Separator.foreground", new ColorUIResource(ColorUtil.fromHex("888888"))); - defaults.put("PopupMenu.background", new ColorUIResource(ColorUtil.fromHex("444444"))); - } return defaults; } catch (Exception ignore) { @@ -86,7 +86,7 @@ final class IdeaDarkLaf extends BasicLookAndFeel { private void call(String method) { try { - final Method superMethod = base.getClass().getDeclaredMethod(method); + final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method); superMethod.setAccessible(true); superMethod.invoke(base); } @@ -101,81 +101,9 @@ final class IdeaDarkLaf extends BasicLookAndFeel { @SuppressWarnings({"HardCodedStringLiteral"}) static void initIdeaDefaults(UIDefaults defaults) { - try { - final Properties properties = new Properties(); - final InputStream stream = IdeaDarkLaf.class.getResourceAsStream("darcula_mac.properties"); - properties.load(stream); - for (String key : properties.stringPropertyNames()) { - final String value = properties.getProperty(key); - if (key.endsWith("Insets")) { - final List numbers = StringUtil.split(value, ","); - defaults.put(key, new InsetsUIResource(Integer.parseInt(numbers.get(0)), - Integer.parseInt(numbers.get(1)), - Integer.parseInt(numbers.get(2)), - Integer.parseInt(numbers.get(3)))); - } else { - final Color color = ColorUtil.fromHex(value, null); - final Integer invVal = getInteger(value); + loadDefaults(defaults, null); //load defaults + loadDefaults(defaults, SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux"); // load OS customization - if (color != null) { - defaults.put(key, new ColorUIResource(color)); - } else if (invVal != null) { - defaults.put(key, invVal); - } else { - defaults.put(key, value); - } - } - } - } - catch (IOException e) { - log(e); - } - //defaults.put("TitledBorder.titleColor", IdeaBlueMetalTheme.primary1); - //ColorUIResource col = new ColorUIResource(0, 0, 0); - //defaults.put("ScrollBar.background", col); - //defaults.put("ScrollBar.track", col); - // - ////Border scrollPaneBorder = new BorderUIResource(new BegBorders.ScrollPaneBorder()); - ////defaults.put("ScrollPane.border", scrollPaneBorder); - //ColorUIResource defaultBackground = new ColorUIResource(68, 68, 68); - //ColorUIResource defaultForeground = new ColorUIResource(255, 255, 255); - //final ColorUIResource selectionBackground = new ColorUIResource(44, 44, 44); - //defaults.put("Tree.background", defaultBackground); - //defaults.put("List.background", defaultBackground); - //defaults.put("Table.background", defaultBackground); - //defaults.put("Tree.foreground", defaultForeground); - //defaults.put("Tree.textForeground", defaultForeground); - //defaults.put("Tree.selectionBackground", selectionBackground); - //defaults.put("Tree.selectionForeground", defaultForeground); - // - //defaults.put("List.foreground", defaultForeground); - //defaults.put("Table.foreground", defaultForeground); - // - //defaults.put("control", new ColorUIResource(44, 44, 44)); - // - //defaults.put("Panel.background", new ColorUIResource(44, 44, 44)); - //defaults.put("Panel.foreground", new ColorUIResource(255, 255, 255)); - //defaults.put("Menu.selectionBackground", new ColorUIResource(190, 190, 190)); - //defaults.put("Menu.background", new ColorUIResource(68, 68, 68)); - //defaults.put("MenuItem.background", new ColorUIResource(68, 68, 68)); - //defaults.put("Menu.foreground", new ColorUIResource(255, 255, 255)); - //defaults.put("MenuItem.foreground", new ColorUIResource(255, 255, 255)); - ////defaults.put("ScrollPaneUI", BegScrollPaneUI.class.getName()); - // - //defaults.put("TabbedPane.tabInsets", new Insets(0, 4, 0, 4)); - //defaults.put("ToolTip.background", new ColorUIResource(0, 14, 0)); - //defaults.put("ToolTip.border", new ColoredSideBorder(Color.gray, Color.gray, Color.black, Color.black, 1)); - //defaults.put("Tree.ancestorInputMap", null); - //defaults.put("FileView.directoryIcon", AllIcons.Nodes.Folder); - //defaults.put("FileChooser.upFolderIcon", AllIcons.Nodes.UpFolder); - //defaults.put("FileChooser.newFolderIcon", AllIcons.Nodes.NewFolder); - //defaults.put("FileChooser.homeFolderIcon", AllIcons.Nodes.HomeFolder); - //defaults.put("OptionPane.errorIcon", AllIcons.General.ErrorDialog); - //defaults.put("OptionPane.informationIcon", AllIcons.General.InformationDialog); - //defaults.put("OptionPane.warningIcon", AllIcons.General.WarningDialog); - //defaults.put("OptionPane.questionIcon", AllIcons.General.QuestionDialog); - //defaults.put("Tree.expandedIcon", WindowsTreeUI.ExpandedIcon.createExpandedIcon()); - //defaults.put("Tree.collapsedIcon", WindowsTreeUI.CollapsedIcon.createCollapsedIcon()); defaults.put("Table.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "ctrl C", "copy", "ctrl V", "paste", @@ -228,6 +156,42 @@ final class IdeaDarkLaf extends BasicLookAndFeel { })); } + private static void loadDefaults(UIDefaults defaults, @Nullable String postfix) { + try { + final Properties properties = new Properties(); + final String secondPart = postfix == null ? "" : "_" + postfix; + final String name = "darcula" + secondPart + ".properties"; + final InputStream stream = IdeaDarkLaf.class.getResourceAsStream(name); + properties.load(stream); + for (String key : properties.stringPropertyNames()) { + final String value = properties.getProperty(key); + if (key.endsWith("Insets")) { + final List numbers = StringUtil.split(value, ","); + defaults.put(key, new InsetsUIResource(Integer.parseInt(numbers.get(0)), + Integer.parseInt(numbers.get(1)), + Integer.parseInt(numbers.get(2)), + Integer.parseInt(numbers.get(3)))); + } else { + final Color color = ColorUtil.fromHex(value, null); + final Integer invVal = getInteger(value); + Icon icon = value != null && value.startsWith("AllIcons.") ? IconLoader.getIcon(value) : null; + if (color != null) { + defaults.put(key, new ColorUIResource(color)); + } else if (invVal != null) { + defaults.put(key, invVal); + } else if (icon != null) { + defaults.put(key, new IconUIResource(icon)); + } else { + defaults.put(key, value); + } + } + } + } + catch (IOException e) { + log(e); + } + } + private static Integer getInteger(String value) { try { return Integer.parseInt(value); @@ -286,7 +250,7 @@ final class IdeaDarkLaf extends BasicLookAndFeel { @Override protected void loadSystemColors(UIDefaults defaults, String[] systemColors, boolean useNative) { try { - final Method superMethod = base.getClass().getDeclaredMethod("loadSystemColors", + final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("loadSystemColors", UIDefaults.class, String[].class, boolean.class); diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties new file mode 100644 index 000000000000..389db6c52ea9 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties @@ -0,0 +1,50 @@ +Menu.maxGutterIconWidth=18 +MenuItem.maxGutterIconWidth=18 +MenuItem.acceleratorDelimiter=- + +#Trees +Tree.background=444444 +Tree.foreground=FFFFFF +Tree.textForeground=FFFFFF +#Tree.selectionBackground=BEBEBE +#Tree.selectionForeground=444444 + +#Lists +List.background=444444 +List.foreground=FFFFFF + +#Tables +Table.background=444444 +Table.foreground=FFFFFF +control=444444 +Panel.background=404040 +Panel.foreground=FFFFFF +Menu.selectionBackground=bebebe +MenuBar.background=444444 +MenuBar.disabledBackground=444444 +MenuBar.shadow=444444 +Menu.background=444444 +MenuItem.background=444444 +Menu.foreground=FFFFFF +MenuItem.foreground=ffffff +TabbedPane.tabInsets=0,4,0,4 +ToggleButton.foreground=ffffff +Separator.background=444444 +Separator.foreground=888888 + +Label.foreground=ffffff +Focus.color=ff0000 + +TextField.background=444444 +TextField.foreground=ffffff +CheckBox.background=444444 +CheckBox.foreground=ffffff +RadioButton.foreground=ffffff + +StatusBar.topColor=2c2c2c +StatusBar.top2Color=2c2c2c +StatusBar.bottomColor=2c2c2c + +TextField.caretForeground=ffffff +MenuItem.acceleratorForeground=ffffff +PopupMenu.background=444444 \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_linux.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_linux.properties new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_mac.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_mac.properties index 694b72dd2c48..24b605cf9fa8 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_mac.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_mac.properties @@ -1,48 +1 @@ -Menu.maxGutterIconWidth=18 -MenuItem.maxGutterIconWidth=18 -MenuItem.acceleratorDelimiter=- - -#Trees -Tree.background=444444 -Tree.foreground=FFFFFF -Tree.textForeground=FFFFFF -#Tree.selectionBackground=BEBEBE -#Tree.selectionForeground=444444 - -#Lists -List.background=444444 -List.foreground=FFFFFF - -#Tables -Table.background=444444 -Table.foreground=FFFFFF -control=444444 -Panel.background=404040 -Panel.foreground=FFFFFF -Menu.selectionBackground=bebebe -MenuBar.background=444444 -MenuBar.disabledBackground=444444 -MenuBar.shadow=444444 -Menu.background=444444 -MenuItem.background=444444 -Menu.foreground=FFFFFF -MenuItem.foreground=ffffff -TabbedPane.tabInsets=0,4,0,4 -ToggleButton.foreground=ffffff -Separator.foreground=ffffff -Separator.background=444444 - -Label.foreground=ffffff -Focus.color=ff0000 - -TextField.background=444444 -TextField.foreground=ffffff -CheckBox.background=444444 -CheckBox.foreground=ffffff -RadioButton.foreground=ffffff - -StatusBar.topColor=2c2c2c -StatusBar.top2Color=2c2c2c -StatusBar.bottomColor=2c2c2c - -TextField.caretForeground=ffffff +Menu.arrowIcon=AllIcons.Mac.Tree_white_right_arrow \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_windows.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_windows.properties new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula_windows.properties @@ -0,0 +1 @@ +