mirror of https://github.com/weisJ/darklaf.git
Jannis Weis
5 years ago
committed by
GitHub
46 changed files with 1655 additions and 330 deletions
@ -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 |
||||
|
@ -0,0 +1,133 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.task; |
||||
|
||||
import com.github.weisj.darklaf.PropertyLoader; |
||||
import com.github.weisj.darklaf.color.DarkColorModelHSB; |
||||
import com.github.weisj.darklaf.icons.IconLoader; |
||||
import com.github.weisj.darklaf.theme.Theme; |
||||
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; |
||||
import java.util.logging.Logger; |
||||
|
||||
public class AccentColorAdjustmentTask implements DefaultsAdjustmentTask { |
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(AccentColorAdjustmentTask.class.getName()); |
||||
private static final String MAIN_ACCENT_LIST_KEY = "mainAccent.propertyList"; |
||||
private static final String SELECTION_ACCENT_LIST_KEY = "selectionAccent.propertyList"; |
||||
private static final UIDefaults DEFAULTS = new UIDefaults(); |
||||
|
||||
@Override |
||||
public void run(final Theme currentTheme, final Properties properties) { |
||||
Properties props = currentTheme.loadPropertyFile("accents", true); |
||||
Color accentColor = currentTheme.getAccentColorRule().getAccentColor(); |
||||
Color selectionColor = currentTheme.getAccentColorRule().getSelectionColor(); |
||||
adjust(MAIN_ACCENT_LIST_KEY, accentColor, props, properties); |
||||
adjust(SELECTION_ACCENT_LIST_KEY, selectionColor, props, properties); |
||||
} |
||||
|
||||
private void adjust(final String listKey, final Color c, |
||||
final Properties listProperties, final Properties properties) { |
||||
if (c == null) return; |
||||
Object obj = PropertyLoader.parseValue(listKey, |
||||
listProperties.getProperty(listKey), |
||||
listProperties, DEFAULTS, IconLoader.get()); |
||||
DEFAULTS.clear(); |
||||
if (obj instanceof List<?>) { |
||||
double[] hsb = DarkColorModelHSB.RGBtoHSBValues(c.getRed(), c.getGreen(), c.getBlue()); |
||||
adjustList((List<?>) obj, hsb, properties); |
||||
} |
||||
} |
||||
|
||||
private void adjustList(final List<?> list, final double[] hsb, |
||||
final Properties properties) { |
||||
ColorInfo info = new ColorInfo(); |
||||
for (Object o : list) { |
||||
info = getColorInfo(o, info); |
||||
if (info.key == null) continue; |
||||
Object c = mapColor(info, hsb, properties); |
||||
if (c instanceof Color) { |
||||
properties.put(info.key, c); |
||||
} else { |
||||
LOGGER.warning("Color with key '" + info.key |
||||
+ "' could not be adjusted because the value '" + c + "' is not a color"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private ColorInfo getColorInfo(final Object o, final ColorInfo info) { |
||||
info.set(null, 0, 0, 0); |
||||
if (o instanceof String) { |
||||
info.set(o.toString(), 100, 100, 100); |
||||
return info; |
||||
} |
||||
if (o instanceof Pair<?, ?>) { |
||||
Object first = ((Pair<?, ?>) o).getFirst(); |
||||
Object second = ((Pair<?, ?>) o).getSecond(); |
||||
if (!(first instanceof String)) return null; |
||||
if (!(second instanceof List<?>)) return null; |
||||
String key = first.toString(); |
||||
List<?> list = (List<?>) second; |
||||
if (list.size() != 3 |
||||
|| !(list.get(0) instanceof Integer) |
||||
|| !(list.get(1) instanceof Integer) |
||||
|| !(list.get(2) instanceof Integer)) { |
||||
return info; |
||||
} |
||||
info.set(key, (Integer) list.get(0), (Integer) list.get(1), (Integer) list.get(2)); |
||||
return info; |
||||
} |
||||
return info; |
||||
} |
||||
|
||||
private Object mapColor(final ColorInfo info, final double[] hsbMatch, final Properties properties) { |
||||
Object obj = properties.get(info.key); |
||||
if (obj instanceof Color) { |
||||
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; |
||||
} |
||||
|
||||
private static class ColorInfo { |
||||
private String key; |
||||
private int hAdj; |
||||
private int sAdj; |
||||
private int bAdj; |
||||
|
||||
private void set(final String key, final int hAdj, final int sAdj, final int bAdj) { |
||||
this.key = key; |
||||
this.hAdj = hAdj; |
||||
this.sAdj = sAdj; |
||||
this.bAdj = bAdj; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,113 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.platform.macos; |
||||
|
||||
import com.github.weisj.darklaf.platform.macos.theme.MacOSColors; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class JNIThemeInfoMacOS { |
||||
|
||||
/** |
||||
* Returns whether dark mode is enabled. |
||||
* |
||||
* @return true if dark mode is enabled. |
||||
*/ |
||||
public static native boolean isDarkThemeEnabled(); |
||||
|
||||
/** |
||||
* Returns whether high contrast mode is enabled. |
||||
* |
||||
* @return true if high contrast mode is enabled. |
||||
*/ |
||||
public static native boolean isHighContrastEnabled(); |
||||
|
||||
/* |
||||
* Get the index of the accent color. |
||||
*/ |
||||
private static native int nativeGetAccentColor(); |
||||
|
||||
|
||||
/** |
||||
* Returns the current accent color. |
||||
* |
||||
* @return the accent color. |
||||
*/ |
||||
public static Color getAccentColor() { |
||||
int index = nativeGetAccentColor(); |
||||
switch (index) { |
||||
case -2: |
||||
return MacOSColors.BLUE; |
||||
case -1: |
||||
return MacOSColors.GRAY; |
||||
case 0: |
||||
return MacOSColors.RED; |
||||
case 1: |
||||
return MacOSColors.ORANGE; |
||||
case 2: |
||||
return MacOSColors.YELLOW; |
||||
case 3: |
||||
return MacOSColors.GREEN; |
||||
case 5: |
||||
return MacOSColors.LILAC; |
||||
case 6: |
||||
return MacOSColors.ROSE; |
||||
default: |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* Returns the selection color as an AARRGGBB integer. |
||||
*/ |
||||
private static native int nativeGetSelectionColor(); |
||||
|
||||
|
||||
/** |
||||
* Returns the current selection color. |
||||
* |
||||
* @return the current selection color. |
||||
*/ |
||||
public static Color getSelectionColor() { |
||||
int rgba = nativeGetSelectionColor(); |
||||
// If rgba == 0 then it has an alpha channel != 255, so it is invalid.
|
||||
if (rgba == 0) return null; |
||||
return new Color(rgba); |
||||
} |
||||
|
||||
/** |
||||
* Create an preference change listener. |
||||
* |
||||
* @param callback the event callback. |
||||
* @return the pointer to the listener. |
||||
*/ |
||||
public static native long createPreferenceChangeListener(final Runnable callback); |
||||
|
||||
/** |
||||
* Delete the preference change listener. |
||||
* |
||||
* @param listenerPtr pointer to the listener. |
||||
*/ |
||||
public static native void deletePreferenceChangeListener(final long listenerPtr); |
||||
} |
@ -0,0 +1,73 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.platform.macos; |
||||
|
||||
import com.github.weisj.darklaf.platform.NativeUtil; |
||||
import com.github.weisj.darklaf.util.SystemInfo; |
||||
|
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
public class MacOSLibrary { |
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(MacOSLibrary.class.getName()); |
||||
private static boolean loaded; |
||||
private static boolean attemptedLoad; |
||||
|
||||
/** |
||||
* Load the decorations-library if necessary. |
||||
*/ |
||||
public static void updateLibrary() { |
||||
if (!loaded && !attemptedLoad) { |
||||
loadLibrary(); |
||||
} |
||||
} |
||||
|
||||
private static void loadLibrary() { |
||||
attemptedLoad = true; |
||||
if (!SystemInfo.isMac || loaded) { |
||||
return; |
||||
} |
||||
try { |
||||
if (SystemInfo.isX64) { |
||||
NativeUtil.loadLibraryFromJar( |
||||
"/com/github/weisj/darklaf/platform/darklaf-macos/macos-x86-64/libdarklaf-macos.dylib"); |
||||
loaded = true; |
||||
LOGGER.info("Loaded libdarklaf-macos.dylib. Native features are enabled."); |
||||
} else { |
||||
LOGGER.warning("JRE model '" |
||||
+ SystemInfo.jreArchitecture |
||||
+ "' not supported. Native features will be disabled"); |
||||
} |
||||
} catch (Throwable e) { |
||||
//Library not found, SecurityManager prevents library loading etc.
|
||||
LOGGER.log(Level.SEVERE, "Could not load decorations library libdarklaf-macos.dylib." + |
||||
" Native features will be disabled", e); |
||||
} |
||||
} |
||||
|
||||
public static boolean isLoaded() { |
||||
return loaded; |
||||
} |
||||
} |
@ -0,0 +1,102 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.platform.macos; |
||||
|
||||
import java.awt.*; |
||||
import java.util.Objects; |
||||
import java.util.logging.Logger; |
||||
|
||||
public class MacOSPreferenceMonitor { |
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(MacOSThemePreferenceProvider.class.getName()); |
||||
|
||||
private final MacOSThemePreferenceProvider preferenceProvider; |
||||
|
||||
private boolean darkMode; |
||||
private boolean highContrast; |
||||
private Color accentColor; |
||||
private Color selectionColor; |
||||
private long listenerHandle; |
||||
private boolean running; |
||||
|
||||
public MacOSPreferenceMonitor(final MacOSThemePreferenceProvider preferenceProvider) { |
||||
this.preferenceProvider = preferenceProvider; |
||||
} |
||||
|
||||
private void onNotification() { |
||||
boolean newDark = JNIThemeInfoMacOS.isDarkThemeEnabled(); |
||||
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) |
||||
|| !Objects.equals(selectionColor, newSelectionColor)) { |
||||
darkMode = newDark; |
||||
accentColor = newAccentColor; |
||||
selectionColor = newSelectionColor; |
||||
highContrast = newHighContrast; |
||||
preferenceProvider.reportPreferenceChange(highContrast, darkMode, accentColor, selectionColor); |
||||
} |
||||
} |
||||
|
||||
private void start() { |
||||
darkMode = JNIThemeInfoMacOS.isDarkThemeEnabled(); |
||||
highContrast = JNIThemeInfoMacOS.isHighContrastEnabled(); |
||||
accentColor = JNIThemeInfoMacOS.getAccentColor(); |
||||
selectionColor = JNIThemeInfoMacOS.getSelectionColor(); |
||||
listenerHandle = JNIThemeInfoMacOS.createPreferenceChangeListener(this::onNotification); |
||||
if (listenerHandle == 0) { |
||||
LOGGER.severe("Could not create notification listener. Monitoring will not be started"); |
||||
return; |
||||
} |
||||
running = true; |
||||
LOGGER.info("Started preference monitoring."); |
||||
} |
||||
|
||||
private void stop() { |
||||
if (!running) return; |
||||
running = false; |
||||
LOGGER.info("Stopped preference monitoring."); |
||||
JNIThemeInfoMacOS.deletePreferenceChangeListener(listenerHandle); |
||||
} |
||||
|
||||
public void setRunning(final boolean running) { |
||||
if (running == isRunning()) return; |
||||
if (running) { |
||||
start(); |
||||
} else { |
||||
stop(); |
||||
} |
||||
} |
||||
|
||||
public boolean isRunning() { |
||||
return running; |
||||
} |
||||
} |
@ -0,0 +1,87 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.platform.macos; |
||||
|
||||
import com.github.weisj.darklaf.theme.info.*; |
||||
|
||||
import java.awt.*; |
||||
import java.util.function.Consumer; |
||||
|
||||
public class MacOSThemePreferenceProvider implements ThemePreferenceProvider { |
||||
|
||||
private final PreferredThemeStyle fallbackStyle = new PreferredThemeStyle(ContrastRule.STANDARD, |
||||
ColorToneRule.LIGHT); |
||||
private final MacOSPreferenceMonitor monitor = new MacOSPreferenceMonitor(this); |
||||
private Consumer<PreferredThemeStyle> callback; |
||||
|
||||
@Override |
||||
public PreferredThemeStyle getPreference() { |
||||
if (!MacOSLibrary.isLoaded()) return fallbackStyle; |
||||
boolean darkMode = JNIThemeInfoMacOS.isDarkThemeEnabled(); |
||||
boolean highContrast = JNIThemeInfoMacOS.isHighContrastEnabled(); |
||||
Color accentColor = JNIThemeInfoMacOS.getAccentColor(); |
||||
Color selectionColor = JNIThemeInfoMacOS.getSelectionColor(); |
||||
return create(highContrast, darkMode, accentColor, selectionColor); |
||||
} |
||||
|
||||
private PreferredThemeStyle create(final boolean highContrast, final boolean darkMode, |
||||
final Color accentColor, final Color selectionColor) { |
||||
ContrastRule contrastRule = highContrast ? ContrastRule.HIGH_CONTRAST : ContrastRule.STANDARD; |
||||
ColorToneRule toneRule = darkMode ? ColorToneRule.DARK : ColorToneRule.LIGHT; |
||||
AccentColorRule accentColorRule = AccentColorRule.fromColor(accentColor, selectionColor); |
||||
return new PreferredThemeStyle(contrastRule, toneRule, accentColorRule); |
||||
} |
||||
|
||||
void reportPreferenceChange(final boolean dark, final boolean highContrast, |
||||
final Color accentColor, final Color selectionColor) { |
||||
if (callback != null) { |
||||
PreferredThemeStyle style = create(dark, highContrast, accentColor, selectionColor); |
||||
callback.accept(style); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void setReporting(final boolean reporting) { |
||||
if (reporting && !MacOSLibrary.isLoaded()) MacOSLibrary.updateLibrary(); |
||||
synchronized (monitor) { |
||||
monitor.setRunning(reporting); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean isReporting() { |
||||
return monitor.isRunning(); |
||||
} |
||||
|
||||
@Override |
||||
public void initialize() { |
||||
MacOSLibrary.updateLibrary(); |
||||
} |
||||
|
||||
@Override |
||||
public void setCallback(final Consumer<PreferredThemeStyle> callback) { |
||||
this.callback = callback; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.platform.macos.theme; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class MacOSColors { |
||||
|
||||
// 0.000000 0.478431 1.000000
|
||||
public static final Color BLUE = new Color(0, 122, 255); |
||||
// 0.584314 0.239216 0.588235
|
||||
public static final Color LILAC = new Color(149, 61, 149); |
||||
// 0.968627 0.309804 0.619608
|
||||
public static final Color ROSE = new Color(247, 79, 158); |
||||
// 0.878431 0.219608 0.243137
|
||||
public static final Color RED = new Color(224, 56, 62); |
||||
// 0.968627 0.509804 0.105882
|
||||
public static final Color ORANGE = new Color(247, 130, 27); |
||||
// 0.988235 0.721569 0.152941
|
||||
public static final Color YELLOW = new Color(252, 184, 39); |
||||
// 0.384314 0.729412 0.27451
|
||||
public static final Color GREEN = new Color(98, 186, 70); |
||||
// 0.596078 0.596078 0.596078
|
||||
public static final Color GRAY = new Color(152, 152, 152); |
||||
} |
@ -0,0 +1,184 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
#import "com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS.h" |
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h> |
||||
#import <AppKit/AppKit.h> |
||||
|
||||
#define OBJC(jl) ((id)jlong_to_ptr(jl)) |
||||
|
||||
#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_CONTRAST @"AXInterfaceIncreaseContrastStatusDidChange" |
||||
#define EVENT_COLOR_CHANGE NSSystemColorsDidChangeNotification |
||||
|
||||
#define VALUE_DARK @"Dark" |
||||
#define VALUE_DEFAULT_ACCENT_COLOR (-2) |
||||
#define VALUE_NO_ACCENT_COLOR (-100) |
||||
#define VALUE_NO_SELECTION_COLOR (-1) |
||||
|
||||
@interface PreferenceChangeListener:NSObject { |
||||
@public JavaVM *jvm; |
||||
@public jobject callback; |
||||
} |
||||
@end |
||||
|
||||
@implementation PreferenceChangeListener |
||||
- (id)initWithJVM:(JavaVM *)jvm_ andCallBack:(jobject)callback_ { |
||||
self = [super init]; |
||||
self->jvm = jvm_; |
||||
self->callback = 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_CONTRAST onCenter:center]; |
||||
[self listenToKey:EVENT_COLOR_CHANGE onCenter:center]; |
||||
return self; |
||||
} |
||||
|
||||
- (void)dealloc { |
||||
NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter]; |
||||
[center removeObserver:self]; // Removes all registered notifications. |
||||
[super dealloc]; |
||||
} |
||||
|
||||
- (void)listenToKey:(NSString *)key onCenter:(NSDistributedNotificationCenter *)center { |
||||
[center addObserver:self |
||||
selector:@selector(notificationEvent:) |
||||
name:key |
||||
object:nil]; |
||||
} |
||||
|
||||
- (void)runCallback { |
||||
if (!jvm) return; |
||||
JNIEnv *env; |
||||
BOOL detach = NO; |
||||
int getEnvStat = jvm->GetEnv((void **)&env, JNI_VERSION_1_6); |
||||
if (getEnvStat == JNI_EDETACHED) { |
||||
detach = YES; |
||||
if (jvm->AttachCurrentThread((void **) &env, NULL) != 0) return; |
||||
} else if (getEnvStat == JNI_EVERSION) { |
||||
return; |
||||
} |
||||
jclass runnableClass = env->GetObjectClass(callback); |
||||
jmethodID runMethodId = env->GetMethodID(runnableClass, "run", "()V"); |
||||
if (runMethodId) { |
||||
env->CallVoidMethod(callback, runMethodId); |
||||
} |
||||
if (env->ExceptionCheck()) { |
||||
env->ExceptionDescribe(); |
||||
} |
||||
if (detach) jvm->DetachCurrentThread(); |
||||
} |
||||
|
||||
- (void)notificationEvent:(NSNotification *)notification { |
||||
[self runCallback]; |
||||
} |
||||
|
||||
@end |
||||
|
||||
JNIEXPORT jboolean JNICALL |
||||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_isDarkThemeEnabled(JNIEnv *env, jclass obj) { |
||||
JNF_COCOA_ENTER(env); |
||||
if(@available(macOS 10.14, *)) { |
||||
NSString *interfaceStyle = [[NSUserDefaults standardUserDefaults] stringForKey:KEY_APPLE_INTERFACE_STYLE]; |
||||
// interfaceStyle can be nil (light mode) or "Dark" (dark mode). |
||||
BOOL isDark = [VALUE_DARK caseInsensitiveCompare:interfaceStyle] == NSOrderedSame; |
||||
return (jboolean) isDark; |
||||
} else { |
||||
return (jboolean) NO; |
||||
} |
||||
JNF_COCOA_EXIT(env); |
||||
return NO; |
||||
} |
||||
|
||||
JNIEXPORT jboolean JNICALL |
||||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_isHighContrastEnabled(JNIEnv *env, jclass obj) { |
||||
JNF_COCOA_ENTER(env); |
||||
return (jboolean) NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast; |
||||
JNF_COCOA_EXIT(env); |
||||
return (jboolean) NO; |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL |
||||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_nativeGetAccentColor(JNIEnv *env, jclass obj) { |
||||
JNF_COCOA_ENTER(env); |
||||
if (@available(macOS 10.14, *)) { |
||||
BOOL hasAccentSet = ([[NSUserDefaults standardUserDefaults] objectForKey:KEY_ACCENT_COLOR] != nil); |
||||
if (hasAccentSet) { |
||||
return (jint) ([[NSUserDefaults standardUserDefaults] integerForKey:KEY_ACCENT_COLOR]); |
||||
} |
||||
} |
||||
return (jint) VALUE_DEFAULT_ACCENT_COLOR; |
||||
JNF_COCOA_EXIT(env); |
||||
return (jint) VALUE_NO_ACCENT_COLOR; |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL |
||||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_nativeGetSelectionColor(JNIEnv *env, jclass obj) { |
||||
JNF_COCOA_ENTER(env); |
||||
NSColorSpace *rgbSpace = [NSColorSpace genericRGBColorSpace]; |
||||
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]); |
||||
return (jint) (0xff000000 | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | ((b & 0xFF) << 0)); |
||||
JNF_COCOA_EXIT(env); |
||||
return (jint) VALUE_NO_SELECTION_COLOR; |
||||
} |
||||
|
||||
JNIEXPORT jlong JNICALL |
||||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_createPreferenceChangeListener(JNIEnv *env, jclass obj, jobject callback) { |
||||
JNF_COCOA_DURING(env); // We dont want an auto release pool. |
||||
JavaVM *jvm; |
||||
if (env->GetJavaVM(&jvm) == 0) { |
||||
jobject callbackRef = env->NewGlobalRef(callback); |
||||
PreferenceChangeListener *listener = [[PreferenceChangeListener alloc] initWithJVM:jvm andCallBack: callbackRef]; |
||||
[listener retain]; |
||||
return reinterpret_cast<jlong>(listener); |
||||
} |
||||
return (jlong) 0; |
||||
JNF_COCOA_HANDLE(env); |
||||
return (jlong) 0; |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL |
||||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_deletePreferenceChangeListener(JNIEnv *env, jclass obj, jlong listenerPtr) { |
||||
JNF_COCOA_ENTER(env); |
||||
PreferenceChangeListener *listener = OBJC(listenerPtr); |
||||
if (listener) { |
||||
env->DeleteGlobalRef(listener->callback); |
||||
[listener release]; |
||||
[listener dealloc]; |
||||
} |
||||
JNF_COCOA_EXIT(env); |
||||
} |
@ -0,0 +1,155 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.theme; |
||||
|
||||
import com.github.weisj.darklaf.theme.info.*; |
||||
|
||||
import javax.swing.*; |
||||
import java.util.Properties; |
||||
|
||||
public class ThemeDelegate extends Theme { |
||||
|
||||
private final Theme delegate; |
||||
private final boolean overwriteFontSize; |
||||
private final boolean overWriteAccentColor; |
||||
|
||||
public ThemeDelegate(final Theme delegate) { |
||||
this(delegate, null, null); |
||||
} |
||||
|
||||
public ThemeDelegate(final Theme delegate, final FontSizeRule fontSizeRule, final AccentColorRule accentColorRule) { |
||||
super(fontSizeRule, accentColorRule); |
||||
if (delegate == null) { |
||||
throw new IllegalArgumentException("Theme delegate cannot be null"); |
||||
} |
||||
this.delegate = delegate; |
||||
this.overwriteFontSize = fontSizeRule != null; |
||||
this.overWriteAccentColor = accentColorRule != null; |
||||
} |
||||
|
||||
public Theme getDelegate() { |
||||
return delegate; |
||||
} |
||||
|
||||
@Override |
||||
public Theme derive(final FontSizeRule fontSizeRule, |
||||
final AccentColorRule accentColorRule) { |
||||
return getDelegate().derive(fontSizeRule, accentColorRule); |
||||
} |
||||
|
||||
@Override |
||||
public Theme copy() { |
||||
return getDelegate().copy(); |
||||
} |
||||
|
||||
@Override |
||||
public FontSizeRule getFontSizeRule() { |
||||
return overwriteFontSize ? super.getFontSizeRule() : delegate.getFontSizeRule(); |
||||
} |
||||
|
||||
@Override |
||||
public AccentColorRule getAccentColorRule() { |
||||
return overWriteAccentColor ? super.getAccentColorRule() : delegate.getAccentColorRule(); |
||||
} |
||||
|
||||
@Override |
||||
public ColorToneRule getColorToneRule() { |
||||
return delegate.getColorToneRule(); |
||||
} |
||||
|
||||
@Override |
||||
public ContrastRule getContrastRule() { |
||||
return delegate.getContrastRule(); |
||||
} |
||||
|
||||
@Override |
||||
protected PresetIconRule getPresetIconRule() { |
||||
return delegate.getPresetIconRule(); |
||||
} |
||||
|
||||
@Override |
||||
public void loadDefaults(final Properties properties, final UIDefaults currentDefaults) { |
||||
delegate.loadDefaults(properties, currentDefaults); |
||||
} |
||||
|
||||
@Override |
||||
public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults) { |
||||
delegate.customizeGlobals(properties, currentDefaults); |
||||
} |
||||
|
||||
@Override |
||||
public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults) { |
||||
delegate.customizeIconTheme(properties, currentDefaults); |
||||
} |
||||
|
||||
@Override |
||||
public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults) { |
||||
delegate.loadIconTheme(properties, currentDefaults); |
||||
} |
||||
|
||||
@Override |
||||
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults) { |
||||
delegate.customizePlatformProperties(properties, currentDefaults); |
||||
} |
||||
|
||||
@Override |
||||
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { |
||||
delegate.customizeUIProperties(properties, currentDefaults); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return delegate.getName(); |
||||
} |
||||
|
||||
@Override |
||||
protected String getResourcePath() { |
||||
return delegate.getResourcePath(); |
||||
} |
||||
|
||||
@Override |
||||
public String getPrefix() { |
||||
return delegate.getPrefix(); |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return delegate.getName(); |
||||
} |
||||
|
||||
@Override |
||||
protected Class<? extends Theme> getLoaderClass() { |
||||
return delegate.getClass(); |
||||
} |
||||
|
||||
@Override |
||||
protected String getPropertyFilePath(final String name) { |
||||
return delegate.getPropertyFilePath(name); |
||||
} |
||||
|
||||
@Override |
||||
public boolean useCustomDecorations() { |
||||
return delegate.useCustomDecorations(); |
||||
} |
||||
} |
@ -0,0 +1,70 @@
|
||||
/* |
||||
* MIT License |
||||
* |
||||
* Copyright (c) 2020 Jannis Weis |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in all |
||||
* copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
*/ |
||||
package com.github.weisj.darklaf.theme.info; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class AccentColorRule { |
||||
|
||||
private static final AccentColorRule DEFAULT = new AccentColorRule(null, null); |
||||
private final Color accentColor; |
||||
private final Color selectionColor; |
||||
|
||||
public AccentColorRule(final Color accentColor) { |
||||
this(accentColor, null); |
||||
} |
||||
|
||||
protected AccentColorRule(final Color accentColor, final Color selectionColor) { |
||||
this.accentColor = accentColor; |
||||
this.selectionColor = selectionColor; |
||||
} |
||||
|
||||
public static AccentColorRule getDefault() { |
||||
return DEFAULT; |
||||
} |
||||
|
||||
public static AccentColorRule fromColor(final Color accentColor, final Color selectionColor) { |
||||
return new AccentColorRule(accentColor, selectionColor); |
||||
} |
||||
|
||||
public static AccentColorRule fromColor(final Color accentColor) { |
||||
return fromColor(accentColor, null); |
||||
} |
||||
|
||||
public Color getAccentColor() { |
||||
return accentColor; |
||||
} |
||||
|
||||
public Color getSelectionColor() { |
||||
return selectionColor; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "AccentColorRule{" + |
||||
"accentColor=" + accentColor + |
||||
", selectionColor=" + selectionColor + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
# |
||||
# MIT License |
||||
# |
||||
# Copyright (c) 2020 Jannis Weis |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
# of this software and associated documentation files (the "Software"), to deal |
||||
# in the Software without restriction, including without limitation the rights |
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
# copies of the Software, and to permit persons to whom the Software is |
||||
# furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included in all |
||||
# copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
# SOFTWARE. |
||||
# |
||||
mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ |
||||
hoverHighlightDefault:[100,80,80];\ |
||||
clickHighlightDefault:[100,90,85];\ |
||||
widgetBorderDefault:[100,80,110];\ |
||||
controlBorderFocus:[100,90,116];\ |
||||
controlBorderFocusSelected:[100,90,116];\ |
||||
glowFocusLine:[100,90,116];\ |
||||
glowFocus:[100,120,155];\ |
||||
borderFocus:[100,76,122];\ |
||||
highlightFill:[100,80,45];\ |
||||
highlightFillFocus:[100,100,80];\ |
||||
highlightFillFocusSecondary:[100,110,100];\ |
||||
highlightFillMono:[100,25,50];\ |
||||
controlFillHighlight:[100,100,100];\ |
||||
controlFillHighlightDisabled:[100,77,50];\ |
||||
hyperlink:[100,100,100]} |
||||
selectionAccent.propertyList = {textSelectionBackground} |
||||
|
@ -0,0 +1,41 @@
|
||||
# |
||||
# MIT License |
||||
# |
||||
# Copyright (c) 2020 Jannis Weis |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
# of this software and associated documentation files (the "Software"), to deal |
||||
# in the Software without restriction, including without limitation the rights |
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
# copies of the Software, and to permit persons to whom the Software is |
||||
# furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included in all |
||||
# copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
# SOFTWARE. |
||||
# |
||||
mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ |
||||
hoverHighlightDefault:[100,80,100];\ |
||||
clickHighlightDefault:[100,90,100];\ |
||||
widgetBorderDefault:[100,100,90];\ |
||||
controlBorderFocus:[100,60,100];\ |
||||
controlBorderFocusSelected:[100,50,122];\ |
||||
glowFocusLine:[100,60,100];\ |
||||
glowFocus:[100,120,120];\ |
||||
borderFocus:[100,76,122];\ |
||||
highlightFillFocus:[100,130,95];\ |
||||
highlightFillFocusSecondary:[100,110,100];\ |
||||
highlightFillMono:[100,25,90];\ |
||||
controlBorderSelected:[100,100,100];\ |
||||
widgetFillSelected:[100,100,100];\ |
||||
controlFillHighlight:[100,100,100];\ |
||||
hyperlink:[100,100,100]} |
||||
selectionAccent.propertyList = {textSelectionBackground} |
||||
|
@ -1,3 +1,3 @@
|
||||
If your machine can't build the macos library download the latest |
||||
If your machine can't build the library download the latest |
||||
'darklaf-windows_x86-64.dll' from the repository and place it in this folder |
||||
renamed as 'darklaf-windows.dll'. |
||||
|
@ -1,3 +1,3 @@
|
||||
If your machine can't build the macos library download the latest |
||||
If your machine can't build the library download the latest |
||||
'darklaf-windows_x86.dll' from the repository and place it in this folder |
||||
renamed as 'darklaf-windows.dll'. |
||||
|
Loading…
Reference in new issue