diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 3ee18feda..6e3ecd728 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -43,4 +43,5 @@ It should contain: * OS (Windows, Linux, Mac) * IntelliJ Product + version (IDEA, RubyMine...) * Plugin version +* Plugin configuration (found in material_theme.xml) * If needed a list of enabled plugins diff --git a/CHANGELOG.md b/CHANGELOG.md index 10de82dce..dc575e30d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## 0.12.0 +- New components: slider and radio buttons + +## 0.11.0 +- Targeting 2017.3 + +## 0.10.6 +- Fix ComboboxAction and IdeaButtonLookAction in 2017.3 +- Set default color for "NOT CHANGED" file status +- Set directories color from "Up to date" file status +- Fix issue with Run Configurations +- Fix Scratches Color in the tree + +## 0.10.5 +- Bug fixes due to the passage to 2017.3 + +## 0.10.4 +- Fix Tabbed Pane color in Arc and One Dark +- Fix background color of list selected items in One Dark +- Add babelrc.json to babel icon association +- Fix (hopefully) the NullPointerException due to not being recognized File Colors + ## 0.10.3 - Material One Dark Color Scheme diff --git a/M.svg b/M.svg new file mode 100644 index 000000000..0ede12b54 --- /dev/null +++ b/M.svg @@ -0,0 +1,28 @@ + + + + + Asset 1 + + + + + + + + + diff --git a/Material Theme.zip b/Material Theme.zip index a42ce4853..6fee0af0a 100644 Binary files a/Material Theme.zip and b/Material Theme.zip differ diff --git a/build.gradle b/build.gradle index 4f6ae4d28..39ea3cdfa 100644 --- a/build.gradle +++ b/build.gradle @@ -81,20 +81,23 @@ jacocoTestReport { intellij { pluginName 'Material Theme' - version '172.4155.24' - type 'IU' - downloadSources false + version '173.2290.1' + downloadSources true sameSinceUntilBuild true alternativeIdePath idePath updateSinceUntilBuild = false - plugins = ['com.jetbrains.php:172.4155.25', 'yaml','properties', 'CSS', 'JavaScriptLanguage', 'com.jetbrains.twig:172' + - '.2827.17', 'Pythonid:2017.2.172.3317.93'] + plugins = ['com.jetbrains.php:173.2290.12', + 'yaml', + 'properties', + 'com.jetbrains.twig:173.2290.12', + 'Pythonid:2017.3.173.2099.13'] // systemProperty "idea.platform.prefix","DataGrip" publishPlugin { username publishUsername password publishPassword +// channels = ['eap'] } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 58b396d62..bf9191a42 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Wed Sep 06 15:38:04 IDT 2017 +#Sun Sep 24 09:19:19 IDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/com/chrisrm/idea/MTConfig.java b/src/main/java/com/chrisrm/idea/MTConfig.java index 8330bef7e..ef81e193d 100644 --- a/src/main/java/com/chrisrm/idea/MTConfig.java +++ b/src/main/java/com/chrisrm/idea/MTConfig.java @@ -52,7 +52,7 @@ ) public class MTConfig implements PersistentStateComponent { public static final String DEFAULT_BG = "https://raw.githubusercontent" + - ".com/mallowigi/material-theme-jetbrains-eap/master/src/main/resources/themes/wall.jpg,60"; + ".com/mallowigi/material-theme-jetbrains-eap/master/src/main/resources/themes/wall.jpg,60"; public static final String ACCENT_COLOR = "80CBC4"; // They are public so they can be serialized public MTThemes selectedTheme = MTThemes.DEFAULT; @@ -101,7 +101,8 @@ public MTConfig() { if (this.highlightThickness == null) { highlightThickness = Integer.parseInt(properties.getProperty("material.tab.borderThickness")); } - } catch (final IOException ignored) { + } + catch (final IOException ignored) { } } @@ -155,8 +156,8 @@ public void loadState(final MTConfig state) { */ public void fireBeforeChanged(final MTForm form) { ApplicationManager.getApplication().getMessageBus() - .syncPublisher(BeforeConfigNotifier.BEFORE_CONFIG_TOPIC) - .beforeConfigChanged(this, form); + .syncPublisher(BeforeConfigNotifier.BEFORE_CONFIG_TOPIC) + .beforeConfigChanged(this, form); } /** @@ -164,8 +165,8 @@ public void fireBeforeChanged(final MTForm form) { */ public void fireChanged() { ApplicationManager.getApplication().getMessageBus() - .syncPublisher(ConfigNotifier.CONFIG_TOPIC) - .configChanged(this); + .syncPublisher(ConfigNotifier.CONFIG_TOPIC) + .configChanged(this); } //region Tabs Highlight @@ -293,13 +294,11 @@ public void setIsMaterialDesign(final boolean materialDesign) { isMaterialDesign = materialDesign; } - public boolean isMaterialDesignChanged(final boolean isMaterialDesign) { return this.isMaterialDesign != isMaterialDesign; } //endregion - //region Bold Tabs public boolean getIsBoldTabs() { return isBoldTabs; @@ -324,7 +323,7 @@ public void setAccentColor(final String accentColor) { } public boolean isAccentColorChanged(final Color customAccentColor) { - return !Objects.equals(this.accentColor, customAccentColor); + return !Objects.equals(this.accentColor, ColorUtil.toHex(customAccentColor)); } //endregion @@ -354,7 +353,6 @@ public boolean isWallpaperSetChanged(final boolean isWallpaperSet) { } //endregion - //region Material Icons public boolean isUseMaterialIcons() { return useMaterialIcons; @@ -541,6 +539,4 @@ public boolean isUpperCaseTabsChanged(final boolean upperCaseTabs) { } //endregion - - } diff --git a/src/main/java/com/chrisrm/idea/MTCustomThemeConfig.java b/src/main/java/com/chrisrm/idea/MTCustomThemeConfig.java index 2ccb8743d..2a07c69e8 100644 --- a/src/main/java/com/chrisrm/idea/MTCustomThemeConfig.java +++ b/src/main/java/com/chrisrm/idea/MTCustomThemeConfig.java @@ -37,8 +37,9 @@ import com.intellij.util.xmlb.XmlSerializerUtil; import org.jetbrains.annotations.NotNull; -import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.*; import java.awt.*; +import java.util.Objects; @State( name = "MaterialCustomThemeConfig", @@ -79,8 +80,8 @@ public void loadState(final MTCustomThemeConfig state) { public void fireChanged() { ApplicationManager.getApplication().getMessageBus() - .syncPublisher(CustomConfigNotifier.CONFIG_TOPIC) - .customConfigChanged(this); + .syncPublisher(CustomConfigNotifier.CONFIG_TOPIC) + .customConfigChanged(this); } public Color getTreeSelectionColor() { @@ -259,11 +260,70 @@ public void setButtonHighlightColor(final Color buttonHighlightColor) { this.buttonHighlightColor = ColorUtil.toHex(buttonHighlightColor); } - public void setTreeSelectionColor(final Color treeSelectionColor) { this.treeSelectionColor = ColorUtil.toHex(treeSelectionColor); } + public boolean isBackgroundColorChanged(Color backgroundColor) { + return !Objects.equals(this.backgroundColor, ColorUtil.toHex(backgroundColor)); + } + + public boolean isForegroundColorChanged(Color foregroundColor) { + return !Objects.equals(this.foregroundColor, ColorUtil.toHex(foregroundColor)); + } + + public boolean isTextColorChanged(Color textColor) { + return !Objects.equals(this.textColor, ColorUtil.toHex(textColor)); + } + + public boolean isSelectionBackgroundColorChanged(Color selectionBackgroundColor) { + return !Objects.equals(this.selectionBackgroundColor, ColorUtil.toHex(selectionBackgroundColor)); + } + + public boolean isSelectionForegroundColorChanged(Color selectionForegroundColor) { + return !Objects.equals(this.selectionForegroundColor, ColorUtil.toHex(selectionForegroundColor)); + } + + public boolean isInactiveColorChanged(Color inactiveColor) { + return !Objects.equals(this.inactiveColor, ColorUtil.toHex(inactiveColor)); + } + + public boolean isCaretColorChanged(Color caretColor) { + return !Objects.equals(this.caretColor, ColorUtil.toHex(caretColor)); + } + + public boolean isSecondaryBackgrouncColorChanged(Color secondaryBackgroundColor) { + return !Objects.equals(this.secondaryBackgroundColor, ColorUtil.toHex(secondaryBackgroundColor)); + } + + public boolean isDisabledColorChanged(Color disabledColor) { + return !Objects.equals(this.disabledColor, ColorUtil.toHex(disabledColor)); + } + + public boolean isContrastColorChanged(Color contrastColor) { + return !Objects.equals(this.contrastColor, ColorUtil.toHex(contrastColor)); + } + + public boolean isTableSelectionColorChanged(Color tableSelectedColor) { + return !Objects.equals(this.tableSelectedColor, ColorUtil.toHex(tableSelectedColor)); + } + + public boolean isSecondBorderColorChanged(Color secondBorderColor) { + return !Objects.equals(this.secondBorderColor, ColorUtil.toHex(secondBorderColor)); + } + + public boolean isHighlightColorChanged(Color highlightColor) { + return !Objects.equals(this.highlightColor, ColorUtil.toHex(highlightColor)); + } + + public boolean isButtonHighlightColorChanged(Color buttonHighlightColor) { + return !Objects.equals(this.buttonHighlightColor, ColorUtil.toHex(buttonHighlightColor)); + } + + public boolean isTreeSelectionColorChanged(Color treeSelectionColor) { + return !Objects.equals(this.treeSelectionColor.substring(0, 6), ColorUtil.toHex(treeSelectionColor)); + } + public static final class MTCustomDefaults { public static Color treeSelectionColor = ColorUtil.toAlpha(new ColorUIResource(0x546E7A), 50); public static ColorUIResource buttonHighlightColor = new ColorUIResource(0x304146); @@ -281,5 +341,4 @@ public static final class MTCustomDefaults { public static ColorUIResource foregroundColor = new ColorUIResource(0xB0BEC5); public static ColorUIResource backgroundColor = new ColorUIResource(0x263238); } - } diff --git a/src/main/java/com/chrisrm/idea/MTLafComponent.java b/src/main/java/com/chrisrm/idea/MTLafComponent.java index 07d654522..3d262c29f 100644 --- a/src/main/java/com/chrisrm/idea/MTLafComponent.java +++ b/src/main/java/com/chrisrm/idea/MTLafComponent.java @@ -93,27 +93,30 @@ public static void hackTitleLabel() { final ClassPool cp = new ClassPool(true); cp.insertClassPath(new ClassClassPath(CaptionPanel.class)); final CtClass ctClass = cp.get("com.intellij.ui.TitlePanel"); - final CtConstructor declaredConstructor = ctClass.getDeclaredConstructor(new CtClass[]{ + final CtConstructor declaredConstructor = ctClass.getDeclaredConstructor(new CtClass[] { cp.get("javax.swing.Icon"), cp.get("javax.swing" + - ".Icon")}); + ".Icon")}); declaredConstructor.instrument(new ExprEditor() { @Override public void edit(final MethodCall m) throws CannotCompileException { if (m.getMethodName().equals("empty")) { // Replace insets m.replace("{ $1 = 10; $2 = 10; $3 = 10; $4 = 10; $_ = $proceed($$); }"); - } else if (m.getMethodName().equals("setHorizontalAlignment")) { + } + else if (m.getMethodName().equals("setHorizontalAlignment")) { // Set title at the left m.replace("{ $1 = javax.swing.SwingConstants.LEFT; $_ = $proceed($$); }"); - } else if (m.getMethodName().equals("setBorder")) { + } + else if (m.getMethodName().equals("setBorder")) { // Bigger heading m.replace("{ $_ = $proceed($$); myLabel.setFont(myLabel.getFont().deriveFont(1, com.intellij.util.ui.JBUI.scale(16.0f))); }"); } } }); ctClass.toClass(); - } catch (final Exception e) { + } + catch (final Exception e) { e.printStackTrace(); } } @@ -128,7 +131,7 @@ private static void hackIdeaActionButton() { final CtClass ctClass = cp.get("com.intellij.openapi.actionSystem.impl.IdeaActionButtonLook"); // Edit paintborder - final CtClass[] paintBorderParams = new CtClass[]{ + final CtClass[] paintBorderParams = new CtClass[] { cp.get("java.awt.Graphics"), cp.get("java.awt.Dimension"), cp.get("int") @@ -139,29 +142,31 @@ private static void hackIdeaActionButton() { public void edit(final MethodCall m) throws CannotCompileException { if (m.getMethodName().equals("setColor")) { m.replace("{ $1 = javax.swing.UIManager.getColor(\"Focus.color\"); $_ = $proceed($$); }"); - } else if (m.getMethodName().equals("draw")) { + } + else if (m.getMethodName().equals("draw")) { m.replace("{ if ($1.getBounds().width > 30) { " + - "$proceed($$); " + - "} else { " + - "$0.fillOval(1, 1, $1.getBounds().width, $1.getBounds().height); } " + - "}"); + "$proceed($$); " + + "} else { " + + "$0.fillOval(1, 1, $1.getBounds().width, $1.getBounds().height); } " + + "}"); } } }); // Edit paintborder - final CtClass[] paintBackgroundParams = new CtClass[]{ + // outdated in EAP 2017.3 + final CtClass[] paintBackgroundParams = new CtClass[] { cp.get("java.awt.Graphics"), cp.get("java.awt.Dimension"), cp.get("java.awt.Color"), cp.get("int") }; - final CtMethod paintBackground = ctClass.getDeclaredMethod("paintBackground", paintBackgroundParams); + final CtMethod paintBackground = ctClass.getDeclaredMethod("paintBackground"); paintBackground.instrument(new ExprEditor() { @Override public void edit(final MethodCall m) throws CannotCompileException { - if (m.getMethodName().equals("setColor")) { - m.replace("{ $1 = new java.awt.Color(0x00000000, true); $_ = $proceed($$); }"); + if (m.getMethodName().equals("paintBackground")) { + m.replace("{ }"); } } }); @@ -175,7 +180,8 @@ public void edit(final MethodCall m) throws CannotCompileException { public void edit(final MethodCall m) throws CannotCompileException { if (m.getMethodName().equals("drawRoundRect")) { m.replace("{ $2 = $4; $5 = 0; $6 = 0; $_ = $proceed($$); }"); - } else if (m.getMethodName().equals("setPaint") && m.getLineNumber() > 454 && m.getLineNumber() < 460) { + } + else if (m.getMethodName().equals("setPaint") && m.getLineNumber() > 454 && m.getLineNumber() < 461) { final String color = "javax.swing.UIManager.getColor(\"TextField.selectedSeparatorColor\")"; m.replace("{ $1 = myMouseInside ? " + color + " : com.intellij.ui.Gray._95; $_ = $proceed($$); }"); } @@ -183,13 +189,12 @@ public void edit(final MethodCall m) throws CannotCompileException { }); comboBoxActionButtonClass.toClass(); - - } catch (final Exception e) { + } + catch (final Exception e) { e.printStackTrace(); } } - @Override public void disposeComponent() { connect.disconnect(); @@ -306,10 +311,17 @@ private void installMaterialComponents() { replaceStatusBar(); replaceSpinners(); replaceCheckboxes(); + replaceRadioButtons(); + replaceSliders(); // replaceTextAreas(); } } + private void replaceSliders() { + UIManager.put("SliderUI", MTSliderUI.class.getName()); + UIManager.getDefaults().put(MTSliderUI.class.getName(), MTSliderUI.class); + } + private void replaceCheckboxes() { UIManager.put("CheckBoxUI", MTCheckBoxUI.class.getName()); UIManager.getDefaults().put(MTCheckBoxUI.class.getName(), MTCheckBoxUI.class); @@ -317,6 +329,11 @@ private void replaceCheckboxes() { UIManager.put("CheckBox.border", new MTCheckBoxBorder()); } + private void replaceRadioButtons() { + UIManager.put("RadioButtonUI", MTRadioButtonUI.class.getName()); + UIManager.getDefaults().put(MTRadioButtonUI.class.getName(), MTRadioButtonUI.class); + } + private void replaceTextAreas() { UIManager.put("TextAreaUI", MTTextAreaUI.class.getName()); UIManager.getDefaults().put(MTTextAreaUI.class.getName(), MTTextAreaUI.class); @@ -362,6 +379,5 @@ private void replaceTree() { UIManager.put("List.sourceListSelectionBackgroundPainter", new MTSelectedTreePainter()); UIManager.put("List.sourceListFocusedSelectionBackgroundPainter", new MTSelectedTreePainter()); - } } diff --git a/src/main/java/com/chrisrm/idea/MTTheme.java b/src/main/java/com/chrisrm/idea/MTTheme.java index 8b70dfeda..f2f7436e4 100644 --- a/src/main/java/com/chrisrm/idea/MTTheme.java +++ b/src/main/java/com/chrisrm/idea/MTTheme.java @@ -245,6 +245,7 @@ protected String[] getSelectionBackgroundResources() { "Menu.selectionBackground", "MenuItem.selectionBackground", "Autocomplete.selectionbackground", + "List.selectionBackground", "EditorPane.inactiveForeground", "ScrollBar.thumb" }; @@ -290,6 +291,11 @@ protected String[] getBackgroundResources() { "PasswordField.background", "FormattedTextField.background", "TextArea.background", + "CheckBox.background", + "Slider.background", + "Label.background", + "TextPane.background", + "RadioButton.background", "CheckBox.darcula.backgroundColor1", "CheckBox.darcula.backgroundColor2", "CheckBox.darcula.checkSignColor", diff --git a/src/main/java/com/chrisrm/idea/MTThemeManager.java b/src/main/java/com/chrisrm/idea/MTThemeManager.java index da7f8c5d9..b20f621a0 100644 --- a/src/main/java/com/chrisrm/idea/MTThemeManager.java +++ b/src/main/java/com/chrisrm/idea/MTThemeManager.java @@ -55,9 +55,8 @@ import sun.awt.AppContext; import javax.swing.*; -import javax.swing.plaf.FontUIResource; -import javax.swing.text.html.HTMLEditorKit; -import javax.swing.text.html.StyleSheet; +import javax.swing.plaf.*; +import javax.swing.text.html.*; import java.awt.*; import java.lang.reflect.Field; import java.net.URL; @@ -70,7 +69,7 @@ public final class MTThemeManager { - private static final String[] FONT_RESOURCES = new String[]{ + private static final String[] FONT_RESOURCES = new String[] { "Button.font", "ToggleButton.font", "RadioButton.font", @@ -106,7 +105,7 @@ public final class MTThemeManager { "ToolTip.font", "Tree.font"}; - private static final String[] CONTRASTED_RESOURCES = new String[]{ + private static final String[] CONTRASTED_RESOURCES = new String[] { "Tree.background", "Tree.textBackground", // "Table.background", @@ -151,7 +150,7 @@ public final class MTThemeManager { "ActionToolbar.background" }; - public static final String[] ACCENT_RESOURCES = new String[]{ + public static final String[] ACCENT_RESOURCES = new String[] { "link.foreground", "ProgressBar.foreground", "RadioButton.darcula.selectionEnabledColor", @@ -168,6 +167,7 @@ public final class MTThemeManager { "CheckBox.darcula.focused.backgroundColor2.selected", "Hyperlink.linkColor", "Focus.color", + "Slider.thumb", "material.tab.borderColor" }; public static final int DEFAULT_SIDEBAR_HEIGHT = 28; @@ -335,7 +335,6 @@ public void activate(final MTThemes mtTheme) { applyAccents(false); setBoldTabs(); - final String currentScheme = EditorColorsManager.getInstance().getGlobalScheme().getName(); final String makeActiveScheme = !editorColorsSchemes.contains(currentScheme) ? @@ -347,7 +346,8 @@ public void activate(final MTThemes mtTheme) { if (UIUtil.isUnderDarcula()) { DarculaInstaller.uninstall(); DarculaInstaller.install(); - } else { + } + else { DarculaInstaller.uninstall(); } LafManager.getInstance().updateUI(); @@ -400,7 +400,8 @@ private void removeTheme(final MTThemes mtTheme) { if (UIUtil.isUnderDarcula()) { UIManager.setLookAndFeel(new DarculaLaf()); - } else { + } + else { UIManager.setLookAndFeel(new IntelliJLaf()); } @@ -412,10 +413,12 @@ private void removeTheme(final MTThemes mtTheme) { if (UIUtil.isUnderDarcula()) { DarculaInstaller.uninstall(); DarculaInstaller.install(); - } else { + } + else { DarculaInstaller.uninstall(); } - } catch (final UnsupportedLookAndFeelException e) { + } + catch (final UnsupportedLookAndFeelException e) { e.printStackTrace(); } } @@ -449,7 +452,8 @@ private void applyFonts() { if (uiSettings.getOverrideLafFonts()) { applyCustomFonts(lookAndFeelDefaults, uiSettings.getFontFace(), uiSettings.getFontSize()); - } else { + } + else { final Font roboto = MTUiUtils.findFont(DEFAULT_FONT); if (roboto != null) { applyCustomFonts(lookAndFeelDefaults, DEFAULT_FONT, JBUI.scale(DEFAULT_FONT_SIZE)); @@ -498,7 +502,8 @@ private void applyCustomTreeIndent() { if (mtConfig.isCustomTreeIndentEnabled) { UIManager.put("Tree.rightChildIndent", mtConfig.customTreeIndent); - } else { + } + else { UIManager.put("Tree.rightChildIndent", DEFAULT_INDENT); } } @@ -545,7 +550,8 @@ private void patchStyledEditorKit() { final Field keyField = HTMLEditorKit.class.getDeclaredField("DEFAULT_STYLES_KEY"); keyField.setAccessible(true); AppContext.getAppContext().put(keyField.get(null), styleSheet); - } catch (final Exception ignored) { + } + catch (final Exception ignored) { } } //endregion @@ -579,7 +585,8 @@ private void reloadUI(final MTTheme mtTheme) { if (UIUtil.isUnderDarcula()) { DarculaInstaller.install(); } - } catch (final UnsupportedLookAndFeelException e) { + } + catch (final UnsupportedLookAndFeelException e) { e.printStackTrace(); } } diff --git a/src/main/java/com/chrisrm/idea/config/MTCustomThemeConfigurable.java b/src/main/java/com/chrisrm/idea/config/MTCustomThemeConfigurable.java index 5298305dc..c1eaf23ad 100644 --- a/src/main/java/com/chrisrm/idea/config/MTCustomThemeConfigurable.java +++ b/src/main/java/com/chrisrm/idea/config/MTCustomThemeConfigurable.java @@ -29,7 +29,6 @@ import com.chrisrm.idea.MTCustomThemeConfig; import com.chrisrm.idea.config.ui.MTCustomThemeForm; import com.chrisrm.idea.messages.MaterialThemeBundle; -import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -80,7 +79,7 @@ protected MTCustomThemeForm createForm() { } @Override - protected void doApply(final MTCustomThemeForm mtForm, final MTCustomThemeConfig mtConfig) throws ConfigurationException { + protected void doApply(final MTCustomThemeForm mtForm, final MTCustomThemeConfig mtConfig) { mtConfig.setBackgroundColor(mtForm.getBackgroundColor()); mtConfig.setForegroundColor(mtForm.getForegroundColor()); mtConfig.setTextColor(mtForm.getTextColor()); @@ -102,6 +101,22 @@ protected void doApply(final MTCustomThemeForm mtForm, final MTCustomThemeConfig @Override protected boolean checkModified(final MTCustomThemeForm mtForm, final MTCustomThemeConfig mtConfig) { - return true; + boolean modified = mtConfig.isBackgroundColorChanged(getForm().getBackgroundColor()); + modified = modified || mtConfig.isForegroundColorChanged(getForm().getForegroundColor()); + modified = modified || mtConfig.isTextColorChanged(getForm().getTextColor()); + modified = modified || mtConfig.isSelectionBackgroundColorChanged(getForm().getSelectionForegroundColor()); + modified = modified || mtConfig.isSelectionForegroundColorChanged(getForm().getSelectionForegroundColor()); + modified = modified || mtConfig.isInactiveColorChanged(getForm().getInactiveColor()); + modified = modified || mtConfig.isCaretColorChanged(getForm().getCaretColor()); + modified = modified || mtConfig.isSecondaryBackgrouncColorChanged(getForm().getSecondaryBackgroundColor()); + modified = modified || mtConfig.isDisabledColorChanged(getForm().getDisabledColor()); + modified = modified || mtConfig.isContrastColorChanged(getForm().getContrastColor()); + modified = modified || mtConfig.isTableSelectionColorChanged(getForm().getTableSelectedColor()); + modified = modified || mtConfig.isSecondBorderColorChanged(getForm().getSecondBorderColor()); + modified = modified || mtConfig.isHighlightColorChanged(getForm().getHighlightColor()); + modified = modified || mtConfig.isButtonHighlightColorChanged(getForm().getButtonHighlightColor()); + modified = modified || mtConfig.isTreeSelectionColorChanged(getForm().getTreeSelectionColor()); + + return modified; } } diff --git a/src/main/java/com/chrisrm/idea/config/MTFileColorsPage.java b/src/main/java/com/chrisrm/idea/config/MTFileColorsPage.java index fdd7929f0..db357d33a 100644 --- a/src/main/java/com/chrisrm/idea/config/MTFileColorsPage.java +++ b/src/main/java/com/chrisrm/idea/config/MTFileColorsPage.java @@ -48,7 +48,15 @@ import java.util.List; import java.util.Map; +import static com.chrisrm.idea.schemes.MTFileColors.initFileColors; + public final class MTFileColorsPage implements ColorSettingsPage, DisplayPrioritySortable { + + private List descriptors; + + private MTFileColorsPage() { + } + @NotNull @Override public AttributesDescriptor[] getAttributeDescriptors() { @@ -58,12 +66,16 @@ public AttributesDescriptor[] getAttributeDescriptors() { @NotNull @Override public ColorDescriptor[] getColorDescriptors() { - final List descriptors = new ArrayList<>(); + if (this.descriptors == null) { + this.descriptors = new ArrayList<>(); + initFileColors(); - final FileStatus[] allFileStatuses = FileStatusFactory.getInstance().getAllFileStatuses(); - for (final FileStatus allFileStatus : allFileStatuses) { - descriptors.add(new ColorDescriptor(allFileStatus.getText(), MTFileColors.getColorKey(allFileStatus), ColorDescriptor.Kind - .FOREGROUND)); + final FileStatus[] allFileStatuses = FileStatusFactory.getInstance().getAllFileStatuses(); + for (final FileStatus allFileStatus : allFileStatuses) { + descriptors.add(new ColorDescriptor(allFileStatus.getText(), + MTFileColors.getColorKey(allFileStatus), + ColorDescriptor.Kind.FOREGROUND)); + } } return ArrayUtil.toObjectArray(descriptors, ColorDescriptor.class); diff --git a/src/main/java/com/chrisrm/idea/schemes/MTFileColors.java b/src/main/java/com/chrisrm/idea/schemes/MTFileColors.java index e1cf57f45..3bacbf8ec 100644 --- a/src/main/java/com/chrisrm/idea/schemes/MTFileColors.java +++ b/src/main/java/com/chrisrm/idea/schemes/MTFileColors.java @@ -30,11 +30,15 @@ public final class MTFileColors { public static final ColorKey DELETED_FROM_FS = ColorKey.createColorKey("MT_DELETED_FROM_FS", ColorUtil.fromHex("#626669")); public static final ColorKey SWITCHED = ColorKey.createColorKey("MT_SWITCHED", ColorUtil.fromHex("#F77669")); public static final ColorKey OBSOLETE = ColorKey.createColorKey("MT_OBSOLETE", ColorUtil.fromHex("#FFCB6B")); - public static final ColorKey SUPPRESSED = ColorKey.createColorKey("MT_SUPPRESSED", ColorUtil.fromHex("#3C3F41")); + public static final ColorKey SUPPRESSED = ColorKey.createColorKey("MT_SUPPRESSED", ColorUtil.fromHex("#546E7A")); - public static final HashMap FILE_STATUS_COLOR_MAP; + public static HashMap FILE_STATUS_COLOR_MAP; static { + initFileColors(); + } + + public static void initFileColors() { FILE_STATUS_COLOR_MAP = new HashMap<>(18); // Load all registered file statuses and read their colors from the properties final FileStatus[] allFileStatuses = FileStatusFactory.getInstance().getAllFileStatuses(); @@ -46,7 +50,7 @@ public final class MTFileColors { final String originalColorString = ColorUtil.toHex(originalColor); // 2a. Get custom file color from the bundle, or default to original file color final String property = FileColorsBundle.messageOrDefault("material.file." + allFileStatus.getId().toLowerCase(), - originalColorString); + originalColorString); final Color color = ColorUtil.fromHex(property == null ? originalColorString : property); // 2b. Set in the map the custom/default file color @@ -57,7 +61,7 @@ public final class MTFileColors { final String property = FileColorsBundle.messageOrDefault("material.file." + allFileStatus.getId().toLowerCase(), "-1"); // If not found do not add the color to the map if (Objects.equals(property, "-1")) { - FILE_STATUS_COLOR_MAP.put(allFileStatus, ColorKey.createColorKey("MT_" + allFileStatus.getId(), null)); + FILE_STATUS_COLOR_MAP.put(allFileStatus, ColorKey.createColorKey("MT_" + allFileStatus.getId())); continue; } @@ -66,7 +70,6 @@ public final class MTFileColors { FILE_STATUS_COLOR_MAP.put(allFileStatus, ColorKey.createColorKey("MT_" + allFileStatus.getId(), color)); } } - } private MTFileColors() { diff --git a/src/main/java/com/chrisrm/idea/themes/ArcDarkTheme.java b/src/main/java/com/chrisrm/idea/themes/ArcDarkTheme.java index c78e4b332..864cf9679 100644 --- a/src/main/java/com/chrisrm/idea/themes/ArcDarkTheme.java +++ b/src/main/java/com/chrisrm/idea/themes/ArcDarkTheme.java @@ -162,7 +162,6 @@ protected String[] getSecondBorderResources() { return new String[]{ "MenuBar.darcula.borderColor", "MenuBar.darcula.borderShadowColor", - "TabbedPane.highlight", "TabbedPane.selected", "TabbedPane.selectHighlight", "CheckBox.darcula.disabledBorderColor1", diff --git a/src/main/java/com/chrisrm/idea/themes/MonokaiTheme.java b/src/main/java/com/chrisrm/idea/themes/MonokaiTheme.java index e8a2968da..509c05928 100644 --- a/src/main/java/com/chrisrm/idea/themes/MonokaiTheme.java +++ b/src/main/java/com/chrisrm/idea/themes/MonokaiTheme.java @@ -162,7 +162,6 @@ protected String[] getSecondBorderResources() { return new String[] { "MenuBar.darcula.borderColor", "MenuBar.darcula.borderShadowColor", - "TabbedPane.highlight", "TabbedPane.selected", "TabbedPane.selectHighlight", "CheckBox.darcula.disabledBorderColor1", diff --git a/src/main/java/com/chrisrm/idea/themes/OneDarkTheme.java b/src/main/java/com/chrisrm/idea/themes/OneDarkTheme.java index 4ca9a649b..8bf102ab6 100644 --- a/src/main/java/com/chrisrm/idea/themes/OneDarkTheme.java +++ b/src/main/java/com/chrisrm/idea/themes/OneDarkTheme.java @@ -59,7 +59,7 @@ public String getDisabled() { @Override protected String getTreeSelectionColorString() { - return "3A3F4B50"; + return "3A3F4B80"; } @Override @@ -163,7 +163,6 @@ protected String[] getSecondBorderResources() { return new String[]{ "MenuBar.darcula.borderColor", "MenuBar.darcula.borderShadowColor", - "TabbedPane.highlight", "TabbedPane.selected", "TabbedPane.selectHighlight", "CheckBox.darcula.disabledBorderColor1", @@ -255,6 +254,7 @@ protected String[] getSelectionBackgroundResources() { "MenuItem.selectionBackground", "Autocomplete.selectionbackground", "TextField.selectionBackground", + "List.selectionBackground", "PasswordField.selectionBackground", "ComboBox.disabledForeground" }; diff --git a/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java b/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java index eb399fd81..efaf5dbda 100644 --- a/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java +++ b/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java @@ -126,7 +126,7 @@ private void colorFileStatus(final PresentationData data, final VirtualFile file final Color colorFromStatus = getColorFromStatus(status); final boolean isBoldTabs = MTConfig.getInstance().getIsBoldTabs(); if (file.isDirectory()) { - // data.setForcedTextForeground(ColorUtil.fromHex(MTConfig.getInstance().getAccentColor())); + data.setForcedTextForeground(MTFileColors.get(FileStatus.NOT_CHANGED)); if (isBoldTabs) { data.setAttributesKey(CodeInsightColors.BOOKMARKS_ATTRIBUTES); } diff --git a/src/main/java/com/chrisrm/idea/ui/MTRadioButtonUI.java b/src/main/java/com/chrisrm/idea/ui/MTRadioButtonUI.java index 5d9d5d957..d435bc322 100644 --- a/src/main/java/com/chrisrm/idea/ui/MTRadioButtonUI.java +++ b/src/main/java/com/chrisrm/idea/ui/MTRadioButtonUI.java @@ -25,22 +25,18 @@ */ package com.chrisrm.idea.ui; -import com.intellij.ide.ui.laf.darcula.DarculaUIUtil; import com.intellij.ide.ui.laf.darcula.ui.DarculaRadioButtonUI; import com.intellij.openapi.ui.GraphicsConfig; -import com.intellij.ui.ColorUtil; import com.intellij.ui.Gray; -import com.intellij.ui.JBGradientPaint; import com.intellij.util.ui.EmptyIcon; import com.intellij.util.ui.GraphicsUtil; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.UIUtil; import sun.swing.SwingUtilities2; import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicHTML; -import javax.swing.text.View; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; +import javax.swing.text.*; import java.awt.*; /** @@ -79,7 +75,6 @@ public synchronized void paint(final Graphics g2d, final JComponent c) { g.fillRect(0, 0, size.width, size.height); } - paintIcon(c, g, viewRect, iconRect); drawText(b, g, text, textRect, fm); } @@ -89,7 +84,10 @@ public Icon getDefaultIcon() { return JBUI.scale(EmptyIcon.create(20)).asUIResource(); } - protected void paintIcon(final JComponent c, final Graphics2D g, final Rectangle viewRect, final Rectangle iconRect) { + protected void paintIcon(final JComponent c, + final Graphics2D g, + final Rectangle viewRect, + final Rectangle iconRect) { Insets i = c.getInsets(); viewRect.x += i.left; viewRect.y += i.top; @@ -105,84 +103,74 @@ protected void paintIcon(final JComponent c, final Graphics2D g, final Rectangle final int h = iconRect.height - rad; g.translate(x, y); - //noinspection UseJBColor - final JBGradientPaint ijGradient = new JBGradientPaint(c, new Color(0x4985e4), new Color(0x4074c9)); //setup AA for lines final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); final boolean focus = c.hasFocus(); final boolean selected = ((AbstractButton) c).isSelected(); - if (UIUtil.isUnderDarcula() || !selected) { - g.setPaint(UIUtil.getGradientPaint(0, 0, ColorUtil.shift(c.getBackground(), 1.5), - 0, c.getHeight(), ColorUtil.shift(c.getBackground(), 1.2))); - } else { - g.setPaint(ijGradient); - } - if (!UIUtil.isUnderDarcula() && selected) { - final GraphicsConfig fillOvalConf = new GraphicsConfig(g); - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); - g.fillOval(0, JBUI.scale(1), w, h); - fillOvalConf.restore(); - } else { - if (focus) { - g.fillOval(0, JBUI.scale(1), w, h); - } else { - g.fillOval(0, JBUI.scale(1), w - JBUI.scale(1), h - JBUI.scale(1)); - } - } + // paint focus oval ripple if (focus) { - if (JBUI.isPixHiDPI(c)) { - DarculaUIUtil.paintFocusOval(g, JBUI.scale(1), JBUI.scale(1) + 1, w - JBUI.scale(2), h - JBUI.scale(2)); - } else { - DarculaUIUtil.paintFocusOval(g, 0, JBUI.scale(1), w, h); - } - } else { - if (UIUtil.isUnderDarcula()) { - g.setPaint(UIUtil.getGradientPaint(w / 2, 1, Gray._160.withAlpha(90), w / 2, h, Gray._100.withAlpha(90))); - g.drawOval(0, JBUI.scale(1) + 1, w - 1, h - 1); - - g.setPaint(Gray._40.withAlpha(200)); - g.drawOval(0, JBUI.scale(1), w - 1, h - 1); - } else { - g.setPaint(selected ? ijGradient : c.isEnabled() ? Gray._30 : Gray._130); - if (!selected) { - g.drawOval(0, JBUI.scale(1), w - 1, h - 1); - } - } + paintOvalRing(g, w, h); } + // paint border + g.setPaint(Gray._160.withAlpha(90)); + g.drawOval(JBUI.scale(2), JBUI.scale(1) + 1, w - 1, h - 1); + g.setPaint(Gray._40.withAlpha(200)); + g.drawOval(JBUI.scale(2), JBUI.scale(1), w - 1, h - 1); + if (selected) { final boolean enabled = c.isEnabled(); - g.setColor(UIManager.getColor(enabled ? "RadioButton.darcula.selectionEnabledShadowColor" : "RadioButton.darcula" + - ".selectionDisabledShadowColor")); // ? Gray._30 : Gray._60); - final int yOff = 1 + JBUI.scale(1); - g.fillOval(w / 2 - rad / 2, h / 2 - rad / 2 + yOff, rad, rad); - g.setColor(UIManager.getColor(enabled ? "RadioButton.darcula.selectionEnabledColor" : "RadioButton.darcula" + - ".selectionDisabledColor")); //Gray._170 : Gray._120); - g.fillOval(w / 2 - rad / 2, h / 2 - rad / 2 - 1 + yOff, rad, rad); + g.setColor(UIManager.getColor(enabled ? + "RadioButton.darcula.selectionEnabledShadowColor" : + "RadioButton.darcula.selectionDisabledShadowColor")); // ? Gray._30 : Gray._60); + + // draw outer border + g.drawOval(JBUI.scale(2), JBUI.scale(1), w - 1, h - 1); + + // draw dot + int xOff = JBUI.scale(2); + final int yOff = JBUI.scale(1); + g.fillOval(w / 2 - rad / 2, h / 2 - rad / 2 - yOff, rad + JBUI.scale(4), rad + JBUI.scale(4)); + + // g.setColor(UIManager.getColor(enabled ? + // "RadioButton.darcula.selectionEnabledColor" : + // "RadioButton.darcula.selectionDisabledColor")); //Gray._170 : Gray._120); + // g.fillOval(w / 2 - rad / 2, h / 2 - rad / 2 - 1 + yOff, rad, rad); } config.restore(); g.translate(-x, -y); } + protected Color getFocusColor() { + return UIManager.getColor("Focus.color"); + } + + private void paintOvalRing(Graphics2D g, int w, int h) { + g.setColor(UIManager.getColor("Focus.color")); + g.fillOval(-JBUI.scale(2), -3, w + 8, h + 8); + } + protected void drawText(final AbstractButton b, final Graphics2D g, final String text, final Rectangle textRect, final FontMetrics fm) { // Draw the Text if (text != null) { View v = (View) b.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g, textRect); - } else { + } + else { int mnemIndex = b.getDisplayedMnemonicIndex(); if (b.isEnabled()) { // *** paint the text normally g.setColor(b.getForeground()); - } else { + } + else { // *** paint the text disabled g.setColor(getDisabledTextColor()); } SwingUtilities2.drawStringUnderlineCharAt(b, g, text, - mnemIndex, textRect.x, textRect.y + fm.getAscent()); + mnemIndex, textRect.x, textRect.y + fm.getAscent()); } } diff --git a/src/main/java/com/chrisrm/idea/ui/MTSliderUI.java b/src/main/java/com/chrisrm/idea/ui/MTSliderUI.java new file mode 100644 index 000000000..e579cbe8a --- /dev/null +++ b/src/main/java/com/chrisrm/idea/ui/MTSliderUI.java @@ -0,0 +1,491 @@ +package com.chrisrm.idea.ui; + +import com.chrisrm.idea.utils.MTUiUtils; +import com.intellij.openapi.ui.GraphicsConfig; +import com.intellij.util.ObjectUtils; +import com.intellij.util.ui.GraphicsUtil; +import com.intellij.util.ui.JBUI; + +import javax.swing.*; +import javax.swing.plaf.*; +import javax.swing.plaf.metal.*; +import java.awt.*; + +public final class MTSliderUI extends MetalSliderUI { + + protected final int TICK_BUFFER = 4; + protected boolean filledSlider = false; + // NOTE: these next five variables are currently unused. + protected static Color thumbColor; + protected static Color highlightColor; + protected static Color darkShadowColor; + protected static int trackWidth; + protected static int tickLength; + private int safeLength; + + public static ComponentUI createUI(JComponent c) { + return new MTSliderUI(); + } + + public void installUI(JComponent c) { + fixMacSlider(); + super.installUI(c); + + trackWidth = (Integer) ObjectUtils.notNull(UIManager.get("Slider.trackWidth"), 7); + tickLength = safeLength = (Integer) ObjectUtils.notNull(UIManager.get("Slider.majorTickLength"), 6); + + thumbColor = getThumbColor(); + highlightColor = getSliderHighlightColor(); + darkShadowColor = getDarkShadowColor(); + + scrollListener.setScrollByBlock(false); + + filledSlider = true; + } + + private void fixMacSlider() { + UIManager.put("Slider.trackWidth", 7); + UIManager.put("Slider.majorTickLength", 6); + UIManager.put("Slider.horizontalThumbIcon", null); + UIManager.put("Slider.verticalThumbIcon", null); + } + + public void paintThumb(Graphics g) { + Rectangle knobBounds = thumbRect; + final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); + + g.setColor(getThumbColor()); + g.translate(knobBounds.x, knobBounds.y); + // getVertThumbIcon().paintIcon(slider, g, 0, 0); + g.fillOval(0, 0, knobBounds.width, knobBounds.height); + g.translate(-knobBounds.x, -knobBounds.y); + config.restore(); + } + + private Color getThumbColor() { + return MTUiUtils.getColor(UIManager.getColor("Slider.thumb"), + MetalLookAndFeel.getControlShadow(), + MetalLookAndFeel.getControlShadow()); + } + + private Color getTrackColor() { + return MTUiUtils.getColor(UIManager.getColor("Slider.track"), + MetalLookAndFeel.getControlHighlight(), + MetalLookAndFeel.getControlHighlight()); + } + + private Color getTrackDisabledColor() { + return MTUiUtils.getColor(UIManager.getColor("Slider.trackDisabled"), + MetalLookAndFeel.getControlShadow(), + MetalLookAndFeel.getControlShadow()); + } + + private Color getSliderHighlightColor() { + return MTUiUtils.getColor(UIManager.getColor("Slider.highlight"), + MetalLookAndFeel.getControlHighlight(), + MetalLookAndFeel.getControlHighlight()); + } + + private Color getDarkShadowColor() { + return MTUiUtils.getColor(UIManager.getColor("Slider.darkShadow"), + MetalLookAndFeel.getControlDarkShadow(), + MetalLookAndFeel.getControlDarkShadow()); + } + + /** + * Returns a rectangle enclosing the track that will be painted. + */ + private Rectangle getPaintTrackRect() { + int trackLeft = 0, + trackRight, + trackTop = 0, + trackBottom; + + if (slider.getOrientation() == JSlider.HORIZONTAL) { + trackBottom = (trackRect.height - 1) - getThumbOverhang(); + trackTop = trackBottom - (getTrackWidth() - 1); + trackRight = trackRect.width - 1; + } + else { + if (isLeftToRight(slider)) { + trackLeft = (trackRect.width - getThumbOverhang()) - + getTrackWidth(); + trackRight = (trackRect.width - getThumbOverhang()) - 1; + } + else { + trackLeft = getThumbOverhang(); + trackRight = getThumbOverhang() + getTrackWidth() - 1; + } + trackBottom = trackRect.height - 1; + } + return new Rectangle(trackRect.x + trackLeft, trackRect.y + trackTop, + trackRight - trackLeft, trackBottom - trackTop); + } + + private boolean isLeftToRight(Component c) { + return c.getComponentOrientation().isLeftToRight(); + } + + public void paintTrack(Graphics g) { + boolean leftToRight = isLeftToRight(slider); + + g.translate(trackRect.x, trackRect.y); + + int trackLeft = 0; + int trackTop = 0; + int trackRight; + int trackBottom; + + // Draw the track + if (slider.getOrientation() == JSlider.HORIZONTAL) { + trackBottom = (trackRect.height - 1) - getThumbOverhang(); + trackTop = trackBottom - (getTrackWidth() - 1); + trackRight = trackRect.width - 1; + } + else { + if (leftToRight) { + trackLeft = (trackRect.width - getThumbOverhang()) - + getTrackWidth(); + trackRight = (trackRect.width - getThumbOverhang()) - 1; + } + else { + trackLeft = getThumbOverhang(); + trackRight = getThumbOverhang() + getTrackWidth() - 1; + } + trackBottom = trackRect.height - 1; + } + + if (slider.isEnabled()) { + g.setColor(getTrackColor()); + g.fillRect(trackLeft, trackTop, + (trackRight - trackLeft) - 1, (trackBottom - trackTop) - 1); + + // g.setColor(Color.RED); + // g.drawLine(trackLeft + 1, trackBottom, trackRight, trackBottom); + // g.drawLine(trackRight, trackTop + 1, trackRight, trackBottom); + // + // g.setColor(Color.BLUE); + // g.drawLine(trackLeft + 1, trackTop + 1, trackRight - 2, trackTop + 1); + // g.drawLine(trackLeft + 1, trackTop + 1, trackLeft + 1, trackBottom - 2); + } + else { + g.setColor(getTrackDisabledColor()); + g.fillRect(trackLeft, trackTop, + (trackRight - trackLeft) - 1, (trackBottom - trackTop) - 1); + } + + // Draw the fill + if (filledSlider) { + int middleOfThumb; + int fillTop; + int fillLeft; + int fillBottom; + int fillRight; + + if (slider.getOrientation() == JSlider.HORIZONTAL) { + middleOfThumb = thumbRect.x + (thumbRect.width / 2); + middleOfThumb -= trackRect.x; // To compensate for the g.translate() + fillTop = !slider.isEnabled() ? trackTop : trackTop; + fillBottom = !slider.isEnabled() ? trackBottom - 1 : trackBottom - 1; + + if (!drawInverted()) { + fillLeft = !slider.isEnabled() ? trackLeft : trackLeft; + fillRight = middleOfThumb; + } + else { + fillLeft = middleOfThumb; + fillRight = !slider.isEnabled() ? trackRight - 1 : trackRight - 1; + } + } + else { + middleOfThumb = thumbRect.y + (thumbRect.height / 2); + middleOfThumb -= trackRect.y; // To compensate for the g.translate() + fillLeft = !slider.isEnabled() ? trackLeft : trackLeft; + fillRight = !slider.isEnabled() ? trackRight - 1 : trackRight - 1; + + if (!drawInverted()) { + fillTop = middleOfThumb; + fillBottom = !slider.isEnabled() ? trackBottom - 1 : trackBottom - 1; + } + else { + fillTop = !slider.isEnabled() ? trackTop : trackTop; + fillBottom = middleOfThumb; + } + } + + if (slider.isEnabled()) { + g.setColor(slider.getBackground()); + g.drawLine(fillLeft, fillTop, fillRight, fillTop); + g.drawLine(fillLeft, fillTop, fillLeft, fillBottom); + + g.setColor(getThumbColor()); + g.fillRect(fillLeft, fillTop, + fillRight - fillLeft, fillBottom - fillTop); + } + else { + g.setColor(MetalLookAndFeel.getControlShadow()); + g.fillRect(fillLeft, fillTop, fillRight - fillLeft, fillBottom - fillTop); + } + } + + g.translate(-trackRect.x, -trackRect.y); + } + + private void oceanPaintTrack(Graphics g) { + boolean leftToRight = isLeftToRight(slider); + boolean drawInverted = drawInverted(); + Color sliderAltTrackColor = (Color) UIManager.get( + "Slider.altTrackColor"); + + // Translate to the origin of the painting rectangle + Rectangle paintRect = getPaintTrackRect(); + g.translate(paintRect.x, paintRect.y); + + // Width and height of the painting rectangle. + int w = paintRect.width; + int h = paintRect.height; + + if (slider.getOrientation() == JSlider.HORIZONTAL) { + int middleOfThumb = thumbRect.x + thumbRect.width / 2 - paintRect.x; + + if (slider.isEnabled()) { + int fillMinX; + int fillMaxX; + + if (middleOfThumb > 0) { + g.setColor(drawInverted ? MetalLookAndFeel.getControlDarkShadow() : + MetalLookAndFeel.getPrimaryControlDarkShadow()); + + g.drawRect(0, 0, middleOfThumb - 1, h - 1); + } + + if (middleOfThumb < w) { + g.setColor(drawInverted ? MetalLookAndFeel.getPrimaryControlDarkShadow() : + MetalLookAndFeel.getControlDarkShadow()); + + g.drawRect(middleOfThumb, 0, w - middleOfThumb - 1, h - 1); + } + + if (filledSlider) { + g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); + if (drawInverted) { + fillMinX = middleOfThumb; + fillMaxX = w - 2; + g.drawLine(1, 1, middleOfThumb, 1); + } + else { + fillMinX = 1; + fillMaxX = middleOfThumb; + g.drawLine(middleOfThumb, 1, w - 1, 1); + } + if (h == 6) { + g.setColor(MetalLookAndFeel.getWhite()); + g.drawLine(fillMinX, 1, fillMaxX, 1); + g.setColor(sliderAltTrackColor); + g.drawLine(fillMinX, 2, fillMaxX, 2); + g.setColor(MetalLookAndFeel.getControlShadow()); + g.drawLine(fillMinX, 3, fillMaxX, 3); + g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); + g.drawLine(fillMinX, 4, fillMaxX, 4); + } + } + } + else { + g.setColor(MetalLookAndFeel.getControlShadow()); + + if (middleOfThumb > 0) { + if (!drawInverted && filledSlider) { + g.fillRect(0, 0, middleOfThumb - 1, h - 1); + } + else { + g.drawRect(0, 0, middleOfThumb - 1, h - 1); + } + } + + if (middleOfThumb < w) { + if (drawInverted && filledSlider) { + g.fillRect(middleOfThumb, 0, w - middleOfThumb - 1, h - 1); + } + else { + g.drawRect(middleOfThumb, 0, w - middleOfThumb - 1, h - 1); + } + } + } + } + else { + int middleOfThumb = thumbRect.y + (thumbRect.height / 2) - paintRect.y; + + if (slider.isEnabled()) { + int fillMinY; + int fillMaxY; + + if (middleOfThumb > 0) { + g.setColor(drawInverted ? MetalLookAndFeel.getPrimaryControlDarkShadow() : + MetalLookAndFeel.getControlDarkShadow()); + + g.drawRect(0, 0, w - 1, middleOfThumb - 1); + } + + if (middleOfThumb < h) { + g.setColor(drawInverted ? MetalLookAndFeel.getControlDarkShadow() : + MetalLookAndFeel.getPrimaryControlDarkShadow()); + + g.drawRect(0, middleOfThumb, w - 1, h - middleOfThumb - 1); + } + + if (filledSlider) { + g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); + if (drawInverted()) { + fillMinY = 1; + fillMaxY = middleOfThumb; + if (leftToRight) { + g.drawLine(1, middleOfThumb, 1, h - 1); + } + else { + g.drawLine(w - 2, middleOfThumb, w - 2, h - 1); + } + } + else { + fillMinY = middleOfThumb; + fillMaxY = h - 2; + if (leftToRight) { + g.drawLine(1, 1, 1, middleOfThumb); + } + else { + g.drawLine(w - 2, 1, w - 2, middleOfThumb); + } + } + if (w == 6) { + g.setColor(leftToRight ? MetalLookAndFeel.getWhite() : MetalLookAndFeel.getPrimaryControlShadow()); + g.drawLine(1, fillMinY, 1, fillMaxY); + g.setColor(leftToRight ? sliderAltTrackColor : MetalLookAndFeel.getControlShadow()); + g.drawLine(2, fillMinY, 2, fillMaxY); + g.setColor(leftToRight ? MetalLookAndFeel.getControlShadow() : sliderAltTrackColor); + g.drawLine(3, fillMinY, 3, fillMaxY); + g.setColor(leftToRight ? MetalLookAndFeel.getPrimaryControlShadow() : MetalLookAndFeel.getWhite()); + g.drawLine(4, fillMinY, 4, fillMaxY); + } + } + } + else { + g.setColor(MetalLookAndFeel.getControlShadow()); + + if (middleOfThumb > 0) { + if (drawInverted && filledSlider) { + g.fillRect(0, 0, w - 1, middleOfThumb - 1); + } + else { + g.drawRect(0, 0, w - 1, middleOfThumb - 1); + } + } + + if (middleOfThumb < h) { + if (!drawInverted && filledSlider) { + g.fillRect(0, middleOfThumb, w - 1, h - middleOfThumb - 1); + } + else { + g.drawRect(0, middleOfThumb, w - 1, h - middleOfThumb - 1); + } + } + } + } + + g.translate(-paintRect.x, -paintRect.y); + } + + protected Dimension getThumbSize() { + Dimension size = new Dimension(); + + if (slider.getOrientation() == JSlider.VERTICAL) { + size.width = JBUI.scale(16); + size.height = JBUI.scale(16); + } + else { + size.width = JBUI.scale(16); + size.height = JBUI.scale(16); + } + + return size; + } + + /** + * Gets the height of the tick area for horizontal sliders and the width of the + * tick area for vertical sliders. BasicSliderUI uses the returned value to + * determine the tick area rectangle. + */ + public int getTickLength() { + return 0; + } + + /** + * Returns the shorter dimension of the track. + */ + protected int getTrackWidth() { + // This strange calculation is here to keep the + // track in proportion to the thumb. + final double kIdealTrackWidth = 7.0; + final double kIdealThumbHeight = 16.0; + final double kWidthScalar = kIdealTrackWidth / kIdealThumbHeight; + + if (slider.getOrientation() == JSlider.HORIZONTAL) { + return (int) (kWidthScalar * thumbRect.height); + } + else { + return (int) (kWidthScalar * thumbRect.width); + } + } + + /** + * Returns the longer dimension of the slide bar. (The slide bar is only the + * part that runs directly under the thumb) + */ + protected int getTrackLength() { + if (slider.getOrientation() == JSlider.HORIZONTAL) { + return trackRect.width; + } + return trackRect.height; + } + + /** + * Returns the amount that the thumb goes past the slide bar. + */ + protected int getThumbOverhang() { + return (int) (getThumbSize().getHeight() - getTrackWidth()) / 2; + } + + protected void scrollDueToClickInTrack(int dir) { + scrollByUnit(dir); + } + + protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) { + g.setColor(slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow()); + g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + (safeLength / 2)); + } + + protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) { + g.setColor(slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow()); + g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + (safeLength - 1)); + } + + protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) { + g.setColor(slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow()); + + if (isLeftToRight(slider)) { + g.drawLine(TICK_BUFFER, y, TICK_BUFFER + (safeLength / 2), y); + } + else { + g.drawLine(0, y, safeLength / 2, y); + } + } + + protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) { + g.setColor(slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow()); + + if (isLeftToRight(slider)) { + g.drawLine(TICK_BUFFER, y, TICK_BUFFER + safeLength, y); + } + else { + g.drawLine(0, y, safeLength, y); + } + } +} diff --git a/src/main/java/com/chrisrm/idea/utils/UIReplacer.java b/src/main/java/com/chrisrm/idea/utils/UIReplacer.java index f15607483..5967f4f4c 100644 --- a/src/main/java/com/chrisrm/idea/utils/UIReplacer.java +++ b/src/main/java/com/chrisrm/idea/utils/UIReplacer.java @@ -34,6 +34,7 @@ import com.intellij.ide.ui.laf.darcula.DarculaUIUtil; import com.intellij.lang.parameterInfo.ParameterInfoUIContextEx; import com.intellij.notification.impl.NotificationsManagerImpl; +import com.intellij.openapi.actionSystem.impl.IdeaActionButtonLook; import com.intellij.openapi.options.newEditor.SettingsTreeView; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.wm.impl.status.MemoryUsagePanel; @@ -47,7 +48,7 @@ import com.intellij.vcs.log.ui.highlighters.MergeCommitsHighlighter; import javax.swing.*; -import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.*; import java.awt.*; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -71,7 +72,8 @@ public static void patchUI() { Patcher.patchScrollbars(); Patcher.patchDialogs(); Patcher.patchVCS(); - } catch (final Exception e) { + } + catch (final Exception e) { e.printStackTrace(); } } @@ -120,12 +122,19 @@ static void patchPanels() throws Exception { final Field[] fields = DarculaUIUtil.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) - .filter(f -> f.getType().equals(JBColor.class)) - .toArray(); + .filter(f -> f.getType().equals(JBColor.class)) + .toArray(); final Color accentColor = ColorUtil.fromHex(MTConfig.getInstance().getAccentColor()); final JBColor accentJBColor = new JBColor(accentColor, accentColor); StaticPatcher.setFinalStatic((Field) objects[0], accentJBColor); StaticPatcher.setFinalStatic((Field) objects[1], accentJBColor); + + final Field[] fields2 = IdeaActionButtonLook.class.getDeclaredFields(); + final Object[] objects2 = Arrays.stream(fields2) + .filter(f -> f.getType().equals(Color.class)) + .toArray(); + + StaticPatcher.setFinalStatic((Field) objects2[1], accentJBColor); } static void patchMemoryIndicator() throws Exception { @@ -141,8 +150,8 @@ static void patchMemoryIndicator() throws Exception { final Field[] fields = MemoryUsagePanel.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) - .filter(f -> f.getType().equals(Color.class)) - .toArray(); + .filter(f -> f.getType().equals(Color.class)) + .toArray(); StaticPatcher.setFinalStatic((Field) objects[0], usedColor); StaticPatcher.setFinalStatic((Field) objects[1], unusedColor); } @@ -153,8 +162,8 @@ static void patchQuickInfo() throws Exception { final Field[] fields = ParameterInfoComponent.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) - .filter(f -> f.getType().equals(Map.class)) - .toArray(); + .filter(f -> f.getType().equals(Map.class)) + .toArray(); StaticPatcher.setFinalStatic((Field) objects[0], ImmutableMap.of( ParameterInfoUIContextEx.Flag.HIGHLIGHT, "b color=" + accentColor, @@ -171,8 +180,8 @@ static void patchAutocomplete() throws Exception { final Field[] fields = LookupCellRenderer.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) - .filter(f -> f.getType().equals(Color.class)) - .toArray(); + .filter(f -> f.getType().equals(Color.class)) + .toArray(); // SELECTED BACKGROUND COLOR StaticPatcher.setFinalStatic((Field) objects[3], backgroundSelectedColor); @@ -183,7 +192,6 @@ static void patchAutocomplete() throws Exception { StaticPatcher.setFinalStatic((Field) objects[7], jbAccentColor); // Selected completion foregronud color StaticPatcher.setFinalStatic((Field) objects[8], jbAccentColor); - } static void patchNotifications() throws Exception { @@ -217,7 +225,6 @@ private static void replaceToolBalloons() throws Exception { final Color warnBackground = UIManager.getColor("Notifications.warnBackground"); final Color infoBackground = UIManager.getColor("Notifications.infoBackground"); - final MessageType errorType = declaredConstructor.newInstance( AllIcons.General.NotificationError, errorBackground, @@ -232,7 +239,6 @@ private static void replaceToolBalloons() throws Exception { infoBackground, infoBackground); - StaticPatcher.setFinalStatic(MessageType.class, "ERROR", errorType); StaticPatcher.setFinalStatic(MessageType.class, "INFO", infoType); StaticPatcher.setFinalStatic(MessageType.class, "WARNING", warnType); @@ -268,7 +274,6 @@ static void patchScrollbars() throws Exception { final Color alphaGray = gray.withAlpha(60); StaticPatcher.setFinalStatic(Gray.class, "xA6", alphaGray); StaticPatcher.setFinalStatic(Gray.class, "x00", alphaGray); - } public static void patchVCS() throws Exception { @@ -278,22 +283,20 @@ public static void patchVCS() throws Exception { final Field[] fields = CurrentBranchHighlighter.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) - .filter(f -> f.getType().equals(JBColor.class)) - .toArray(); + .filter(f -> f.getType().equals(JBColor.class)) + .toArray(); StaticPatcher.setFinalStatic((Field) objects[0], commitsColor); } final Field[] fields2 = MergeCommitsHighlighter.class.getDeclaredFields(); final Object[] objects2 = Arrays.stream(fields2) - .filter(f -> f.getType().equals(JBColor.class)) - .toArray(); + .filter(f -> f.getType().equals(JBColor.class)) + .toArray(); Color accentColor = ColorUtil.fromHex(MTConfig.getInstance().getAccentColor()); Color mergeCommitsColor = new JBColor(accentColor, accentColor); StaticPatcher.setFinalStatic((Field) objects2[0], mergeCommitsColor); - } } - } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 8782e0b18..5b79ab1ec 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -25,21 +25,19 @@ --> - com.chrisrm.idea.MaterialThemeUI - Material Theme UI - 0.10.3 - Hirvi AS - - - - + com.chrisrm.idea.MaterialThemeUIFork + Material Theme UI EAP + 0.12.0.3 + Mallowigi Material Theme look to your IDE.

]]>
- + + + com.intellij.modules.platform com.intellij.modules.lang @@ -138,7 +136,7 @@ text="Lighter Theme" description="Material Theme - Lighter" icon="/icons/actions/themes/material_lighter.png"> - + @@ -339,6 +337,34 @@ +

0.12.0

+
    +
  • New components: Radio Buttons and Sliders
  • +
+

0.11.0

+
    +
  • Targeting 2017.3 EAP
  • +
+

0.10.6

+
    +
  • Set default color for "NOT CHANGED" file status
  • +
  • Set directories color from "Up to date" file status
  • +
  • Fix issue with Run Configurations
  • +
+

0.10.5

+
    +
  • Fix bugs related to 2017.3 EAP
  • +
+

0.10.4

+
    +
  • Fix Tabbed Pane color in Arc and One Dark
  • + +
  • Fix background color of list selected items in One Dark
  • + +
  • Add babelrc.json to babel icon association
  • + +
  • Fix (hopefully) the NullPointerException due to not being recognized File Colors
  • +

0.10.3

  • Material One Dark Color Scheme
  • diff --git a/src/main/resources/colors/Material Theme - Darker.xml b/src/main/resources/colors/Material Theme - Darker.xml index 905940bb0..46f870e7d 100644 --- a/src/main/resources/colors/Material Theme - Darker.xml +++ b/src/main/resources/colors/Material Theme - Darker.xml @@ -24,7 +24,7 @@ ~ --> - +