Browse Source

Fixed funky action behaviour.

pull/15/head
weisj 5 years ago
parent
commit
59d46472fd
  1. 6
      src/main/java/com/weis/darklaf/ui/filechooser/DarkFilePane.java
  2. 2
      src/main/java/com/weis/darklaf/ui/menu/DarkMenuItemUIBase.java
  3. 7
      src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java
  4. 3
      src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  5. 6
      src/main/java/com/weis/darklaf/ui/table/DarkTableCellFocusBorder.java
  6. 2
      src/main/java/com/weis/darklaf/ui/table/DarkTableUIBridge.java
  7. 3305
      src/main/java/com/weis/darklaf/ui/table/TableUIBridge.java
  8. 2
      src/main/java/com/weis/darklaf/ui/toolbar/DarkToolBarUIBridge.java
  9. 2
      src/main/java/com/weis/darklaf/util/LazyActionMap.java
  10. 5
      src/main/resources/com/weis/darklaf/properties/ui/fileChooser.properties
  11. 1
      src/main/resources/com/weis/darklaf/properties/ui/tabbedPane.properties
  12. 73
      src/test/java/TabbedPaneKeyboardShortcut.java

6
src/main/java/com/weis/darklaf/ui/filechooser/DarkFilePane.java

@ -87,6 +87,7 @@ public class DarkFilePane extends DarkFilePaneUIBridge {
}; };
list.setCellRenderer(new FileRenderer()); list.setCellRenderer(new FileRenderer());
list.setLayoutOrientation(JList.VERTICAL_WRAP); list.setLayoutOrientation(JList.VERTICAL_WRAP);
LookAndFeel.installColors(list, "FileView.background", "FileView.foreground");
// 4835633 : tell BasicListUI that this is a file list // 4835633 : tell BasicListUI that this is a file list
list.putClientProperty("List.isFileList", Boolean.TRUE); list.putClientProperty("List.isFileList", Boolean.TRUE);
@ -226,7 +227,10 @@ public class DarkFilePane extends DarkFilePaneUIBridge {
OverlayScrollPane overlayScrollPane = new OverlayScrollPane(detailsTable); OverlayScrollPane overlayScrollPane = new OverlayScrollPane(detailsTable);
JScrollPane scrollPane = overlayScrollPane.getScrollPane(); JScrollPane scrollPane = overlayScrollPane.getScrollPane();
scrollPane.setComponentOrientation(chooser.getComponentOrientation()); scrollPane.setComponentOrientation(chooser.getComponentOrientation());
LookAndFeel.installColors(scrollPane.getViewport(), "Table.background", "Table.foreground"); LookAndFeel.installColors(scrollPane.getViewport(),
"FileView.background", "FileView.foreground");
LookAndFeel.installColors(detailsTable,
"FileView.background", "FileView.foreground");
// Adjust width of first column so the table fills the viewport when // Adjust width of first column so the table fills the viewport when
// first displayed (temporary listener). // first displayed (temporary listener).

2
src/main/java/com/weis/darklaf/ui/menu/DarkMenuItemUIBase.java

@ -50,7 +50,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
return new DarkMenuItemUIBase(); return new DarkMenuItemUIBase();
} }
protected static void loadActionMap(@NotNull final LazyActionMap map) { public static void loadActionMap(@NotNull final LazyActionMap map) {
map.put(new Actions(Actions.CLICK)); map.put(new Actions(Actions.CLICK));
} }

7
src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java

@ -257,6 +257,13 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
} }
} }
@Override
protected void paintTabArea(@NotNull final Graphics g, final int tabPlacement, final int selectedIndex) {
g.setColor(DarkColors.get().getTabbedPaneTabAreaBackground());
g.fillRect(0, 0, tabPane.getWidth(), maxTabHeight - 1);
super.paintTabArea(g, tabPlacement, selectedIndex);
}
protected void paintTabAreaBorder(@NotNull final Graphics g, final int tabPlacement, protected void paintTabAreaBorder(@NotNull final Graphics g, final int tabPlacement,
final int x, final int y, final int w, final int h) { final int x, final int y, final int w, final int h) {
g.setColor(getTabBorderColor()); g.setColor(getTabBorderColor());

3
src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java

@ -64,7 +64,6 @@ import java.util.Vector;
*/ */
public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstants { public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstants {
// Instance variables initialized at installation // Instance variables initialized at installation
protected final Insets currentPadInsets = new Insets(0, 0, 0, 0); protected final Insets currentPadInsets = new Insets(0, 0, 0, 0);
@ -224,7 +223,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
// UI Installation/De-installation // UI Installation/De-installation
protected int baseline; protected int baseline;
static void loadActionMap(@NotNull final LazyActionMap map) { public static void loadActionMap(@NotNull final LazyActionMap map) {
map.put(new Actions(Actions.NEXT)); map.put(new Actions(Actions.NEXT));
map.put(new Actions(Actions.PREVIOUS)); map.put(new Actions(Actions.PREVIOUS));
map.put(new Actions(Actions.RIGHT)); map.put(new Actions(Actions.RIGHT));

6
src/main/java/com/weis/darklaf/ui/table/DarkTableCellFocusBorder.java

@ -19,12 +19,12 @@ public class DarkTableCellFocusBorder extends DarkCellBorder {
if (isRowFocusBorder(c)) { if (isRowFocusBorder(c)) {
g.setColor(DarkColors.get().getTableRowBorderColor()); g.setColor(DarkColors.get().getTableRowBorderColor());
g.fillRect(0, 0, width, 1); g.fillRect(0, 0, width, 1);
g.drawRect(0, height - 1, width, 1); g.fillRect(0, height - 1, width, 1);
if (forcePaintLeft(c)) { if (forcePaintLeft(c)) {
g.drawRect(0, 0, 1, height); g.fillRect(0, 0, 1, height);
} }
if (forcePaintRight(c)) { if (forcePaintRight(c)) {
g.drawRect(width - 1, 0, 1, height); g.fillRect(width - 1, 0, 1, height);
} }
} else { } else {
g.setColor(DarkColors.get().getTableFocusBorderColor()); g.setColor(DarkColors.get().getTableFocusBorderColor());

2
src/main/java/com/weis/darklaf/ui/table/DarkTableUIBridge.java

@ -37,7 +37,7 @@ import java.awt.*;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
public class DarkTableUIBridge extends BasicTableUIBridge { public class DarkTableUIBridge extends TableUIBridge {
/** /**
* Paint a representation of the <code>table</code> instance * Paint a representation of the <code>table</code> instance

3305
src/main/java/com/weis/darklaf/ui/table/BasicTableUIBridge.java → src/main/java/com/weis/darklaf/ui/table/TableUIBridge.java

File diff suppressed because it is too large Load Diff

2
src/main/java/com/weis/darklaf/ui/toolbar/DarkToolBarUIBridge.java

@ -144,7 +144,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons
@Deprecated @Deprecated
protected KeyStroke rightKey; protected KeyStroke rightKey;
static void loadActionMap(final LazyActionMap map) { public static void loadActionMap(final LazyActionMap map) {
map.put(new Actions(Actions.NAVIGATE_RIGHT)); map.put(new Actions(Actions.NAVIGATE_RIGHT));
map.put(new Actions(Actions.NAVIGATE_LEFT)); map.put(new Actions(Actions.NAVIGATE_LEFT));
map.put(new Actions(Actions.NAVIGATE_UP)); map.put(new Actions(Actions.NAVIGATE_UP));

2
src/main/java/com/weis/darklaf/util/LazyActionMap.java

@ -21,7 +21,7 @@ public class LazyActionMap extends ActionMapUIResource {
*/ */
private transient Object _loader; private transient Object _loader;
private LazyActionMap(final Class<?> loader) { public LazyActionMap(final Class<?> loader) {
_loader = loader; _loader = loader;
} }

5
src/main/resources/com/weis/darklaf/properties/ui/fileChooser.properties

@ -34,13 +34,16 @@ FileChooser.borderColor = %borderSecondary
FileChooser.rowHeight = 20 FileChooser.rowHeight = 20
FileChooser.minEditDelay = 200 FileChooser.minEditDelay = 200
FileChooser.maxEditDelay = 600 FileChooser.maxEditDelay = 600
FileView.fullRowSelection = true
FileChooser.listViewWindowsStyle = false FileChooser.listViewWindowsStyle = false
FileChooser.fileSizeKiloBytes = {0} kb FileChooser.fileSizeKiloBytes = {0} kb
FileChooser.fileSizeMegaBytes = {0} mb FileChooser.fileSizeMegaBytes = {0} mb
FileChooser.fileSizeGigaBytes = {0} gb FileChooser.fileSizeGigaBytes = {0} gb
FileChooser.readOnly = false FileChooser.readOnly = false
FileView.background = %textBackground
FileView.foreground = %textForeground
FileView.fullRowSelection = true
FileView.fileIcon = files/general.svg[aware] FileView.fileIcon = files/general.svg[aware]
FileView.directoryIcon = files/folder.svg[aware] FileView.directoryIcon = files/folder.svg[aware]
FileView.computerIcon = files/desktop.svg[aware] FileView.computerIcon = files/desktop.svg[aware]

1
src/main/resources/com/weis/darklaf/properties/ui/tabbedPane.properties

@ -32,6 +32,7 @@ TabbedPane.selectedBackground = %backgroundSelected
TabbedPane.focus = %backgroundSelected TabbedPane.focus = %backgroundSelected
TabbedPane.hoverBackground = %backgroundHover TabbedPane.hoverBackground = %backgroundHover
TabbedPane.selectedHoverBackground = %hoverHighlightSecondary TabbedPane.selectedHoverBackground = %hoverHighlightSecondary
TabbedPane.tabAreaBackground = %background
TabbedPane.focusBarHeight = 3 TabbedPane.focusBarHeight = 3
TabbedPane.contentBorderInsets = 0,0,0,0 TabbedPane.contentBorderInsets = 0,0,0,0

73
src/test/java/TabbedPaneKeyboardShortcut.java

@ -0,0 +1,73 @@
/*
* MIT License
*
* Copyright (c) 2019 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.weis.darklaf.LafManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
public class TabbedPaneKeyboardShortcut extends JPanel {
public TabbedPaneKeyboardShortcut() {
initializeUI();
}
private void initializeUI() {
LafManager.install();
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(500, 200));
JTabbedPane pane = new JTabbedPane();
pane.addTab("A Tab", new JPanel());
pane.addTab("B Tab", new JPanel());
pane.addTab("C Tab", new JPanel());
pane.addTab("D Tab", new JPanel());
pane.setMnemonicAt(0, KeyEvent.VK_A);
pane.setMnemonicAt(1, KeyEvent.VK_B);
pane.setMnemonicAt(2, KeyEvent.VK_C);
pane.setMnemonicAt(3, KeyEvent.VK_D);
this.add(pane, BorderLayout.CENTER);
}
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
TabbedPaneKeyboardShortcut.showFrame();
}
});
}
public static void showFrame() {
JPanel panel = new TabbedPaneKeyboardShortcut();
panel.setOpaque(true);
JFrame frame = new JFrame("JTabbedPane Demo");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
}
Loading…
Cancel
Save