From bf64b50dadb2084c9e642ddc450f986310ed18a4 Mon Sep 17 00:00:00 2001 From: weisj Date: Fri, 18 Oct 2019 21:14:03 +0200 Subject: [PATCH] Updated scrollbar colors. Fixed table/list/tree background rendering. Table now sources the drop background from the first ancestor that is not a ScrollPane. --- .../com/weis/darklaf/ui/list/DarkListCellRenderer.java | 2 +- src/main/java/com/weis/darklaf/ui/list/DarkListUI.java | 2 +- .../com/weis/darklaf/ui/scrollpane/DarkScrollBarUI.java | 3 ++- .../com/weis/darklaf/ui/table/DarkTableCellEditor.java | 2 +- .../ui/table/DarkTableCellEditorToggleButton.java | 2 +- .../com/weis/darklaf/ui/table/DarkTableCellRenderer.java | 2 +- src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java | 9 ++++++++- .../darklaf/theme/darcula/darcula_defaults.properties | 2 +- .../darklaf/theme/intellij/intellij_defaults.properties | 2 +- 9 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/weis/darklaf/ui/list/DarkListCellRenderer.java b/src/main/java/com/weis/darklaf/ui/list/DarkListCellRenderer.java index bbd45971..c3c435ea 100644 --- a/src/main/java/com/weis/darklaf/ui/list/DarkListCellRenderer.java +++ b/src/main/java/com/weis/darklaf/ui/list/DarkListCellRenderer.java @@ -65,7 +65,7 @@ public class DarkListCellRenderer extends DefaultListCellRenderer { } } Color alternativeRowColor = UIManager.getColor("List.alternateRowBackground"); - Color normalColor = UIManager.getColor("List.background"); + Color normalColor = list.getBackground(); var background = alternativeRow ? alternativeRowColor : normalColor; if (!(isSelected)) { comp.setBackground(background); diff --git a/src/main/java/com/weis/darklaf/ui/list/DarkListUI.java b/src/main/java/com/weis/darklaf/ui/list/DarkListUI.java index 52b279dd..bc1dc1ce 100644 --- a/src/main/java/com/weis/darklaf/ui/list/DarkListUI.java +++ b/src/main/java/com/weis/darklaf/ui/list/DarkListUI.java @@ -120,7 +120,7 @@ public class DarkListUI extends DarkListUIBridge { if (empty) { boolean alternativeRow = Boolean.TRUE.equals(list.getClientProperty("JList.alternateRowColor")); Color alternativeRowColor = UIManager.getColor("List.alternateRowBackground"); - Color normalColor = UIManager.getColor("List.background"); + Color normalColor = list.getBackground(); var background = alternativeRow && row % 2 == 1 ? alternativeRowColor : normalColor; var c = g.getColor(); g.setColor(background); diff --git a/src/main/java/com/weis/darklaf/ui/scrollpane/DarkScrollBarUI.java b/src/main/java/com/weis/darklaf/ui/scrollpane/DarkScrollBarUI.java index eb585ab4..5d78a842 100644 --- a/src/main/java/com/weis/darklaf/ui/scrollpane/DarkScrollBarUI.java +++ b/src/main/java/com/weis/darklaf/ui/scrollpane/DarkScrollBarUI.java @@ -480,7 +480,8 @@ public class DarkScrollBarUI extends BasicScrollBarUI { final var c = g.getComposite(); g.setComposite(COMPOSITE.derive(THUMB_ALPHA)); var thumbColor = getThumbColor(); - g.setColor(DarkUIUtil.blendColors(thumbBorderColor, thumbColor, 1 - ((thumbAlpha - THUMB_ALPHA)))); + double percent = Math.min(1.0, Math.max(0.0, 1 - (thumbAlpha - THUMB_ALPHA))); + g.setColor(DarkUIUtil.blendColors(thumbBorderColor, thumbColor, percent)); DarkUIUtil.drawRect(g, rect.x, rect.y, rect.width, rect.height, 1); g.setColor(thumbColor); g.fillRect(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); diff --git a/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java b/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java index 13b899b5..504b4507 100644 --- a/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java +++ b/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java @@ -214,7 +214,7 @@ public class DarkTableCellEditor extends DefaultCellEditor { boolean alternativeRow = Boolean.TRUE.equals(table.getClientProperty("JTable.alternateRowColor")); Color alternativeRowColor = UIManager.getColor("Table.alternateRowBackground"); - Color normalColor = UIManager.getColor("Table.background"); + Color normalColor = table.getBackground(); var background = alternativeRow && row % 2 == 1 ? alternativeRowColor : normalColor; var rendererComp = table.getCellRenderer(row, column) diff --git a/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditorToggleButton.java b/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditorToggleButton.java index cb4b4d9c..193e801d 100644 --- a/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditorToggleButton.java +++ b/src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditorToggleButton.java @@ -33,7 +33,7 @@ public class DarkTableCellEditorToggleButton extends AbstractCellEditor implemen boolean alternativeRow = Boolean.TRUE.equals(table.getClientProperty("JTable.alternateRowColor")); Color alternativeRowColor = UIManager.getColor("Table.alternateRowBackground"); - Color normalColor = UIManager.getColor("Table.background"); + Color normalColor = table.getBackground(); var background = alternativeRow && row % 2 == 1 ? alternativeRowColor : normalColor; if (!(isSelected) || table.isEditing()) { toggleButton.setBackground(background); diff --git a/src/main/java/com/weis/darklaf/ui/table/DarkTableCellRenderer.java b/src/main/java/com/weis/darklaf/ui/table/DarkTableCellRenderer.java index 889fc608..f0119b9b 100644 --- a/src/main/java/com/weis/darklaf/ui/table/DarkTableCellRenderer.java +++ b/src/main/java/com/weis/darklaf/ui/table/DarkTableCellRenderer.java @@ -60,7 +60,7 @@ public class DarkTableCellRenderer extends DefaultTableCellRenderer { boolean alternativeRow = Boolean.TRUE.equals(table.getClientProperty("JTable.alternateRowColor")); Color alternativeRowColor = UIManager.getColor("Table.alternateRowBackground"); - Color normalColor = UIManager.getColor("Table.background"); + Color normalColor = table.getBackground(); var background = alternativeRow && row % 2 == 1 ? alternativeRowColor : normalColor; if (!(isSelected) || table.isEditing()) { component.setBackground(background); diff --git a/src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java b/src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java index 09948783..cfba2edb 100644 --- a/src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java +++ b/src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java @@ -185,7 +185,14 @@ public class DarkTableUI extends DarkTableUIBridge { int dist = adjustDistance(distance, vacatedColumnRect, table); // Paint a gray well in place of the moving column. - g.setColor(table.getParent().getBackground()); + Container parent = table.getParent(); + if (isInScrollPane()) { + var par = DarkUIUtil.getParentOfType(JScrollPane.class, table); + if (par != null && par.getParent() != null) { + parent = par.getParent(); + } + } + g.setColor(parent.getBackground()); g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width - 1, vacatedColumnRect.height); diff --git a/src/main/resources/com/weis/darklaf/theme/darcula/darcula_defaults.properties b/src/main/resources/com/weis/darklaf/theme/darcula/darcula_defaults.properties index 79e537e9..64668202 100644 --- a/src/main/resources/com/weis/darklaf/theme/darcula/darcula_defaults.properties +++ b/src/main/resources/com/weis/darklaf/theme/darcula/darcula_defaults.properties @@ -79,7 +79,7 @@ %controlBorderSelected = 6B6B6B %controlBorderFocus = 466D94 %controlBorderFocusSelected = 466D94 -%controlBorderSecondary = C8C8C8 +%controlBorderSecondary = 424242 %controlFill = A0A0A0 %controlFillFocus = A0A0A0 %controlFillSecondary = A0A0A0 diff --git a/src/main/resources/com/weis/darklaf/theme/intellij/intellij_defaults.properties b/src/main/resources/com/weis/darklaf/theme/intellij/intellij_defaults.properties index 6e1c8d2b..490f56c3 100644 --- a/src/main/resources/com/weis/darklaf/theme/intellij/intellij_defaults.properties +++ b/src/main/resources/com/weis/darklaf/theme/intellij/intellij_defaults.properties @@ -81,7 +81,7 @@ %controlBorderSelected = 4982CC %controlBorderFocus = 7B9FC7 %controlBorderFocusSelected = ACCFF7 -%controlBorderSecondary = C8C8C8 +%controlBorderSecondary = B4B4B4 %controlFill = FFFFFF %controlFillSecondary = 808080 %controlTrack = ABABAB