Browse Source

Enabled custom accent/selection colors for OneDarkTheme.

Fixed button background being too small.
Fixed selection background for combo box not being respected.
pull/188/head
weisj 5 years ago
parent
commit
6b9fa9f159
  1. 2
      core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java
  2. 3
      core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java
  3. 2
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  4. 5
      core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java
  5. 3
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java
  6. 8
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java
  7. 1
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java
  8. 2
      core/src/test/java/ui/ComponentDemo.java
  9. 10
      theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java
  10. 1
      theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties
  11. 1
      theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties
  12. 48
      theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_accents.properties
  13. 2
      theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties

2
core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java

@ -228,7 +228,7 @@ public class PaintUtil {
arcSize -= stroke;
g.translate(lw, lw);
roundRect.setRoundRect(x, y, width - 2 * lw, height - 2, arcSize, arcSize);
roundRect.setRoundRect(x, y, width - 2 * lw, height - 2 * lw, arcSize, arcSize);
g.fill(roundRect);
g.translate(-lw, -lw);
context.restore();

3
core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java

@ -88,7 +88,8 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
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");
+ "' could not be adjusted because the value '" + c + ", '" + c.getClass()
+ " is not a color");
}
}
}

2
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -208,7 +208,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
if (effectiveArc == 0) {
g2.fillRect(x, y, width, height);
} else {
PaintUtil.fillRoundRect(g2, x, y, width, height, effectiveArc, true);
PaintUtil.fillRoundRect(g2, x, y, width, height, effectiveArc, false);
}
}

5
core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java

@ -129,6 +129,7 @@ public class CellUtil {
private static Color listCellBackground;
private static Color listCellBackgroundAlternative;
private static Color listCellBackgroundSelected;
private static Color comboListCellBackgroundSelected;
private static Color listCellBackgroundNoFocus;
private static Color listCellBackgroundNoFocusAlternative;
private static Color listCellBackgroundSelectedNoFocus;
@ -231,6 +232,7 @@ public class CellUtil {
listCellBackground = d.getColor("List.background");
listCellBackgroundAlternative = d.getColor("List.backgroundAlternative");
listCellBackgroundSelected = d.getColor("List.backgroundSelected");
comboListCellBackgroundSelected = d.getColor("ComboBox.selectionBackground");
listCellBackgroundNoFocus = d.getColor("List.backgroundNoFocus");
listCellBackgroundNoFocusAlternative = d.getColor("List.backgroundNoFocusAlternative");
listCellBackgroundSelectedNoFocus = d.getColor("List.backgroundSelectedNoFocus");
@ -366,9 +368,10 @@ public class CellUtil {
public static void setupListBackground(final Component comp, final JList<?> parent, final boolean selected,
final boolean altRow) {
boolean alt = altRow && PropertyUtil.getBooleanProperty(parent, DarkListUI.KEY_ALTERNATE_ROW_COLOR);
boolean comboList = PropertyUtil.getBooleanProperty(parent, DarkListUI.KEY_IS_COMBO_LIST);
setupBackground(comp, hasFocus(parent, comp), selected,
alt ? listCellBackgroundAlternative : listCellBackground,
listCellBackgroundSelected,
comboList ? comboListCellBackgroundSelected : listCellBackgroundSelected,
alt ? listCellBackgroundNoFocusAlternative : listCellBackgroundNoFocus,
listCellBackgroundSelectedNoFocus,
alt ? listCellInactiveBackgroundAlternative : listCellInactiveBackground,

3
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java

@ -40,6 +40,7 @@ import javax.swing.plaf.basic.ComboPopup;
import com.github.weisj.darklaf.components.ArrowButton;
import com.github.weisj.darklaf.delegate.LayoutManagerDelegate;
import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.ui.list.DarkDefaultListCellRenderer;
import com.github.weisj.darklaf.ui.list.DarkListCellRendererDelegate;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyKey;
@ -131,7 +132,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
@Override
protected ListCellRenderer<Object> createRenderer() {
return new DarkListCellRendererDelegate();
return new DarkDefaultListCellRenderer();
}
@Override

8
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java

@ -33,6 +33,7 @@ import javax.swing.*;
import javax.swing.plaf.basic.BasicComboPopup;
import com.github.weisj.darklaf.components.OverlayScrollPane;
import com.github.weisj.darklaf.ui.list.DarkListUI;
import com.github.weisj.darklaf.ui.scrollpane.DarkScrollBarUI;
import com.github.weisj.darklaf.util.DarkUIUtil;
@ -69,6 +70,13 @@ public class DarkComboPopup extends BasicComboPopup {
this.borderSize = borderSize;
}
@Override
protected JList<Object> createList() {
JList<Object> list = super.createList();
list.putClientProperty(DarkListUI.KEY_IS_COMBO_LIST, true);
return list;
}
@Override
protected void firePopupMenuWillBecomeVisible() {
if (list.getModel().getSize() != 0) {

1
core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java

@ -42,6 +42,7 @@ import com.github.weisj.darklaf.util.PropertyUtil;
public class DarkListUI extends DarkListUIBridge {
protected static final String KEY_PREFIX = "JList.";
public static final String KEY_IS_COMBO_LIST = KEY_PREFIX + ".isComboList";
public static final String KEY_ALTERNATE_ROW_COLOR = KEY_PREFIX + "alternateRowColor";
public static final String KEY_RENDER_BOOLEAN_AS_CHECKBOX = KEY_PREFIX + "renderBooleanAsCheckBox";
public static final String KEY_BOOLEAN_RENDER_TYPE = KEY_PREFIX + "booleanRenderType";

2
core/src/test/java/ui/ComponentDemo.java

@ -39,14 +39,12 @@ import javax.swing.event.MenuListener;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.graphics.ImageUtil;
import com.github.weisj.darklaf.settings.ThemeSettings;
import com.github.weisj.darklaf.theme.IntelliJTheme;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.theme.info.PreferredThemeStyle;
public interface ComponentDemo {
static Theme getTheme() {
if (true) return new IntelliJTheme();
PreferredThemeStyle themeStyle = LafManager.getPreferredThemeStyle();
return LafManager.themeForPreferredStyle(new PreferredThemeStyle(themeStyle.getContrastRule(),
themeStyle.getColorToneRule()));

10
theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java

@ -68,6 +68,16 @@ public class OneDarkTheme extends Theme {
loadCustomProperties("ui", properties, currentDefaults);
}
@Override
public boolean supportsCustomAccentColor() {
return true;
}
@Override
public boolean supportsCustomSelectionColor() {
return true;
}
@Override
public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults) {
super.customizeIconTheme(properties, currentDefaults);

1
theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties

@ -43,4 +43,3 @@ accent.propertyList = {widgetFillDefault:[100,100,100];\
selection.propertyList = {textCompSelectionBackground}
selectionForeground.propertyList = {textCompSelectionBackground:textCompSelectionForeground}
accentForeground.propertyList = {}

1
theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties

@ -43,4 +43,3 @@ accent.propertyList = {widgetFillDefault:[100,100,100];\
selection.propertyList = {textCompSelectionBackground}
selectionForeground.propertyList = {%textCompSelectionBackground:textCompSelectionForeground}
accentForeground.propertyList = {}

48
theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_accents.properties

@ -0,0 +1,48 @@
#
# 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.
#
#
# suppress inspection "UnusedProperty" for whole file
#
accent.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,50,50];\
controlFillHighlight:[100,100,100];\
controlFillSecondary:[100,100,100];\
controlFadeStart:[100,100,100];\
controlFadeEnd:[100,50,30];\
controlFillHighlightDisabled:[100,77,50];\
hyperlink:[100,100,100]}
selection.propertyList = {textCompSelectionBackground}
selectionForeground.propertyList = {textCompSelectionBackground:textCompSelectionForeground}

2
theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties

@ -66,7 +66,7 @@ Theme.highContrast = false
%clickHighlightColorful = 333841
%hoverHighlightDefault = 7AA3F5
%clickHighlightDefault = 689/F3
%clickHighlightDefault = 6897F3
%hoverHighlightSecondary = 323844
%clickHighlightSecondary = 323844

Loading…
Cancel
Save