Browse Source

Ensure cell backgrounds are consistent between editor and renderer.

Add undo/redo icons.
Add disabled delete icon.
pull/214/head
weisj 4 years ago
parent
commit
6bab2af14d
  1. 5
      core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableModelAdapter.java
  2. 30
      core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableSelectionModel.java
  3. 13
      core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java
  4. 3
      core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java
  5. 2
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboBoxConstants.java
  6. 2
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java
  7. 4
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorToggleButton.java
  8. 12
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRendererDelegate.java
  9. 33
      core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java
  10. 11
      core/src/main/resources/com/github/weisj/darklaf/icons/menu/deleteDisabled.svg
  11. 10
      core/src/main/resources/com/github/weisj/darklaf/icons/menu/redo.svg
  12. 10
      core/src/main/resources/com/github/weisj/darklaf/icons/menu/redoDisabled.svg
  13. 10
      core/src/main/resources/com/github/weisj/darklaf/icons/menu/undo.svg
  14. 10
      core/src/main/resources/com/github/weisj/darklaf/icons/menu/undoDisabled.svg
  15. 4
      core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties
  16. 1
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties

5
core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableModelAdapter.java

@ -63,11 +63,6 @@ public class TreeTableModelAdapter extends AbstractTableModel {
});
}
@Override
public void fireTableRowsDeleted(final int firstRow, final int lastRow) {
super.fireTableRowsDeleted(firstRow, lastRow);
}
public int getColumnCount() {
return treeTableModel.getColumnCount();
}

30
core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableSelectionModel.java

@ -1,30 +0,0 @@
/*
* 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.components.treetable;
import javax.swing.*;
import javax.swing.tree.TreeSelectionModel;
public interface TreeTableSelectionModel extends TreeSelectionModel, ListSelectionModel {}

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

@ -33,7 +33,6 @@ import javax.swing.tree.DefaultTreeCellRenderer;
import com.github.weisj.darklaf.graphics.ColorWrapper;
import com.github.weisj.darklaf.ui.list.DarkListUI;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.table.TableConstants;
import com.github.weisj.darklaf.ui.table.renderer.IconWrapper;
import com.github.weisj.darklaf.ui.tree.DarkTreeUI;
import com.github.weisj.darklaf.util.DarkUIUtil;
@ -251,11 +250,7 @@ public class CellUtil {
public static void setupTableForeground(final Component comp, final JTable parent, final boolean selected,
final int row) {
boolean sel = selected;
if (parent.getSelectionModel().getLeadSelectionIndex() == row) {
sel = !PropertyUtil.getBooleanProperty(parent, TableConstants.KEY_FULL_ROW_FOCUS_BORDER);
}
setupForeground(comp, parent, sel,
setupForeground(comp, parent, selected,
tableCellForeground, tableCellForegroundSelected,
tableCellForegroundNoFocus, tableCellForegroundSelectedNoFocus,
tableCellInactiveForeground, tableCellInactiveForegroundSelected,
@ -312,11 +307,7 @@ public class CellUtil {
final boolean selected, final boolean focus,
final int row) {
boolean alt = row % 2 == 1 && PropertyUtil.getBooleanProperty(parent, DarkTableUI.KEY_ALTERNATE_ROW_COLOR);
boolean sel = selected;
if (parent.getSelectionModel().getLeadSelectionIndex() == row) {
sel = !PropertyUtil.getBooleanProperty(parent, TableConstants.KEY_FULL_ROW_FOCUS_BORDER);
}
return getColor(comp, focus, sel,
return getColor(comp, focus, selected,
alt ? tableCellBackgroundAlternative : tableCellBackground,
tableCellBackgroundSelected,
alt ? tableCellBackgroundNoFocusAlternative : tableCellBackgroundNoFocus,

3
core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java

@ -93,6 +93,7 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellToggleBu
public CellCheckBox(final boolean opaque) {
setOpaque(opaque);
setHorizontalAlignment(CENTER);
setBorderPainted(true);
putClientProperty(ToggleButtonConstants.KEY_IS_TREE_EDITOR, true);
putClientProperty(ToggleButtonConstants.KEY_IS_TABLE_EDITOR, true);
putClientProperty(ToggleButtonConstants.KEY_VERTICAL_ICON_OFFSET, 0);
@ -120,6 +121,7 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellToggleBu
public CellRadioButton(final boolean opaque) {
setOpaque(opaque);
setHorizontalAlignment(CENTER);
setBorderPainted(true);
putClientProperty(ToggleButtonConstants.KEY_IS_TREE_EDITOR, true);
putClientProperty(ToggleButtonConstants.KEY_IS_TABLE_EDITOR, true);
putClientProperty(ToggleButtonConstants.KEY_VERTICAL_ICON_OFFSET, 0);
@ -152,6 +154,7 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellToggleBu
public CellTristateButton(final boolean opaque) {
setOpaque(opaque);
setHorizontalAlignment(CENTER);
setBorderPainted(true);
putClientProperty(ToggleButtonConstants.KEY_IS_TREE_EDITOR, true);
putClientProperty(ToggleButtonConstants.KEY_IS_TABLE_EDITOR, true);
putClientProperty(ToggleButtonConstants.KEY_VERTICAL_ICON_OFFSET, 0);

2
core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboBoxConstants.java

@ -26,8 +26,6 @@ package com.github.weisj.darklaf.ui.combobox;
import java.awt.*;
import javax.swing.*;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.tree.DarkTreeUI;
import com.github.weisj.darklaf.util.PropertyUtil;

2
core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java

@ -126,7 +126,7 @@ public class DarkTableCellEditorDelegate extends TableCellEditorDelegate {
.getTableCellRendererComponent(table, value, isSelected, false, row, column);
setupEditorComponent(editor, value, renderer);
Component comp = applyRendererIcon(editor, renderer);
CellUtil.setupTableBackground(comp, table, true, row);
CellUtil.setupTableBackground(comp, table, false, row);
return comp;
}

4
core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorToggleButton.java

@ -31,7 +31,6 @@ import javax.swing.border.Border;
import javax.swing.table.TableCellEditor;
import com.github.weisj.darklaf.ui.cell.CellToggleButton;
import com.github.weisj.darklaf.ui.table.DarkTableCellBorder;
/**
* @author Jannis Weis
@ -39,10 +38,11 @@ import com.github.weisj.darklaf.ui.table.DarkTableCellBorder;
public class DarkTableCellEditorToggleButton extends AbstractCellEditor implements TableCellEditor, SwingConstants {
private final JToggleButton toggleButton;
private final Border editorBorder = new DarkTableCellBorder();
private final Border editorBorder;
public DarkTableCellEditorToggleButton(final JToggleButton toggleButton) {
this.toggleButton = toggleButton;
this.editorBorder = UIManager.getBorder("Table.booleanEditorBorder");
toggleButton.setFocusable(false);
toggleButton.setOpaque(true);
}

12
core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRendererDelegate.java

@ -61,10 +61,14 @@ public class DarkTableCellRendererDelegate extends TableCellRendererDelegate imp
boolean isRowFocus = DarkTableCellFocusBorder.isRowFocusBorder(table)
&& table.getSelectionModel().getLeadSelectionIndex() == row;
boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table)
&& table.getSelectionModel().getLeadSelectionIndex() == row
&& table.getColumnModel().getSelectionModel().getLeadSelectionIndex() == column;
boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing();
boolean rowLeadSelection = table.getSelectionModel().getLeadSelectionIndex() == row;
boolean columnLeadSelection = table.getColumnModel().getSelectionModel().getLeadSelectionIndex() == column;
if (rowLeadSelection && !columnLeadSelection
&& PropertyUtil.getBooleanProperty(table, TableConstants.KEY_FULL_ROW_FOCUS_BORDER)) {
columnLeadSelection = true;
}
boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table) && rowLeadSelection && columnLeadSelection;
boolean paintSelected = isSelected && !isLeadSelectionCell;
if (component instanceof JComponent) {
setupBorderStyle(table, row, column, (JComponent) component, isLeadSelectionCell, isRowFocus);

33
core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java

@ -233,13 +233,17 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
final GraphicsContext context,
final boolean rounded, final boolean extendLines,
final boolean isPaintingPreceding) {
final int selectionStart = c.getSelectionStart();
final int selectionEnd = c.getSelectionEnd();
Insets ins = c.getInsets();
Rectangle posOffs0 = getPosRect(c, offs0);
Rectangle posOffs1 = getPosRect(c, offs1, Position.Bias.Backward);
Rectangle posStart = getPosRect(c, c.getSelectionStart());
Rectangle posEnd = getPosRect(c, c.getSelectionEnd());
Rectangle posStart = getPosRect(c, selectionStart);
Rectangle posEnd = getPosRect(c, selectionEnd);
int currentLineStart = isPaintingPreceding ? offs0 : getOffset(c, 0, posOffs0.y);
int currentLineEnd = isPaintingPreceding ? offs1 : getOffset(c, c.getWidth(), posOffs1.y);
@ -286,8 +290,8 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
currentLineRect.width = posEnd.x + posEnd.width - currentLineRect.x;
}
boolean hasLineAbove = previousLineEnd >= c.getSelectionStart();
boolean hasLineBelow = nextLineStart <= c.getSelectionEnd();
boolean hasLineAbove = previousLineEnd >= selectionStart;
boolean hasLineBelow = nextLineStart <= selectionEnd;
boolean previousLineVisible = hasLineAbove
&& previousLineRect.width > 0
@ -301,26 +305,26 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
if (extendLines) {
// Adjust the line rects for the adjacent lines for correct rounded corner placement.
extendLine(c, ins, previousLineRect,
hasLineAbove && previousLineStart >= c.getSelectionStart(),
hasLineAbove && previousLineEnd <= c.getSelectionEnd());
hasLineAbove && previousLineStart >= selectionStart,
hasLineAbove && previousLineEnd <= selectionEnd);
boolean extendNextRight = hasLineBelow
&& nextLineEnd < c.getDocument().getLength()
&& getOffset(c, getPosRect(c, nextLineEnd + 1)) <= c.getSelectionEnd();
&& getOffset(c, getPosRect(c, nextLineEnd + 1)) <= selectionEnd;
extendLine(c, ins, nextLineRect,
hasLineBelow && nextLineStart >= c.getSelectionStart(),
hasLineBelow && nextLineStart >= selectionStart,
extendNextRight);
paintPreviousLine = hasLineAbove
&& (previousLineStart == previousLineEnd || previousLineEnd == c.getSelectionStart());
&& (previousLineStart == previousLineEnd || previousLineEnd == selectionStart);
previousLineVisible = hasLineAbove;
if (nextLineRect.y != posEnd.y) nextLineVisible = hasLineBelow;
boolean extendRight = isPaintingPreceding || (hasLineBelow && (endX(layerRect) == endX(currentLineRect)));
extendRight &= offs1 < c.getSelectionEnd();
extendRight &= offs1 < selectionEnd;
boolean extendLeft = isPaintingPreceding || (hasLineAbove && startX(layerRect) == startX(currentLineRect));
extendLeft &= offs0 > c.getSelectionStart();
extendLeft &= offs0 > selectionStart;
extendLine(c, ins, layerRect, extendLeft, extendRight);
extendLine(c, ins, currentLineRect, extendLeft, extendRight);
@ -344,6 +348,9 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
boolean arcBottomRight = nextLineVisible && !roundedBottomRight
&& rightArcVisible(currentLineRect, nextLineRect);
System.out.println(selectionStart + " " + selectionEnd);
System.out.println(posOffs0 + " " + posOffs1);
layerRect = paintRoundRect(g, context, layerRect,
canRoundLeft && roundedTopLeft,
canRoundRight && roundedTopRight,
@ -357,8 +364,8 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
if (paintPreviousLine && !isPaintingPreceding) {
Rectangle prev = paintRoundedLayer(g, c,
Math.max(previousLineStart, c.getSelectionStart()),
Math.min(previousLineEnd, c.getSelectionEnd()),
Math.max(previousLineStart, selectionStart),
Math.min(previousLineEnd, selectionEnd),
context,
rounded, extendLines, true);
convexHull(r, prev);

11
core/src/main/resources/com/github/weisj/darklaf/icons/menu/deleteDisabled.svg

@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.deleteDisabled.color">
<stop offset="0" stop-color="#6E6E6E"/>
<stop offset="1" stop-color="#6E6E6E"/>
</linearGradient>
</defs>
<path fill="url(#Icons.deleteDisabled.color)"
d="M3,1 L3,0 L7,0 L7,1 L10,1 L10,3 L0,3 L0,1 L3,1 Z M1,11.7142858 L1,4 L9,4 L9,11.7142858 C9,12.4214286 8.4,13 7.6666667,13 L2.33333333,13 C1.6,13 1,12.4214286 1,11.7142858 Z"
transform="translate(3 1)"/>
</svg>

After

Width:  |  Height:  |  Size: 588 B

10
core/src/main/resources/com/github/weisj/darklaf/icons/menu/redo.svg

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.redo.color">
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
</defs>
<path fill="url(#Icons.redo.color)"
d="M7.998 4.667c1.767 0 3.368.66 4.601 1.733L15 4v6H8.999l2.413-2.413a5.304 5.304 0 0 0-3.414-1.254A5.342 5.342 0 0 0 2.93 10l-1.58-.52c.927-2.793 3.548-4.813 6.648-4.813z"/>
</svg>

After

Width:  |  Height:  |  Size: 528 B

10
core/src/main/resources/com/github/weisj/darklaf/icons/menu/redoDisabled.svg

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.redoDisabled.color">
<stop offset="0" stop-color="#6E6E6E"/>
<stop offset="1" stop-color="#6E6E6E"/>
</linearGradient>
</defs>
<path fill="url(#Icons.redoDisabled.color)"
d="M7.998 4.667c1.767 0 3.368.66 4.601 1.733L15 4v6H8.999l2.413-2.413a5.304 5.304 0 0 0-3.414-1.254A5.342 5.342 0 0 0 2.93 10l-1.58-.52c.927-2.793 3.548-4.813 6.648-4.813z"/>
</svg>

After

Width:  |  Height:  |  Size: 544 B

10
core/src/main/resources/com/github/weisj/darklaf/icons/menu/undo.svg

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.undo.color">
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
</defs>
<path fill="url(#Icons.undo.color)"
d="M8.002 4.667c-1.767 0-3.368.66-4.601 1.733L1 4v6h6.001L4.588 7.587a5.304 5.304 0 0 1 3.414-1.254c2.36 0 4.367 1.54 5.068 3.667l1.58-.52c-.927-2.793-3.548-4.813-6.648-4.813z"/>
</svg>

After

Width:  |  Height:  |  Size: 532 B

10
core/src/main/resources/com/github/weisj/darklaf/icons/menu/undoDisabled.svg

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.undoDisabled.color">
<stop offset="0" stop-color="#6E6E6E"/>
<stop offset="1" stop-color="#6E6E6E"/>
</linearGradient>
</defs>
<path fill="url(#Icons.undoDisabled.color)"
d="M8.002 4.667c-1.767 0-3.368.66-4.601 1.733L1 4v6h6.001L4.588 7.587a5.304 5.304 0 0 1 3.414-1.254c2.36 0 4.367 1.54 5.068 3.667l1.58-.52c-.927-2.793-3.548-4.813-6.648-4.813z"/>
</svg>

After

Width:  |  Height:  |  Size: 548 B

4
core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties

@ -28,6 +28,10 @@ Icons.copy.color = %menuIconEnabled
Icons.copyDisabled.color = %menuIconDisabled
Icons.cut.color = %menuIconEnabled
Icons.cutDisabled.color = %menuIconDisabled
Icons.undo.color = %menuIconEnabled
Icons.undoDisabled.color = %menuIconDisabled
Icons.redo.color = %menuIconEnabled
Icons.redoDisabled.color = %menuIconDisabled
Icons.delete.color = %menuIconEnabled
Icons.arrowDownSort.color = %menuIconEnabled
Icons.groupBy.color = %menuIconEnabled

1
core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties

@ -41,6 +41,7 @@ Table.focusSelectedCellHighlightBorder = com.github.weisj.darklaf.ui.table.D
Table.cellEditorBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder
Table.scrollPaneBorder = com.github.weisj.darklaf.ui.table.DarkTableScrollPaneBorder
Table.border = com.github.weisj.darklaf.ui.table.DarkTableBorder
Table.booleanEditorBorder = com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder
Table.focusBorderColor = %borderFocus
Table.focusRowBorderColor = %borderFocus
Table.gridColor = %gridLine

Loading…
Cancel
Save