diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index c855c7b36..6e33f17db 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -40,12 +40,12 @@ jobs: name: macOS (Java 11) runs-on: macos-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 10 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Build - run: ./gradlew build + - uses: actions/checkout@v2 + with: + fetch-depth: 10 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Build + run: ./gradlew build diff --git a/core/build.gradle.kts b/core/build.gradle.kts index d9c498f24..d7dce84ec 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -35,6 +35,22 @@ tasks.jar { } } +project.properties + .filter { it.key.startsWith("demoClass") } + .forEach { + val name = it.key.split(".")[1] + rootProject.tasks.register(name, JavaExec::class) { + group = "Demo" + description = "Run the demo '$name'." + dependsOn(tasks.testClasses) + + workingDir = File(project.rootDir, "build") + workingDir.mkdirs() + main = it.value?.toString() ?: throw GradleException("Main class for demo ``$name` not specified.") + classpath(sourceSets.main.get().runtimeClasspath, sourceSets.test.get().runtimeClasspath) + } + } + val makeDocumentation by tasks.registering(JavaExec::class) { group = "Development" description = "Builds the documentation" diff --git a/core/gradle.properties b/core/gradle.properties index 5af255f08..ceddb1fbd 100644 --- a/core/gradle.properties +++ b/core/gradle.properties @@ -1 +1,41 @@ -generatePomFile = true +generatePomFile = true + +demoClass.UIManagerDefaults = defaults.UIManagerDefaults +demoClass.AllIcons = icon.AllIcons +demoClass.IconDemo = icon.IconDemo +demoClass.RotatableIconDemo = icon.RotatableIconDemo +demoClass.ButtonDemo = ui.button.ButtonDemo +demoClass.GroupedButtonDemo = ui.button.GroupedButtonDemo +demoClass.ToggleButtonDemo = ui.button.ToggleButtonDemo +demoClass.CheckBoxDemo = ui.checkBox.CheckBoxDemo +demoClass.TriCheckBoxDemo = ui.checkBox.TriCheckBoxDemo +demoClass.ColorChooserDemo = ui.colorChooser.ColorChooserDemo +demoClass.ComboBoxDemo = ui.comboBox.ComboBoxDemo +demoClass.DialogDemo = ui.dialog.DialogDemo +demoClass.FileChooserDemo = ui.fileChooser.FileChooserDemo +demoClass.InternalFrameDemo = ui.internalFrame.InternalFrameDemo +demoClass.LabelDemo = ui.label.LabelDemo +demoClass.ListDemo = ui.list.ListDemo +demoClass.PopupMenuDemo = ui.popupMenu.PopupMenuDemo +demoClass.ProgressBarDemo = ui.progressBar.ProgressBarDemo +demoClass.RadioButtonDemo = ui.radioButton.RadioButtonDemo +demoClass.ScrollPaneDemo = ui.scrollPane.ScrollPaneDemo +demoClass.OverlayScrollPaneDemo = ui.scrollPane.OverlayScrollPaneDemo +demoClass.SliderDemo = ui.slider.SliderDemo +demoClass.SpinnerDemo = ui.spinner.SpinnerDemo +demoClass.SplitPaneDemo = ui.splitPane.SplitPaneDemo +demoClass.TabbedPaneDemo = ui.tabbedPane.TabbedPaneDemo +demoClass.TabbedPaneKeyboardShortcutDemo = ui.tabbedPane.TabbedPaneKeyboardShortcut +demoClass.ClosableTabbedPaneDemo = ui.tabbedPane.ClosableTabbedPaneDemo +demoClass.TabFrameDemo = ui.tabFrame.TabFrameDemo +demoClass.TableDemo = ui.table.TableDemo +demoClass.EditorPaneDemo = ui.text.EditorPaneDemo +demoClass.FormattedTextFieldDemo = ui.text.FormattedTextFieldDemo +demoClass.PasswordFieldDemo = ui.text.PasswordFieldDemo +demoClass.TextAreaDemo = ui.text.TextAreaDemo +demoClass.TextFieldDemo = ui.text.TextFieldDemo +demoClass.TextPaneDemo = ui.text.TextPaneDemo +demoClass.ToolBarDemo = ui.toolBar.ToolBarDemo +demoClass.ToolTipDemo = ui.toolTip.ToolTipDemo +demoClass.TreeDemo = ui.tree.TreeDemo +demoClass.PreferenceChangeDemo = PreferenceChangeDemo diff --git a/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java b/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java index 308a4dd42..1be0a09aa 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java @@ -30,6 +30,7 @@ import com.github.weisj.darklaf.util.Pair; import javax.swing.*; +import javax.swing.plaf.ColorUIResource; import java.awt.*; import java.util.List; import java.util.Properties; @@ -108,9 +109,10 @@ private ColorInfo getColorInfo(final Object o, final ColorInfo info) { private Object mapColor(final ColorInfo info, final double[] hsbMatch, final Properties properties) { Object obj = properties.get(info.key); if (obj instanceof Color) { - return DarkColorModelHSB.getColorFromHSBValues(hsbMatch[0] * (info.hAdj / 100.0), - hsbMatch[1] * (info.sAdj / 100.0), - hsbMatch[2] * (info.bAdj / 100.0)); + Color color = DarkColorModelHSB.getColorFromHSBValues(hsbMatch[0] * (info.hAdj / 100.0), + hsbMatch[1] * (info.sAdj / 100.0), + hsbMatch[2] * (info.bAdj / 100.0)); + return new ColorUIResource(color); } return obj; } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java index e34f8c998..b309128ba 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java @@ -111,7 +111,6 @@ public static void paintOutlineBorder(final Graphics2D g, final int width, final private static void doPaint(final Graphics2D g, final int width, final int height, final float arc, final float bw) { GraphicsContext context = GraphicsUtil.setupStrokePainting(g); - Shape outerRect = new RoundRectangle2D.Float(0, 0, width, height, arc + bw, arc + bw); Shape innerRect = new RoundRectangle2D.Float(bw, bw, width - 2 * bw, height - 2 * bw, arc - bw, arc - bw); Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD); @@ -183,11 +182,12 @@ public static void paintLineBorder(final Graphics2D g, final float x, final floa final boolean growByStroke) { GraphicsContext config = GraphicsUtil.setupStrokePainting(g); Stroke stroke = g.getStroke(); - float lw = stroke instanceof BasicStroke ? ((BasicStroke) stroke).getLineWidth() : 1; + float lw = stroke instanceof BasicStroke ? ((BasicStroke) stroke).getLineWidth() : 1f; + lw /= 2; if (growByStroke) { g.draw(new RoundRectangle2D.Float(x - lw, y - lw, width + lw, height + lw, arc, arc)); } else { - g.draw(new RoundRectangle2D.Float(x, y, width, height, arc, arc)); + g.draw(new RoundRectangle2D.Float(x, y, width - lw, height - lw, arc - 3, arc - 3)); } config.restore(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java index e5caa742e..092100122 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java @@ -23,7 +23,6 @@ */ package com.github.weisj.darklaf.util; -import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; @@ -63,11 +62,33 @@ public static Image createDragImage(final Component c, final Rectangle bounds, * @param bounds the bounds inside the component to capture. * @return image containing the captured area. */ + public static BufferedImage imageFromComponent(final Component c, final Rectangle bounds) { + return scaledImageFromComponent(c, bounds, 1.0, 1.0, true); + } - public static Image scaledImageFromComponent(final Component c, final Rectangle bounds) { - return scaledImageFromComponent(c, bounds, Scale.SCALE_X, Scale.SCALE_Y); + /** + * Create image from component. + * + * @param c the component. + * @param bounds the bounds inside the component to capture. + * @return image containing the captured area. + */ + public static BufferedImage imageFromComponent(final Component c, final Rectangle bounds, final boolean print) { + return scaledImageFromComponent(c, bounds, 1.0, 1.0, print); } + /** + * Create image from component. + * + * @param c the component. + * @param bounds the bounds inside the component to capture. + * @return image containing the captured area. + */ + public static BufferedImage scaledImageFromComponent(final Component c, final Rectangle bounds) { + return scaledImageFromComponent(c, bounds, Scale.SCALE_X, Scale.SCALE_Y, true); + } + + /** * Create image from component. * @@ -77,9 +98,9 @@ public static Image scaledImageFromComponent(final Component c, final Rectangle * @param scaley the y scale * @return image containing the captured area. */ - - public static Image scaledImageFromComponent(final Component c, final Rectangle bounds, - final double scalex, final double scaley) { + public static BufferedImage scaledImageFromComponent(final Component c, final Rectangle bounds, + final double scalex, final double scaley, + final boolean print) { BufferedImage image; boolean scale = scalex != 1.0 || scaley != 1.0; if (scale) { @@ -93,87 +114,16 @@ public static Image scaledImageFromComponent(final Component c, final Rectangle g2d.scale(scalex, scaley); } g2d.translate(-bounds.x, -bounds.y); - c.printAll(g2d); - - g2d.dispose(); - return image; - } - - /** - * Create image from component. - * - * @param c the component. - * @param bounds the bounds inside the component to capture. - * @return image containing the captured area. - */ - - public static Image imageFromComponent(final Component c, final Rectangle bounds) { - return scaledImageFromComponent(c, bounds, 1.0, 1.0); - } - - - public static Icon cropIcon(final Icon icon, int maxWidth, int maxHeight) { - if (icon.getIconHeight() <= maxHeight && icon.getIconWidth() <= maxWidth) { - return icon; - } - - Image image = toImage(icon); - if (image == null) return icon; - - double scale = 1f; - BufferedImage bi = ImageUtil.toBufferedImage(image); - final Graphics2D g = bi.createGraphics(); - - int imageWidth = image.getWidth(null); - int imageHeight = image.getHeight(null); - - maxWidth = maxWidth == Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) Math.round(maxWidth * scale); - maxHeight = maxHeight == Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) Math.round(maxHeight * scale); - final int w = Math.min(imageWidth, maxWidth); - final int h = Math.min(imageHeight, maxHeight); - - final BufferedImage img = new BufferedImage(w, h, Transparency.TRANSLUCENT); - final int offX = imageWidth > maxWidth ? (imageWidth - maxWidth) / 2 : 0; - final int offY = imageHeight > maxHeight ? (imageHeight - maxHeight) / 2 : 0; - for (int col = 0; col < w; col++) { - for (int row = 0; row < h; row++) { - img.setRGB(col, row, bi.getRGB(col + offX, row + offY)); - } - } - g.dispose(); - return new ImageIcon(img); - } - - public static Image toImage(final Icon icon) { - if (icon instanceof ImageIcon) { - return ((ImageIcon) icon).getImage(); + if (print) { + c.printAll(g2d); } else { - BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), - BufferedImage.TYPE_INT_RGB); - icon.paintIcon(null, image.getGraphics(), 0, 0); - return image; + c.paintAll(g2d); } - } - - public static BufferedImage toBufferedImage(final Image image) { - if (image == null) { - throw new NullPointerException("Can't covert null image"); - } - if (image instanceof BufferedImage) { - return (BufferedImage) image; - } else { - BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), - image.getHeight(null), - BufferedImage.TYPE_INT_ARGB); - Graphics2D g = bufferedImage.createGraphics(); - g.drawImage(image, 0, 0, null); - g.dispose(); - return bufferedImage; - } + g2d.dispose(); + return image; } - public static BufferedImage createCompatibleTranslucentImage(final int width, final int height) { return isHeadless() ? diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties index e74aa2477..60cc6f8aa 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties @@ -18,7 +18,5 @@ Table.alternateRowColor = true Tree.alternateRowColor = true List.alternateRowColor = true FileChooser.listViewWindowsStyle = false -CheckBox.borderInsets = 2,2,2,2 -RadioButton.borderInsets = 2,2,2,2 PopupMenu.defaultLightWeightPopups = false ToolTip.paintShadow = false diff --git a/core/src/test/java/PreferenceChangeDemo.java b/core/src/test/java/PreferenceChangeDemo.java index 96de0d792..ad9f83ac5 100644 --- a/core/src/test/java/PreferenceChangeDemo.java +++ b/core/src/test/java/PreferenceChangeDemo.java @@ -1,6 +1,8 @@ import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.icons.SolidColorIcon; import com.github.weisj.darklaf.theme.Theme; import ui.ComponentDemo; +import ui.DemoPanel; import javax.swing.*; import java.awt.*; @@ -40,20 +42,49 @@ public static void main(final String[] args) { @Override public JComponent createComponent() { LafManager.addThemePreferenceChangeListener(LafManager::installTheme); - return new JPanel(new GridBagLayout()) {{ - add(new JToggleButton("Start") {{ - addActionListener(e -> { - setText(isSelected() ? "Stop" : "Start"); - }); - }}); - }}; + DemoPanel panel = new DemoPanel(new JToggleButton("Start") {{ + addActionListener(e -> { + setText(isSelected() ? "Stop" : "Start"); + LafManager.enabledPreferenceChangeReporting(isSelected()); + }); + }}); + Icon accentColorIcon = new SolidColorIcon() { + @Override + public Color getColor() { + return LafManager.getTheme().getAccentColorRule().getAccentColor(); + } + }; + Icon selectionColorIcon = new SolidColorIcon() { + @Override + public Color getColor() { + return LafManager.getTheme().getAccentColorRule().getSelectionColor(); + } + }; + JPanel controlPanel = panel.addControls(); + controlPanel.add(new JLabel("Accent Color", accentColorIcon, JLabel.LEFT)); + controlPanel.add(new JLabel("Selection Color", selectionColorIcon, JLabel.LEFT)); + + controlPanel = panel.addControls(); + controlPanel.add(new JTextArea() {{ + setMargin(new Insets(5, 5, 5, 5)); + setEditable(false); + setText("Press start/stop to enable/disable preference monitoring.\n" + + "Then do one of the following\n" + + " - switch between dark/light theme (Windows/macOS)\n" + + " - toggle high contrast mode (Windows/macOS)\n" + + " - change accent color (Windows/macOS)\n" + + " - change selection color (macOS)\n" + + " - change font scaling (Windows)\n" + + "The theme should then adjust automatically (if monitoring is started).\n"); + }}); + return panel; } @Override public WindowListener createWindowListener() { return new WindowAdapter() { @Override - public void windowClosed(final WindowEvent e) { + public void windowClosing(final WindowEvent e) { LafManager.enabledPreferenceChangeReporting(false); } }; diff --git a/core/src/test/java/ui/DemoPanel.java b/core/src/test/java/ui/DemoPanel.java index f4c7bb8ca..20d6be789 100644 --- a/core/src/test/java/ui/DemoPanel.java +++ b/core/src/test/java/ui/DemoPanel.java @@ -56,16 +56,20 @@ public DemoPanel(final JComponent component, final LayoutManager layoutManager, add(controls, BorderLayout.SOUTH); } - public JPanel addControls(final int columns) { + public JPanel addControls(final LayoutManager layoutManager) { JPanel control = new JPanel(); + control.setLayout(layoutManager); + control.setBorder(DarkBorders.createLineBorder(1, 0, 0, 0)); + controls.add(control); + return control; + } + + public JPanel addControls(final int columns) { String constraints = "fillx"; if (columns > 0) { constraints += ", wrap" + columns; } - control.setLayout(new MigLayout(constraints, "[][grow]")); - control.setBorder(DarkBorders.createLineBorder(1, 0, 0, 0)); - controls.add(control); - return control; + return addControls(new MigLayout(constraints, "[][grow]")); } public JPanel addControls() { diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java index fefa7cc13..4b175a3ee 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java @@ -57,6 +57,8 @@ public class JNIThemeInfoMacOS { public static Color getAccentColor() { int index = nativeGetAccentColor(); switch (index) { + case -2: + return MacOSColors.BLUE; case -1: return MacOSColors.GRAY; case 0: @@ -72,7 +74,7 @@ public static Color getAccentColor() { case 6: return MacOSColors.ROSE; default: - return MacOSColors.BLUE; + return null; } } diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java index 940e78181..dcee7915d 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java @@ -49,6 +49,11 @@ private void onNotification() { boolean newHighContrast = JNIThemeInfoMacOS.isHighContrastEnabled(); Color newAccentColor = JNIThemeInfoMacOS.getAccentColor(); Color newSelectionColor = JNIThemeInfoMacOS.getSelectionColor(); + LOGGER.info("Event received:"); + LOGGER.info(" Dark Mode: [old: " + darkMode + " new: " + newDark + "]"); + LOGGER.info(" High Contrast: [old: " + highContrast + " new: " + newHighContrast + "]"); + LOGGER.info(" Accent Color: [old: " + accentColor + " new: " + newAccentColor + "]"); + LOGGER.info(" Selection Color: [old: " + selectionColor + " new: " + newSelectionColor + "]"); if (darkMode != newDark || highContrast != newHighContrast || !Objects.equals(accentColor, newAccentColor) diff --git a/macos/src/main/objectiveCpp/Decorations.mm b/macos/src/main/objectiveCpp/Decorations.mm index 45e30bcbc..018f1720d 100644 --- a/macos/src/main/objectiveCpp/Decorations.mm +++ b/macos/src/main/objectiveCpp/Decorations.mm @@ -87,7 +87,7 @@ NSWindow *nsWindow = OBJC(hwnd); return (jboolean)(([nsWindow styleMask] & NSWindowStyleMaskFullScreen) != 0); JNF_COCOA_EXIT(env); - return false; + return NO; } JNIEXPORT jdouble JNICALL @@ -109,7 +109,7 @@ } else { nsWindow.titleVisibility = NSWindowTitleHidden; } - [nsWindow contentView].needsDisplay = true; + [nsWindow contentView].needsDisplay = TRUE; }]; JNF_COCOA_EXIT(env); } @@ -126,7 +126,7 @@ } else { nsWindow.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; } - [nsWindow contentView].needsDisplay = true; + [nsWindow contentView].needsDisplay = YES; }]; } JNF_COCOA_EXIT(env); @@ -138,8 +138,8 @@ NSWindow *nsWindow = OBJC(hwnd); [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^{ nsWindow.styleMask |= NSWindowStyleMaskFullSizeContentView; - nsWindow.titlebarAppearsTransparent = true; - [nsWindow contentView].needsDisplay = true; + nsWindow.titlebarAppearsTransparent = YES; + [nsWindow contentView].needsDisplay = YES; }]; JNF_COCOA_EXIT(env); } @@ -150,8 +150,8 @@ NSWindow *nsWindow = OBJC(hwnd); [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^{ nsWindow.styleMask &= ~NSWindowStyleMaskFullSizeContentView; - nsWindow.titlebarAppearsTransparent = false; - [nsWindow contentView].needsDisplay = true; + nsWindow.titlebarAppearsTransparent = NO; + [nsWindow contentView].needsDisplay = YES; }]; JNF_COCOA_EXIT(env); } diff --git a/macos/src/main/objectiveCpp/ThemeInfo.mm b/macos/src/main/objectiveCpp/ThemeInfo.mm index c5bbaee5f..051592284 100644 --- a/macos/src/main/objectiveCpp/ThemeInfo.mm +++ b/macos/src/main/objectiveCpp/ThemeInfo.mm @@ -30,14 +30,18 @@ #define KEY_APPLE_INTERFACE_STYLE @"AppleInterfaceStyle" #define KEY_SWITCHES_AUTOMATICALLY @"AppleInterfaceStyleSwitchesAutomatically" #define KEY_ACCENT_COLOR @"AppleAccentColor" +#define KEY_SELECTION_COLOR @"selectedTextBackgroundColor" +#define KEY_SYSTEM_COLOR_LIST @"System" #define EVENT_ACCENT_COLOR @"AppleColorPreferencesChangedNotification" +#define EVENT_AQUA_CHANGE @"AppleAquaColorVariantChanged" #define EVENT_THEME_CHANGE @"AppleInterfaceThemeChangedNotification" #define EVENT_HIGH_CONTRAS @"AXInterfaceIncreaseContrastStatusDidChange" #define EVENT_COLOR_CHANGE NSSystemColorsDidChangeNotification #define VALUE_DARK @"Dark" -#define VALUE_NO_ACCENT_COLOR (0) +#define VALUE_DEFAULT_ACCENT_COLOR (-2) +#define VALUE_NO_ACCENT_COLOR (-100) #define VALUE_NO_SELECTION_COLOR (-1) @interface PreferenceChangeListener:NSObject { @@ -54,6 +58,7 @@ - (id)initWithJVM:(JavaVM *)jvm_ andCallBack:(jobject)callback_ { NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter]; [self listenToKey:EVENT_ACCENT_COLOR onCenter:center]; + [self listenToKey:EVENT_AQUA_CHANGE onCenter:center]; [self listenToKey:EVENT_THEME_CHANGE onCenter:center]; [self listenToKey:EVENT_HIGH_CONTRAS onCenter:center]; [self listenToKey:EVENT_COLOR_CHANGE onCenter:center]; @@ -73,13 +78,13 @@ - (void)listenToKey:(NSString *)key onCenter:(NSDistributedNotificationCenter *) object:nil]; } -- (void)notificationEvent:(NSNotification *)notification { +- (void)runCallback { if (!jvm) return; JNIEnv *env; - BOOL detach = false; + BOOL detach = NO; int getEnvStat = jvm->GetEnv((void **)&env, JNI_VERSION_1_6); if (getEnvStat == JNI_EDETACHED) { - detach = true; + detach = YES; if (jvm->AttachCurrentThread((void **) &env, NULL) != 0) return; } else if (getEnvStat == JNI_EVERSION) { return; @@ -95,6 +100,10 @@ - (void)notificationEvent:(NSNotification *)notification { if (detach) jvm->DetachCurrentThread(); } +- (void)notificationEvent:(NSNotification *)notification { + [self runCallback]; +} + @end JNIEXPORT jboolean JNICALL @@ -108,17 +117,17 @@ - (void)notificationEvent:(NSNotification *)notification { // Catalina BOOL switchesAutomatically = [[NSUserDefaults standardUserDefaults] boolForKey:KEY_SWITCHES_AUTOMATICALLY]; if (switchesAutomatically) { - // If switchesAutomatically == true the roles of "Dark" and nil are changed. + // If switchesAutomatically == YES the roles of "Dark" and nil are changed. return (jboolean) !isDark; } } - // Mojave or switchesAutomatically == false. + // Mojave or switchesAutomatically == NO. return (jboolean) isDark; } else { - return (jboolean) false; + return (jboolean) NO; } JNF_COCOA_EXIT(env); - return false; + return NO; } JNIEXPORT jboolean JNICALL @@ -126,7 +135,7 @@ - (void)notificationEvent:(NSNotification *)notification { JNF_COCOA_ENTER(env); return (jboolean) NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast; JNF_COCOA_EXIT(env); - return (jboolean) false; + return (jboolean) NO; } JNIEXPORT jint JNICALL @@ -138,7 +147,7 @@ - (void)notificationEvent:(NSNotification *)notification { return (jint) ([[NSUserDefaults standardUserDefaults] integerForKey:KEY_ACCENT_COLOR]); } } - return (jint) VALUE_NO_ACCENT_COLOR; + return (jint) VALUE_DEFAULT_ACCENT_COLOR; JNF_COCOA_EXIT(env); return (jint) VALUE_NO_ACCENT_COLOR; } @@ -147,7 +156,7 @@ - (void)notificationEvent:(NSNotification *)notification { Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_nativeGetSelectionColor(JNIEnv *env, jclass obj) { JNF_COCOA_ENTER(env); NSColorSpace *rgbSpace = [NSColorSpace genericRGBColorSpace]; - NSColor *accentColor = [[NSColor selectedControlColor] colorUsingColorSpace:rgbSpace]; + NSColor *accentColor = [[[NSColorList colorListNamed: KEY_SYSTEM_COLOR_LIST] colorWithKey:KEY_SELECTION_COLOR] colorUsingColorSpace:rgbSpace]; NSInteger r = (NSInteger) (255 * [accentColor redComponent]); NSInteger g = (NSInteger) (255 * [accentColor greenComponent]); NSInteger b = (NSInteger) (255 * [accentColor blueComponent]); diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java index d46b3f2e6..e7c4215f6 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java @@ -31,6 +31,10 @@ public class SolidColorIcon implements Icon { private final int height; private Color color; + public SolidColorIcon() { + this(null); + } + public SolidColorIcon(final Color color) { this(color, 16, 16); } @@ -43,8 +47,11 @@ public SolidColorIcon(final Color color, final int width, final int height) { @Override public void paintIcon(final Component c, final Graphics g, final int x, final int y) { - g.setColor(color); - g.fillRect(x, y, getIconWidth(), getIconHeight()); + Color col = getColor(); + if (col != null) { + g.setColor(col); + g.fillRect(x, y, getIconWidth(), getIconHeight()); + } } @Override diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties index 2abeee57f..75cb994c3 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -mainAccent.propertyList = {widgetFillDefault:[100,100,90];\ +mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ hoverHighlightDefault:[100,80,80];\ clickHighlightDefault:[100,90,85];\ widgetBorderDefault:[100,80,110];\ @@ -34,8 +34,8 @@ mainAccent.propertyList = {widgetFillDefault:[100,100,90];\ highlightFillFocus:[100,100,80];\ highlightFillFocusSecondary:[100,110,100];\ highlightFillMono:[100,25,50];\ - controlFillHighlight:[100,112,185];\ - controlFillHighlightDisabled:[100,77,100];\ - hyperlink:[100,110,190]} + controlFillHighlight:[100,100,100];\ + controlFillHighlightDisabled:[100,77,50];\ + hyperlink:[100,100,100]} selectionAccent.propertyList = {textSelectionBackground} diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties index 0a1c5202f..402d30d2a 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties @@ -36,7 +36,6 @@ mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ controlBorderSelected:[100,100,100];\ widgetFillSelected:[100,100,100];\ controlFillHighlight:[100,100,100];\ - controlFillHighlightDisabled:[100,5,90];\ - hyperlink:[100,100,122]} + hyperlink:[100,100,100]} selectionAccent.propertyList = {textSelectionBackground} diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties index 14d04623f..234a3ac57 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties @@ -98,7 +98,7 @@ Theme.highContrast = false %controlFillFocus = FFFFFF %controlFillDisabled = ABABAB %controlFillHighlight = 4D89C9 -%controlFillHighlightDisabled = b0b3b6 +%controlFillHighlightDisabled = ABABAB %controlBackground = C4C4C4 %controlFadeStart = C4C4C4 %controlFadeEnd = 808080