Browse Source

added darcula licence notice.

Reversed cache class (instead values are cached in the ui classes).
Added the possibility to access ui defaults ui class constructors by
resolving them after the defaults have been loaded.
Added popup menu to move tabs in tabFrame.
Fixed an issue where a popup would loose the focus painting when popup menus
were opened or the popup was resized.
pull/15/head
weisj 5 years ago
parent
commit
74701b5865
  1. 201
      licence/DARCULA_LICENCE.txt
  2. 23
      src/jniplatform/cpp/JNIDecorations.cpp
  3. 23
      src/main/java/com/weis/darklaf/DarkLaf.java
  4. 5
      src/main/java/com/weis/darklaf/components/DefaultColorPipette.java
  5. 69
      src/main/java/com/weis/darklaf/components/JXPopupMenu.java
  6. 9
      src/main/java/com/weis/darklaf/components/border/MutableLineBorder.java
  7. 81
      src/main/java/com/weis/darklaf/components/tabframe/TabFrame.java
  8. 22
      src/main/java/com/weis/darklaf/components/tabframe/TabFrameContentPane.java
  9. 27
      src/main/java/com/weis/darklaf/components/tabframe/TabFrameControl.java
  10. 1
      src/main/java/com/weis/darklaf/components/tabframe/TabFrameTab.java
  11. 1
      src/main/java/com/weis/darklaf/components/tabframe/ToggleSplitPane.java
  12. 1823
      src/main/java/com/weis/darklaf/defaults/DarkColors.java
  13. 156
      src/main/java/com/weis/darklaf/defaults/DarkDefaults.java
  14. 411
      src/main/java/com/weis/darklaf/defaults/DarkIcons.java
  15. 28
      src/main/java/com/weis/darklaf/theme/Theme.java
  16. 85
      src/main/java/com/weis/darklaf/ui/button/DarkButtonBorder.java
  17. 153
      src/main/java/com/weis/darklaf/ui/button/DarkButtonUI.java
  18. 35
      src/main/java/com/weis/darklaf/ui/button/DarkToggleButtonUI.java
  19. 5
      src/main/java/com/weis/darklaf/ui/cell/DarkCellRendererToggleButton.java
  20. 33
      src/main/java/com/weis/darklaf/ui/checkbox/DarkCheckBoxUI.java
  21. 5
      src/main/java/com/weis/darklaf/ui/colorchooser/ColorPreviewComponent.java
  22. 22
      src/main/java/com/weis/darklaf/ui/colorchooser/ColorWheel.java
  23. 9
      src/main/java/com/weis/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  24. 4
      src/main/java/com/weis/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java
  25. 3
      src/main/java/com/weis/darklaf/ui/colorchooser/RecentSwatchPanel.java
  26. 29
      src/main/java/com/weis/darklaf/ui/colorchooser/SlideComponent.java
  27. 3
      src/main/java/com/weis/darklaf/ui/colorchooser/SwatchPanel.java
  28. 30
      src/main/java/com/weis/darklaf/ui/combobox/DarkComboBoxUI.java
  29. 12
      src/main/java/com/weis/darklaf/ui/filechooser/DarkFileChooserListViewBorder.java
  30. 3
      src/main/java/com/weis/darklaf/ui/filechooser/DarkFilePaneUIBridge.java
  31. 14
      src/main/java/com/weis/darklaf/ui/internalframe/DarkDesktopIconBorder.java
  32. 5
      src/main/java/com/weis/darklaf/ui/internalframe/DarkDesktopIconUI.java
  33. 5
      src/main/java/com/weis/darklaf/ui/internalframe/DarkInternalFrameBorder.java
  34. 23
      src/main/java/com/weis/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java
  35. 10
      src/main/java/com/weis/darklaf/ui/list/DarkListCellFocusBorder.java
  36. 10
      src/main/java/com/weis/darklaf/ui/menu/DarkMenuBarBorder.java
  37. 11
      src/main/java/com/weis/darklaf/ui/menu/DarkMenuBarUI.java
  38. 5
      src/main/java/com/weis/darklaf/ui/menu/DarkMenuItemUIBase.java
  39. 5
      src/main/java/com/weis/darklaf/ui/menu/DarkMenuUI.java
  40. 19
      src/main/java/com/weis/darklaf/ui/progressbar/DarkProgressBarUI.java
  41. 5
      src/main/java/com/weis/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java
  42. 33
      src/main/java/com/weis/darklaf/ui/radiobutton/DarkRadioButtonUI.java
  43. 16
      src/main/java/com/weis/darklaf/ui/rootpane/CloseButtonUI.java
  44. 23
      src/main/java/com/weis/darklaf/ui/rootpane/DarkTitlePane.java
  45. 17
      src/main/java/com/weis/darklaf/ui/scrollpane/DarkScrollBarUI.java
  46. 87
      src/main/java/com/weis/darklaf/ui/slider/DarkSliderUI.java
  47. 33
      src/main/java/com/weis/darklaf/ui/spinner/DarkSpinnerBorder.java
  48. 45
      src/main/java/com/weis/darklaf/ui/spinner/DarkSpinnerUI.java
  49. 26
      src/main/java/com/weis/darklaf/ui/splitpane/DarkSplitPaneDivider.java
  50. 10
      src/main/java/com/weis/darklaf/ui/splitpane/DarkSplitPaneUI.java
  51. 16
      src/main/java/com/weis/darklaf/ui/statusbar/DarkStatusBarUI.java
  52. 55
      src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java
  53. 6
      src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  54. 8
      src/main/java/com/weis/darklaf/ui/tabbedpane/MoreTabsButton.java
  55. 3
      src/main/java/com/weis/darklaf/ui/tabbedpane/ScrollableTabPanel.java
  56. 5
      src/main/java/com/weis/darklaf/ui/tabbedpane/ScrollableTabViewport.java
  57. 19
      src/main/java/com/weis/darklaf/ui/tabframe/DarkPanelPopupUI.java
  58. 153
      src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java
  59. 5
      src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java
  60. 10
      src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java
  61. 8
      src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameUI.java
  62. 81
      src/main/java/com/weis/darklaf/ui/tabframe/DarkTabbedPopupUI.java
  63. 20
      src/main/java/com/weis/darklaf/ui/table/DarkTableBorder.java
  64. 5
      src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java
  65. 5
      src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditorToggleButton.java
  66. 13
      src/main/java/com/weis/darklaf/ui/table/DarkTableCellFocusBorder.java
  67. 5
      src/main/java/com/weis/darklaf/ui/table/DarkTableCellRenderer.java
  68. 21
      src/main/java/com/weis/darklaf/ui/table/DarkTableHeaderBorder.java
  69. 14
      src/main/java/com/weis/darklaf/ui/table/DarkTableHeaderCorner.java
  70. 15
      src/main/java/com/weis/darklaf/ui/table/DarkTableHeaderUI.java
  71. 14
      src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java
  72. 15
      src/main/java/com/weis/darklaf/ui/table/DarkTableUIBridge.java
  73. 9
      src/main/java/com/weis/darklaf/ui/table/TextFieldTableCellEditorBorder.java
  74. 39
      src/main/java/com/weis/darklaf/ui/taskpane/DarkTaskPaneUI.java
  75. 65
      src/main/java/com/weis/darklaf/ui/text/DarkPasswordFieldUI.java
  76. 84
      src/main/java/com/weis/darklaf/ui/text/DarkTextBorder.java
  77. 83
      src/main/java/com/weis/darklaf/ui/text/DarkTextFieldUI.java
  78. 11
      src/main/java/com/weis/darklaf/ui/titledborder/DarkTitledBorder.java
  79. 14
      src/main/java/com/weis/darklaf/ui/toolbar/DarkToolBarBorder.java
  80. 10
      src/main/java/com/weis/darklaf/ui/toolbar/DarkToolBarUI.java
  81. 9
      src/main/java/com/weis/darklaf/ui/toolbar/DarkToolBarUIBridge.java
  82. 8
      src/main/java/com/weis/darklaf/ui/toolbar/DropPreviewPanel.java
  83. 8
      src/main/java/com/weis/darklaf/ui/tooltip/DarkTooltipBorder.java
  84. 10
      src/main/java/com/weis/darklaf/ui/tree/DarkTreeCellBorder.java
  85. 65
      src/main/java/com/weis/darklaf/ui/tree/DarkTreeUI.java
  86. 17
      src/main/java/com/weis/darklaf/util/DarkUIUtil.java
  87. 120
      src/main/java/com/weis/darklaf/util/PropertyLoader.java
  88. 13
      src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java
  89. 4
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToBottomLeft.svg
  90. 5
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToBottomRight.svg
  91. 4
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToLeftBottom.svg
  92. 4
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToLeftTop.svg
  93. 5
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToRightBottom.svg
  94. 5
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToRightTop.svg
  95. 5
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToTopLeft.svg
  96. 5
      src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToTopRight.svg
  97. 4
      src/main/resources/com/weis/darklaf/icons/light/navigation/moveToBottomLeft.svg
  98. 5
      src/main/resources/com/weis/darklaf/icons/light/navigation/moveToBottomRight.svg
  99. 4
      src/main/resources/com/weis/darklaf/icons/light/navigation/moveToLeftBottom.svg
  100. 4
      src/main/resources/com/weis/darklaf/icons/light/navigation/moveToLeftTop.svg
  101. Some files were not shown because too many files have changed in this diff Show More

201
licence/DARCULA_LICENCE.txt

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

23
src/jniplatform/cpp/JNIDecorations.cpp

@ -66,12 +66,11 @@ LRESULT HitTestNCA(HWND hWnd, WPARAM wParam, LPARAM lParam, WindowWrapper *wrapp
}
// Hit test (HTTOPLEFT, ... HTBOTTOMRIGHT)
LRESULT hitTests[3][3] =
{
{HTTOPLEFT, HTTOP, HTTOPRIGHT},
{HTLEFT, HTNOWHERE, HTRIGHT},
{HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT},
};
LRESULT hitTests[3][3] = {
{HTTOPLEFT, HTTOP, HTTOPRIGHT},
{HTLEFT, HTNOWHERE, HTRIGHT},
{HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT},
};
LRESULT hit = hitTests[uRow][uCol];
if (hit == HTNOWHERE || !wrapper->resizable)
{
@ -105,6 +104,18 @@ LRESULT CALLBACK WindowWrapper::WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_
{
return HitTestNCA(hwnd, wParam, lParam, wrapper);
}
else if (uMsg == WM_GETMINMAXINFO)
{
MINMAXINFO *min_max_info = reinterpret_cast<MINMAXINFO *>(lParam);
RECT max_rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &max_rect, 0);
min_max_info->ptMaxSize.x = max_rect.right - max_rect.left;
min_max_info->ptMaxSize.y = max_rect.bottom - max_rect.top;
min_max_info->ptMaxPosition.x = max_rect.left;
min_max_info->ptMaxPosition.y = max_rect.top;
return 0;
}
return CallWindowProc(wrapper->prev_proc, hwnd, uMsg, wParam, lParam);
}

23
src/main/java/com/weis/darklaf/DarkLaf.java

@ -23,12 +23,10 @@
*/
package com.weis.darklaf;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkDefaults;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.platform.windows.JNIDecorations;
import com.weis.darklaf.theme.Theme;
import com.weis.darklaf.ui.menu.DarkPopupMenuUI;
import com.weis.darklaf.util.PropertyLoader;
import com.weis.darklaf.util.SystemInfo;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -42,6 +40,8 @@ import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Properties;
@ -51,7 +51,7 @@ import java.util.logging.Logger;
/**
* @author Jannis Weis
*/
public class DarkLaf extends BasicLookAndFeel {
public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener {
private static final Logger LOGGER = Logger.getLogger(DarkLaf.class.getName());
@ -256,6 +256,18 @@ public class DarkLaf extends BasicLookAndFeel {
@Override
public void initialize() {
call("initialize");
PropertyLoader.reset();
UIManager.addPropertyChangeListener(this);
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
if ("lookAndFeel".equals(evt.getPropertyName())) {
if (UIManager.getLookAndFeel() == this) {
PropertyLoader.finish();
}
UIManager.removePropertyChangeListener(this);
}
}
@Override
@ -268,9 +280,6 @@ public class DarkLaf extends BasicLookAndFeel {
((DarkPopupMenuUI.MouseGrabber) grabber).uninstall();
}
}
DarkColors.uninstall();
DarkIcons.uninstall();
DarkDefaults.uninstall();
}
@SuppressWarnings({"HardCodedStringLiteral"})

5
src/main/java/com/weis/darklaf/components/DefaultColorPipette.java

@ -1,7 +1,6 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.weis.darklaf.components;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.colorchooser.ColorListener;
import com.weis.darklaf.util.GraphicsUtil;
import com.weis.darklaf.util.TimerUtil;
@ -28,10 +27,12 @@ public class DefaultColorPipette extends ColorPipetteBase {
private final Timer timer;
private Graphics2D zoomGraphics;
private BufferedImage zoomImage;
protected Color borderColor;
public DefaultColorPipette(@NotNull final JComponent parent, @NotNull final ColorListener colorListener) {
super(parent, colorListener);
timer = TimerUtil.createNamedTimer("DefaultColorPipette", 5, e -> updatePipette());
borderColor = UIManager.getColor("ColorChooser.pipetteBorderColor");
}
protected void updatePipette() {
@ -160,7 +161,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
}
protected Color getPipetteBorderColor() {
return DarkColors.get().getColorChooserPipetteBorderColor();
return borderColor;
}
protected static class DefaultPickerWindow extends PickerWindow {

69
src/main/java/com/weis/darklaf/components/JXPopupMenu.java

@ -0,0 +1,69 @@
/*
* 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.
*/
package com.weis.darklaf.components;
import com.weis.darklaf.util.DarkUIUtil;
import org.jdesktop.jxlayer.JXLayer;
import org.pbjar.jxlayer.plaf.ext.TransformUI;
import javax.swing.*;
import java.awt.*;
/**
* Popup menu that is aware of {@link org.pbjar.jxlayer.plaf.ext.TransformUI}.
*/
public class JXPopupMenu extends JPopupMenu {
public JXPopupMenu() {
this(null);
}
/**
* Constructs a <code>JPopupMenu</code> with the specified title.
*
* @param label the string that a UI may use to display as a title
* for the popup menu.
*/
public JXPopupMenu(final String label) {
super(label);
}
@Override
public void show(final Component invoker, final int x, final int y) {
Point p = new Point(x, y);
if (invoker != null) {
JXLayer layer = DarkUIUtil.getParentOfType(JXLayer.class, invoker);
if (layer != null && layer.getUI() instanceof TransformUI) {
var ui = (TransformUI) layer.getUI();
p = SwingUtilities.convertPoint(invoker, p, layer);
//noinspection unchecked
var transform = ui.getPreferredTransform(layer.getSize(), layer);
transform.transform(p, p);
super.show(layer, p.x, p.y);
return;
}
}
super.show(invoker, p.x, p.y);
}
}

9
src/main/java/com/weis/darklaf/components/border/MutableLineBorder.java

@ -22,11 +22,10 @@ public class MutableLineBorder extends EmptyBorder {
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
final int width, final int height) {
g.setColor(getColor());
var insets = getBorderInsets();
g.fillRect(x, y, width - insets.right, insets.top);
g.fillRect(x, y + insets.top, insets.left, height - insets.top);
g.fillRect(x + insets.left, y + height - insets.bottom, width - insets.left, insets.bottom);
g.fillRect(x + width - insets.right, y, insets.right, height - insets.bottom);
g.fillRect(x, y, width - right, top);
g.fillRect(x, y + top, left, height - top);
g.fillRect(x + left, y + height - bottom, width - left, bottom);
g.fillRect(x + width - right, y, right, height - bottom);
}
@Override

81
src/main/java/com/weis/darklaf/components/tabframe/TabFrame.java

@ -303,8 +303,23 @@ public class TabFrame extends JComponent {
if (a == Alignment.CENTER) {
return;
}
var tabComponent = createDefaultTab(title, icon, a, index);
insertTabComp(tabComponent, a, index);
insertTab(c, createDefaultTab(title, icon, a, index), a, index);
}
/**
* Insert a tab.
* A default tab component will be created.
*
* @param c the popup to add.
* @param tab the corresponding tab.
* @param a the alignment position to add at.{@link TabFramePosition#getAlignment()}
* @param index the index to insert at.{@link TabFramePosition#getIndex()}
*/
public void insertTab(@NotNull final TabFramePopup c, final TabFrameTab tab, final Alignment a, final int index) {
if (a == Alignment.CENTER) {
return;
}
insertTabComp(tab, a, index);
compsForAlignment(a).add(index, c);
c.setEnabled(false);
c.setTabFrame(this);
@ -658,6 +673,35 @@ public class TabFrame extends JComponent {
insertTab(c, title, icon, a, tabsForAlignment(a).size());
}
/**
* Move a tab to a new position.
*
* @param tabComp the tab to move.
* @param a the new alignment position.{@link TabFramePosition#getAlignment()}
*/
public void moveTab(@NotNull final TabFrameTab tabComp, final Alignment a) {
if (a == tabComp.getOrientation()) {
return;
}
boolean oldSelected = tabComp.isSelected();
var oldAlign = tabComp.getOrientation();
var oldIndex = tabComp.getIndex();
closeTab(oldAlign, oldIndex);
var comp = compsForAlignment(oldAlign).get(oldIndex);
removeTab(oldAlign, oldIndex);
addTab(comp, tabComp, a);
if (oldSelected) {
openTab(a, tabComp.getIndex());
}
doLayout();
getTabContainer(a).repaint();
}
/**
* Remove a popup.
*
@ -675,35 +719,14 @@ public class TabFrame extends JComponent {
}
/**
* Move a tab to a new position.
* Add a popup.
*
* @param tabComp the tab to move.
* @param a the new alignment position.{@link TabFramePosition#getAlignment()}
* @param c the popup.
* @param tab the corresponding tab.
* @param a the alignment position.{@link TabFramePosition#getAlignment()}
*/
public void moveTab(@NotNull final TabFrameTab tabComp, final Alignment a) {
if (a == tabComp.getOrientation()) {
return;
}
boolean oldSelected = tabComp.isSelected();
var oldAlign = tabComp.getOrientation();
int index = tabComp.getIndex();
compsForAlignment(oldAlign).get(index).close();
removeTabComp(oldAlign, index);
var comp = compsForAlignment(oldAlign).remove(index);
int newIndex = tabsForAlignment(a).size();
insertTabComp(tabComp, a, newIndex);
compsForAlignment(a).add(newIndex, comp);
tabComp.setSelected(oldSelected);
notifySelectionChange(tabComp);
comp.setIndex(newIndex);
comp.setAlignment(a);
doLayout();
getTabContainer(oldAlign).repaint();
getTabContainer(a).repaint();
public void addTab(final TabFramePopup c, final TabFrameTab tab, final Alignment a) {
insertTab(c, tab, a, tabsForAlignment(a).size());
}
/*

22
src/main/java/com/weis/darklaf/components/tabframe/TabFrameContentPane.java

@ -70,29 +70,29 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
PopupContainer bottomRightPanel = new PopupContainer();
PopupContainer leftTopPanel = new PopupContainer();
rightSplitter = new ToggleSplitPane("rightSplitter");
rightSplitter = new TabFrameSplitPane("rightSplitter");
rightSplitter.setOrientation(JSplitPane.VERTICAL_SPLIT);
rightSplitter.setTopComponent(rightTopPanel);
rightSplitter.setBottomComponent(rightBottomPanel);
leftSplitter = new ToggleSplitPane("leftSplitter");
leftSplitter = new TabFrameSplitPane("leftSplitter");
leftSplitter.setOrientation(JSplitPane.VERTICAL_SPLIT);
leftSplitter.setTopComponent(leftTopPanel);
leftSplitter.setBottomComponent(leftBottomPanel);
topSplitter = new ToggleSplitPane("topSplitter");
topSplitter = new TabFrameSplitPane("topSplitter");
topSplitter.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
topSplitter.setLeftComponent(topLeftPanel);
topSplitter.setRightComponent(topRightPanel);
bottomSplitter = new ToggleSplitPane("bottomSplitter");
bottomSplitter = new TabFrameSplitPane("bottomSplitter");
bottomSplitter.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
bottomSplitter.setLeftComponent(bottomLeftPanel);
bottomSplitter.setRightComponent(bottomRightPanel);
topSplit = new ToggleSplitPane("topSplit");
bottomSplit = new ToggleSplitPane("bottomSplit");
topSplit = new TabFrameSplitPane("topSplit");
bottomSplit = new TabFrameSplitPane("bottomSplit");
topSplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
bottomSplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
@ -100,8 +100,8 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
topSplit.setBottomComponent(bottomSplit);
bottomSplit.setBottomComponent(bottomSplitter);
leftSplit = new ToggleSplitPane("leftSplit");
rightSplit = new ToggleSplitPane("rightSplit");
leftSplit = new TabFrameSplitPane("leftSplit");
rightSplit = new TabFrameSplitPane("rightSplit");
leftSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
rightSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
@ -446,4 +446,10 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
this.splitterPeerDisable = splitterPeerDisable;
}
}
protected static class TabFrameSplitPane extends ToggleSplitPane implements TabFrameControl {
protected TabFrameSplitPane(final String name) {
super(name);
}
}
}

27
src/main/java/com/weis/darklaf/components/tabframe/TabFrameControl.java

@ -0,0 +1,27 @@
/*
* 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.
*/
package com.weis.darklaf.components.tabframe;
public interface TabFrameControl {
}

1
src/main/java/com/weis/darklaf/components/tabframe/TabFrameTab.java

@ -105,4 +105,5 @@ public interface TabFrameTab {
* @param tabFrame the TabFrame.
*/
void setTabFrame(TabFrame tabFrame);
}

1
src/main/java/com/weis/darklaf/components/tabframe/ToggleSplitPane.java

@ -155,5 +155,4 @@ public class ToggleSplitPane extends JSplitPane {
: comp.getMinimumSize().height;
}
}

1823
src/main/java/com/weis/darklaf/defaults/DarkColors.java

File diff suppressed because it is too large Load Diff

156
src/main/java/com/weis/darklaf/defaults/DarkDefaults.java

@ -1,156 +0,0 @@
/*
* 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.
*/
package com.weis.darklaf.defaults;
import javax.swing.*;
@SuppressWarnings("WeakerAccess")
public class DarkDefaults {
protected static DarkDefaults instance;
protected int ButtonArc = -1;
protected int ButtonFocusArc = -1;
protected int ButtonSquareFocusArc = -1;
protected int ButtonBorderSize = -1;
protected int ButtonShadowSize = -1;
protected int SpinnerArc = -1;
protected int TextFieldBorderSize = -1;
protected int SpinnerBorderSize = -1;
protected int TabFrameTabHeight = -1;
protected int TaskPaneArc = -1;
protected int ButtonSquareArc = -1;
protected int ButtonMinimumArc = -1;
public static DarkDefaults get() {
if (instance == null) {
instance = new DarkDefaults();
}
return instance;
}
public static void uninstall() {
if (instance == null) return;
instance.uninstallDefaults();
instance = null;
}
protected void uninstallDefaults() {
ButtonArc = -1;
ButtonFocusArc = -1;
ButtonSquareFocusArc = -1;
ButtonBorderSize = -1;
ButtonShadowSize = -1;
SpinnerArc = -1;
TextFieldBorderSize = -1;
SpinnerBorderSize = -1;
TabFrameTabHeight = -1;
TaskPaneArc = -1;
ButtonSquareArc = -1;
ButtonMinimumArc = -1;
}
public int getButtonArc() {
if (ButtonArc < 0) {
ButtonArc = UIManager.getInt("Button.arc");
}
return ButtonArc;
}
public int getButtonFocusArc() {
if (ButtonFocusArc < 0) {
ButtonFocusArc = UIManager.getInt("Button.focusArc");
}
return ButtonFocusArc;
}
public int getButtonSquareFocusArc() {
if (ButtonSquareFocusArc < 0) {
ButtonSquareFocusArc = UIManager.getInt("Button.squareFocusArc");
}
return ButtonSquareFocusArc;
}
public int getButtonBorderSize() {
if (ButtonBorderSize < 0) {
ButtonBorderSize = UIManager.getInt("Button.borderThickness");
}
return ButtonBorderSize;
}
public int getButtonShadowSize() {
if (ButtonShadowSize < 0) {
ButtonShadowSize = UIManager.getInt("Button.shadowHeight");
}
return ButtonShadowSize;
}
public int getSpinnerArc() {
if (SpinnerArc < 0) {
SpinnerArc = UIManager.getInt("Spinner.arc");
}
return SpinnerArc;
}
public int getTextFieldBorderSize() {
if (TextFieldBorderSize < 0) {
TextFieldBorderSize = UIManager.getInt("TextField.borderThickness");
}
return TextFieldBorderSize;
}
public int getSpinnerBorderSize() {
if (SpinnerBorderSize < 0) {
SpinnerBorderSize = UIManager.getInt("Spinner.borderThickness");
}
return SpinnerBorderSize;
}
public int getTabFrameTabHeight() {
if (TabFrameTabHeight < 0) {
TabFrameTabHeight = UIManager.getInt("TabFrame.tabHeight");
}
return TabFrameTabHeight;
}
public int getTaskPaneArc() {
if (TaskPaneArc < 0) {
TaskPaneArc = UIManager.getInt("TaskPane.arc");
}
return TaskPaneArc;
}
public int getButtonSquareArc() {
if (ButtonSquareArc < 0) {
ButtonSquareArc = UIManager.getInt("Button.squareArc");
}
return ButtonSquareArc;
}
public int getButtonMinimumArc() {
if (ButtonMinimumArc < 0) {
ButtonMinimumArc = UIManager.getInt("Button.minimumArc");
}
return ButtonMinimumArc;
}
}

411
src/main/java/com/weis/darklaf/defaults/DarkIcons.java

@ -1,411 +0,0 @@
/*
* 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.
*/
package com.weis.darklaf.defaults;
import com.weis.darklaf.icons.UIAwareIcon;
import javax.swing.*;
@SuppressWarnings("WeakerAccess")
public class DarkIcons {
protected static DarkIcons instance;
protected Icon SplitPaneDividerLeftOneTouch;
protected Icon SplitPaneDividerRightOneTouch;
protected Icon SplitPaneDividerTopOneTouch;
protected Icon SplitPaneDividerBottomOneTouch;
protected Icon SplitPaneDividerVerticalSplit;
protected Icon SplitPaneDividerHorizontalSplit;
protected Icon PasswordFiledShow;
protected Icon PasswordFiledShowPressed;
protected Icon TreeExpandedFocusedSelected;
protected Icon TreeExpandedSelected;
protected Icon TreeExpandedFocused;
protected Icon TreeExpanded;
protected Icon TreeCollapsedFocusedSelected;
protected Icon TreeCollapsedSelected;
protected Icon TreeCollapsedFocused;
protected Icon TreeCollapsed;
protected Icon TextFieldClearHover;
protected Icon TextFieldClear;
protected Icon TextFieldSearchHistory;
protected Icon TextFieldSearch;
protected Icon SliderVolumeLevel0;
protected Icon SliderVolumeLevel1;
protected Icon SliderVolumeLevel2;
protected Icon SliderVolumeLevel3;
protected Icon SliderVolumeLevel4;
protected Icon SliderVolumeLevel0Inactive;
protected Icon SliderVolumeLevel1Inactive;
protected Icon SliderVolumeLevel2Inactive;
protected Icon SliderVolumeLevel3Inactive;
protected Icon SliderVolumeLevel4Inactive;
protected Icon ColorChooserPipette;
protected Icon ColorChooserPipetteHover;
protected Icon TabbedPaneMoreTabs;
protected Icon TabbedPaneNewTabs;
protected Icon ToolBarHorizontalGrip;
protected Icon ToolBarVerticalGrip;
protected UIAwareIcon SpinnerMathUp;
protected UIAwareIcon SpinnerMathDown;
protected UIAwareIcon SpinnerArrowUp;
protected UIAwareIcon SpinnerArrowDown;
public static DarkIcons get() {
if (instance == null) {
instance = new DarkIcons();
}
return instance;
}
public static void uninstall() {
if (instance == null) return;
instance.uninstallIcons();
instance = null;
}
protected void uninstallIcons() {
SplitPaneDividerLeftOneTouch = null;
SplitPaneDividerRightOneTouch = null;
SplitPaneDividerTopOneTouch = null;
SplitPaneDividerBottomOneTouch = null;
SplitPaneDividerVerticalSplit = null;
SplitPaneDividerHorizontalSplit = null;
PasswordFiledShow = null;
PasswordFiledShowPressed = null;
TreeExpandedFocusedSelected = null;
TreeExpandedSelected = null;
TreeExpandedFocused = null;
TreeExpanded = null;
TreeCollapsedFocusedSelected = null;
TreeCollapsedSelected = null;
TreeCollapsedFocused = null;
TreeCollapsed = null;
TextFieldClearHover = null;
TextFieldClear = null;
TextFieldSearchHistory = null;
TextFieldSearch = null;
SliderVolumeLevel0 = null;
SliderVolumeLevel1 = null;
SliderVolumeLevel2 = null;
SliderVolumeLevel3 = null;
SliderVolumeLevel4 = null;
SliderVolumeLevel0Inactive = null;
SliderVolumeLevel1Inactive = null;
SliderVolumeLevel2Inactive = null;
SliderVolumeLevel3Inactive = null;
SliderVolumeLevel4Inactive = null;
ColorChooserPipette = null;
ColorChooserPipetteHover = null;
TabbedPaneMoreTabs = null;
TabbedPaneNewTabs = null;
ToolBarHorizontalGrip = null;
ToolBarVerticalGrip = null;
SpinnerMathUp = null;
SpinnerMathDown = null;
SpinnerArrowUp = null;
SpinnerArrowDown = null;
}
public Icon getSplitPaneDividerLeftOneTouch() {
if (SplitPaneDividerLeftOneTouch == null) {
SplitPaneDividerLeftOneTouch = UIManager.getIcon("SplitPaneDivider.leftOneTouch.icon");
}
return SplitPaneDividerLeftOneTouch;
}
public Icon getSplitPaneDividerRightOneTouch() {
if (SplitPaneDividerRightOneTouch == null) {
SplitPaneDividerRightOneTouch = UIManager.getIcon("SplitPaneDivider.rightOneTouch.icon");
}
return SplitPaneDividerRightOneTouch;
}
public Icon getSplitPaneDividerTopOneTouch() {
if (SplitPaneDividerTopOneTouch == null) {
SplitPaneDividerTopOneTouch = UIManager.getIcon("SplitPaneDivider.topOneTouch.icon");
}
return SplitPaneDividerTopOneTouch;
}
public Icon getSplitPaneDividerBottomOneTouch() {
if (SplitPaneDividerBottomOneTouch == null) {
SplitPaneDividerBottomOneTouch = UIManager.getIcon("SplitPaneDivider.bottomOneTouch.icon");
}
return SplitPaneDividerBottomOneTouch;
}
public Icon getSplitPaneDividerVerticalSplit() {
if (SplitPaneDividerVerticalSplit == null) {
SplitPaneDividerVerticalSplit = UIManager.getIcon("SplitPane.verticalGlue.icon");
}
return SplitPaneDividerVerticalSplit;
}
public Icon getSplitPaneDividerHorizontalSplit() {
if (SplitPaneDividerHorizontalSplit == null) {
SplitPaneDividerHorizontalSplit = UIManager.getIcon("SplitPane.horizontalGlue.icon");
}
return SplitPaneDividerHorizontalSplit;
}
public Icon getPasswordFiledShow() {
if (PasswordFiledShow == null) {
PasswordFiledShow = UIManager.getIcon("PasswordField.show.icon");
}
return PasswordFiledShow;
}
public Icon getPasswordFiledShowPressed() {
if (PasswordFiledShowPressed == null) {
PasswordFiledShowPressed = UIManager.getIcon("PasswordField.showPressed.icon");
}
return PasswordFiledShowPressed;
}
public Icon getTreeExpandedFocusedSelected() {
if (TreeExpandedFocusedSelected == null) {
TreeExpandedFocusedSelected = UIManager.getIcon("Tree.expanded.selected.focused.icon");
}
return TreeExpandedFocusedSelected;
}
public Icon getTreeExpandedSelected() {
if (TreeExpandedSelected == null) {
TreeExpandedSelected = UIManager.getIcon("Tree.expanded.selected.unfocused.icon");
}
return TreeExpandedSelected;
}
public Icon getTreeExpandedFocused() {
if (TreeExpandedFocused == null) {
TreeExpandedFocused = UIManager.getIcon("Tree.expanded.unselected.focused.icon");
}
return TreeExpandedFocused;
}
public Icon getTreeExpanded() {
if (TreeExpanded == null) {
TreeExpanded = UIManager.getIcon("Tree.expanded.unselected.unfocused.icon");
}
return TreeExpanded;
}
public Icon getTreeCollapsedFocusedSelected() {
if (TreeCollapsedFocusedSelected == null) {
TreeCollapsedFocusedSelected = UIManager.getIcon("Tree.collapsed.selected.focused.icon");
}
return TreeCollapsedFocusedSelected;
}
public Icon getTreeCollapsedSelected() {
if (TreeCollapsedSelected == null) {
TreeCollapsedSelected = UIManager.getIcon("Tree.collapsed.selected.unfocused.icon");
}
return TreeCollapsedSelected;
}
public Icon getTreeCollapsedFocused() {
if (TreeCollapsedFocused == null) {
TreeCollapsedFocused = UIManager.getIcon("Tree.collapsed.unselected.focused.icon");
}
return TreeCollapsedFocused;
}
public Icon getTreeCollapsed() {
if (TreeCollapsed == null) {
TreeCollapsed = UIManager.getIcon("Tree.collapsed.unselected.unfocused.icon");
}
return TreeCollapsed;
}
public Icon getTextFieldClearHover() {
if (TextFieldClearHover == null) {
TextFieldClearHover = UIManager.getIcon("TextField.search.clearHover.icon");
}
return TextFieldClearHover;
}
public Icon getTextFieldClear() {
if (TextFieldClear == null) {
TextFieldClear = UIManager.getIcon("TextField.search.clear.icon");
}
return TextFieldClear;
}
public Icon getTextFieldSearchHistory() {
if (TextFieldSearchHistory == null) {
TextFieldSearchHistory = UIManager.getIcon("TextField.search.searchWithHistory.icon");
}
return TextFieldSearchHistory;
}
public Icon getTextFieldSearch() {
if (TextFieldSearch == null) {
TextFieldSearch = UIManager.getIcon("TextField.search.search.icon");
}
return TextFieldSearch;
}
public Icon getSliderVolumeLevel0() {
if (SliderVolumeLevel0 == null) {
SliderVolumeLevel0 = UIManager.getIcon("Slider.volume.enabled_level_0.icon");
}
return SliderVolumeLevel0;
}
public Icon getSliderVolumeLevel1() {
if (SliderVolumeLevel1 == null) {
SliderVolumeLevel1 = UIManager.getIcon("Slider.volume.enabled_level_1.icon");
}
return SliderVolumeLevel1;
}
public Icon getSliderVolumeLevel2() {
if (SliderVolumeLevel2 == null) {
SliderVolumeLevel2 = UIManager.getIcon("Slider.volume.enabled_level_2.icon");
}
return SliderVolumeLevel2;
}
public Icon getSliderVolumeLevel3() {
if (SliderVolumeLevel3 == null) {
SliderVolumeLevel3 = UIManager.getIcon("Slider.volume.enabled_level_3.icon");
}
return SliderVolumeLevel3;
}
public Icon getSliderVolumeLevel4() {
if (SliderVolumeLevel4 == null) {
SliderVolumeLevel4 = UIManager.getIcon("Slider.volume.enabled_level_4.icon");
}
return SliderVolumeLevel4;
}
public Icon getSliderVolumeLevel0Inactive() {
if (SliderVolumeLevel0Inactive == null) {
SliderVolumeLevel0Inactive = UIManager.getIcon("Slider.volume.disabled_level_0.icon");
}
return SliderVolumeLevel0Inactive;
}
public Icon getSliderVolumeLevel1Inactive() {
if (SliderVolumeLevel1Inactive == null) {
SliderVolumeLevel1Inactive = UIManager.getIcon("Slider.volume.disabled_level_1.icon");
}
return SliderVolumeLevel1Inactive;
}
public Icon getSliderVolumeLevel2Inactive() {
if (SliderVolumeLevel2Inactive == null) {
SliderVolumeLevel2Inactive = UIManager.getIcon("Slider.volume.disabled_level_2.icon");
}
return SliderVolumeLevel2Inactive;
}
public Icon getSliderVolumeLevel3Inactive() {
if (SliderVolumeLevel3Inactive == null) {
SliderVolumeLevel3Inactive = UIManager.getIcon("Slider.volume.disabled_level_3.icon");
}
return SliderVolumeLevel3Inactive;
}
public Icon getSliderVolumeLevel4Inactive() {
if (SliderVolumeLevel4Inactive == null) {
SliderVolumeLevel4Inactive = UIManager.getIcon("Slider.volume.disabled_level_4.icon");
}
return SliderVolumeLevel4Inactive;
}
public Icon getColorChooserPipette() {
if (ColorChooserPipette == null) {
ColorChooserPipette = UIManager.getIcon("ColorChooser.pipette.icon");
}
return ColorChooserPipette;
}
public Icon getColorChooserPipetteHover() {
if (ColorChooserPipetteHover == null) {
ColorChooserPipetteHover = UIManager.getIcon("ColorChooser.pipetteRollover.icon");
}
return ColorChooserPipetteHover;
}
public UIAwareIcon getSpinnerArrowDown() {
if (SpinnerArrowDown == null) {
SpinnerArrowDown = (UIAwareIcon) UIManager.getIcon("ArrowButton.down.icon");
}
return SpinnerArrowDown;
}
public UIAwareIcon getSpinnerArrowUp() {
if (SpinnerArrowUp == null) {
SpinnerArrowUp = (UIAwareIcon) UIManager.getIcon("ArrowButton.up.icon");
}
return SpinnerArrowUp;
}
public UIAwareIcon getSpinnerMathDown() {
if (SpinnerMathDown == null) {
SpinnerMathDown = (UIAwareIcon) UIManager.getIcon("Spinner.minus.icon");
}
return SpinnerMathDown;
}
public UIAwareIcon getSpinnerMathUp() {
if (SpinnerMathUp == null) {
SpinnerMathUp = (UIAwareIcon) UIManager.getIcon("Spinner.plus.icon");
}
return SpinnerMathUp;
}
public Icon getTabbedPaneMoreTabs() {
if (TabbedPaneMoreTabs == null) {
TabbedPaneMoreTabs = UIManager.getIcon("TabbedPane.moreTabs.icon");
}
return TabbedPaneMoreTabs;
}
public Icon getTabbedPaneNewTabs() {
if (TabbedPaneNewTabs == null) {
TabbedPaneNewTabs = UIManager.getIcon("TabbedPane.newTab.icon");
}
return TabbedPaneNewTabs;
}
public Icon getToolBarHorizontalGrip() {
if (ToolBarHorizontalGrip == null) {
ToolBarHorizontalGrip = UIManager.getIcon("ToolBar.horizontalGrip.icon");
}
return ToolBarHorizontalGrip;
}
public Icon getToolBarVerticalGrip() {
if (ToolBarVerticalGrip == null) {
ToolBarVerticalGrip = UIManager.getIcon("ToolBar.verticalGrip.icon");
}
return ToolBarVerticalGrip;
}
}

28
src/main/java/com/weis/darklaf/theme/Theme.java

@ -2,7 +2,7 @@ package com.weis.darklaf.theme;
import com.weis.darklaf.DarkLaf;
import com.weis.darklaf.DarkMetalTheme;
import com.weis.darklaf.util.LafUtil;
import com.weis.darklaf.util.PropertyLoader;
import com.weis.darklaf.util.SystemInfo;
import org.jetbrains.annotations.NotNull;
@ -39,39 +39,27 @@ public abstract class Theme {
public void loadDefaults(@NotNull final Properties properties, final UIDefaults currentDefaults) {
var name = getResourcePath() + getName() + "_defaults.properties";
putProperties(load(name), properties, currentDefaults);
PropertyLoader.putProperties(load(name), properties, currentDefaults);
}
public void loadGlobals(@NotNull final Properties properties, final UIDefaults currentDefaults) {
putProperties(LafUtil.loadProperties(DarkLaf.class, "globals", "properties/"), properties,
currentDefaults);
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "globals", "properties/"),
properties, currentDefaults);
}
public void loadPlatformProperties(final Properties properties, final UIDefaults currentDefaults) {
final String osPrefix = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux";
putProperties(LafUtil.loadProperties(DarkLaf.class, osPrefix, "properties/platform/"), properties,
currentDefaults);
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, osPrefix, "properties/platform/"),
properties, currentDefaults);
}
public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) {
for (var property : UI_PROPERTIES) {
putProperties(LafUtil.loadProperties(DarkLaf.class, property, "properties/ui/"), properties,
currentDefaults);
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, property, "properties/ui/"),
properties, currentDefaults);
}
}
protected void putProperties(@NotNull final Properties properties, final Properties accumulator,
final UIDefaults currentDefaults) {
for (final String key : properties.stringPropertyNames()) {
final String value = properties.getProperty(key);
var parsed = LafUtil.parseValue(key, value, accumulator);
if (parsed != null) {
accumulator.put(key, parsed);
} else {
currentDefaults.remove(key);
}
}
}
protected Properties load(final String name) {
final Properties properties = new Properties();

85
src/main/java/com/weis/darklaf/ui/button/DarkButtonBorder.java

@ -23,8 +23,6 @@
*/
package com.weis.darklaf.ui.button;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkDefaults;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
@ -44,6 +42,35 @@ import java.awt.geom.RoundRectangle2D;
*/
public class DarkButtonBorder implements Border, UIResource {
private Color shadowColor;
private Color focusBorderColor;
private Color defaultBorderColor;
private Color borderColor;
private Color inactiveBorderColor;
private int arc;
private int focusArc;
private int squareFocusArc;
private int squareArc;
private int minimumArc;
private int borderSize;
private int shadowSize;
public DarkButtonBorder() {
shadowColor = UIManager.getColor("Button.shadow");
focusBorderColor = UIManager.getColor("Button.focusBorderColor");
defaultBorderColor = UIManager.getColor("Button.defaultBorderColor");
borderColor = UIManager.getColor("Button.activeBorderColor");
inactiveBorderColor = UIManager.getColor("Button.inactiveBorderColor");
arc = UIManager.getInt("Button.arc");
focusArc = UIManager.getInt("Button.focusArc");
squareFocusArc = UIManager.getInt("Button.squareFocusArc");
squareArc = UIManager.getInt("Button.squareArc");
minimumArc = UIManager.getInt("Button.minimumArc");
borderSize = UIManager.getInt("Button.borderThickness");
shadowSize = UIManager.getInt("Button.shadowHeight");
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g,
final int x, final int y, final int width, final int height) {
@ -75,26 +102,18 @@ public class DarkButtonBorder implements Border, UIResource {
config.restore();
}
public static int getArc(final Component c) {
protected int getArc(final Component c) {
if (DarkButtonUI.isNoArc(c)) return 0;
boolean square = DarkButtonUI.isSquare(c);
boolean alt = DarkButtonUI.chooseAlternativeArc(c);
return square ? alt ? getArcSize()
: getSquareArcSize()
: alt ? getSquareArcSize() : getArcSize();
}
public static int getSquareArcSize() {
return DarkDefaults.get().getButtonSquareArc();
return square ? alt ? arc : squareArc : alt ? squareArc : arc;
}
public static int getFocusArc(final Component c) {
if (DarkButtonUI.isNoArc(c)) return getMinimumArc();
protected int getFocusArc(final Component c) {
if (DarkButtonUI.isNoArc(c)) return minimumArc;
boolean square = DarkButtonUI.isSquare(c);
boolean alt = DarkButtonUI.chooseAlternativeArc(c);
return square ? alt ? getFocusArcSize()
: getSquareFocusArcSize()
: alt ? getSquareFocusArcSize() : getFocusArcSize();
return square ? alt ? focusArc : squareFocusArc : alt ? squareFocusArc : focusArc;
}
private void paintShadow(@NotNull final Graphics2D g2, final int width, final int height, final int arc) {
@ -110,47 +129,31 @@ public class DarkButtonBorder implements Border, UIResource {
arc, arc));
shadowShape.subtract(innerArea);
g2.setComposite(DarkUIUtil.SHADOW_COMPOSITE);
g2.setColor(DarkColors.get().getButtonShadowColor());
g2.setColor(shadowColor);
g2.fill(shadowShape);
context.restore();
}
public static int getShadowSize() {
return DarkDefaults.get().getButtonShadowSize();
protected int getBorderSize() {
return borderSize;
}
public static int getBorderSize() {
return DarkDefaults.get().getButtonBorderSize();
protected int getShadowSize() {
return shadowSize;
}
private Color getBorderColor(@NotNull final Component c) {
protected Color getBorderColor(@NotNull final Component c) {
if (c.hasFocus()) {
return DarkColors.get().getButtonFocusBorderColor();
return focusBorderColor;
} else if (c instanceof JButton && ((JButton) c).isDefaultButton() && c.isEnabled()) {
return DarkColors.get().getButtonDefaultBorderColor();
return defaultBorderColor;
} else if (c.isEnabled()) {
return DarkColors.get().getButtonBorderColor();
return borderColor;
} else {
return DarkColors.get().getButtonInactiveBorderColor();
return inactiveBorderColor;
}
}
public static int getArcSize() {
return DarkDefaults.get().getButtonArc();
}
public static int getMinimumArc() {
return DarkDefaults.get().getButtonMinimumArc();
}
public static int getSquareFocusArcSize() {
return DarkDefaults.get().getButtonSquareFocusArc();
}
public static int getFocusArcSize() {
return DarkDefaults.get().getButtonFocusArc();
}
public Insets getBorderInsets(final Component c) {
if (DarkButtonUI.isFullShadow(c) || DarkButtonUI.isLabelButton(c)) {
return new InsetsUIResource(0, 0, 0, 0);

153
src/main/java/com/weis/darklaf/ui/button/DarkButtonUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.button;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import com.weis.darklaf.util.GraphicsUtil;
@ -53,6 +52,19 @@ public class DarkButtonUI extends BasicButtonUI {
protected static final Rectangle iconRect = new Rectangle();
protected int borderSize;
protected int shadowHeight;
protected Color inactiveForeground;
protected Color foreground;
protected Color defaultBackground;
protected Color defaultHoverBackground;
protected Color defaultClickBackground;
protected Color background;
protected Color hoverBackground;
protected Color clickBackground;
protected Color inactiveBackground;
protected Color shadowHover;
protected Color shadowClick;
private int arc;
private int squareArc;
protected AbstractButton button;
@NotNull
@ -70,22 +82,21 @@ public class DarkButtonUI extends BasicButtonUI {
@Override
protected void installDefaults(final AbstractButton b) {
super.installDefaults(b);
borderSize = DarkButtonBorder.getBorderSize();
shadowHeight = DarkButtonBorder.getShadowSize();
}
@Override
public void paint(final Graphics g, final JComponent c) {
GraphicsContext config = new GraphicsContext(g);
AbstractButton b = (AbstractButton) c;
paintButton(g, c);
String text = layout(b, c, SwingUtilities2.getFontMetrics(b, g),
b.getWidth(), b.getHeight());
paintIcon(g, b, c);
paintText(g, b, c, text);
config.restore();
borderSize = UIManager.getInt("Button.borderThickness");
shadowHeight = UIManager.getInt("Button.shadowHeight");
inactiveForeground = UIManager.getColor("Button.disabledText");
foreground = UIManager.getColor("Button.selectedButtonForeground");
defaultBackground = UIManager.getColor("Button.defaultFillColor");
defaultHoverBackground = UIManager.getColor("Button.defaultFillColorRollOver");
defaultClickBackground = UIManager.getColor("Button.defaultFillColorClick");
background = UIManager.getColor("Button.activeFillColor");
hoverBackground = UIManager.getColor("Button.activeFillColorRollOver");
clickBackground = UIManager.getColor("Button.activeFillColorClick");
inactiveBackground = UIManager.getColor("Button.inactiveFillColor");
shadowHover = UIManager.getColor("Button.shadow.hover");
shadowClick = UIManager.getColor("Button.shadow.click");
arc = UIManager.getInt("Button.arc");
squareArc = UIManager.getInt("Button.squareArc");
}
@Override
@ -101,17 +112,31 @@ public class DarkButtonUI extends BasicButtonUI {
textRect.x + this.getTextShiftOffset(),
textRect.y + metrics.getAscent() + getTextShiftOffset());
} else {
g.setColor(DarkColors.get().getButtonInactiveForeground());
g.setColor(inactiveForeground);
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, -1,
textRect.x + getTextShiftOffset(),
textRect.y + metrics.getAscent() + getTextShiftOffset());
}
}
@Override
public void paint(final Graphics g, final JComponent c) {
GraphicsContext config = new GraphicsContext(g);
AbstractButton b = (AbstractButton) c;
paintButton(g, c);
String text = layout(b, c, SwingUtilities2.getFontMetrics(b, g),
b.getWidth(), b.getHeight());
paintIcon(g, b, c);
paintText(g, b, c, text);
config.restore();
}
protected Color getForeground(@NotNull final AbstractButton button) {
Color fg = button.getForeground();
if (fg instanceof UIResource && button instanceof JButton && ((JButton) button).isDefaultButton()) {
Color selectedFg = DarkColors.get().getButtonForeground();
Color selectedFg = foreground;
if (selectedFg != null) {
fg = selectedFg;
}
@ -119,6 +144,34 @@ public class DarkButtonUI extends BasicButtonUI {
return fg;
}
protected void paintButton(final Graphics g, @NotNull final JComponent c) {
Graphics2D g2 = (Graphics2D) g;
if (shouldDrawBackground(c)) {
int arc = getArc(c);
if (isShadowVariant(c)) {
var b = (AbstractButton) c;
if (b.isEnabled() && b.getModel().isRollover()) {
GraphicsUtil.setupAAPainting(g2);
g.setColor(getShadowColor(b));
if (isFullShadow(c)) {
g.fillRect(0, 0, c.getWidth(), c.getHeight());
} else {
DarkUIUtil.paintRoundRect((Graphics2D) g, 0, 0, c.getWidth(), c.getHeight(), arc);
}
}
} else {
g2.setColor(getBackgroundColor(c));
if (isSquare(c) && !chooseAlternativeArc(c)) {
g2.fillRect(borderSize, borderSize, c.getWidth() - 2 * borderSize,
c.getHeight() - 2 * borderSize - shadowHeight);
} else {
DarkUIUtil.paintRoundRect((Graphics2D) g, borderSize, borderSize, c.getWidth() - 2 * borderSize,
c.getHeight() - 2 * borderSize - shadowHeight, arc);
}
}
}
}
@Contract("null -> false")
public static boolean isNoArc(final Component c) {
return c instanceof JButton
@ -171,32 +224,11 @@ public class DarkButtonUI extends BasicButtonUI {
return c.isEnabled() && border != null && button.isContentAreaFilled();
}
protected void paintButton(final Graphics g, @NotNull final JComponent c) {
Graphics2D g2 = (Graphics2D) g;
if (shouldDrawBackground(c)) {
int arc = getArcSize(c);
if (isShadowVariant(c)) {
var b = (AbstractButton) c;
if (b.isEnabled() && b.getModel().isRollover()) {
GraphicsUtil.setupAAPainting(g2);
g.setColor(getShadowColor(b));
if (isFullShadow(c)) {
g.fillRect(0, 0, c.getWidth(), c.getHeight());
} else {
DarkUIUtil.paintRoundRect((Graphics2D) g, 0, 0, c.getWidth(), c.getHeight(), arc);
}
}
} else {
g2.setColor(getBackgroundColor(c));
if (isSquare(c) && !chooseAlternativeArc(c)) {
g2.fillRect(borderSize, borderSize, c.getWidth() - 2 * borderSize,
c.getHeight() - 2 * borderSize - shadowHeight);
} else {
DarkUIUtil.paintRoundRect((Graphics2D) g, borderSize, borderSize, c.getWidth() - 2 * borderSize,
c.getHeight() - 2 * borderSize - shadowHeight, arc);
}
}
}
protected int getArc(final Component c) {
if (DarkButtonUI.isNoArc(c)) return 0;
boolean square = DarkButtonUI.isSquare(c);
boolean alt = DarkButtonUI.chooseAlternativeArc(c);
return square ? alt ? arc : squareArc : alt ? squareArc : arc;
}
@Contract("null -> false")
@ -209,10 +241,8 @@ public class DarkButtonUI extends BasicButtonUI {
protected Color getShadowColor(@NotNull final AbstractButton c) {
var colorHover = c.getClientProperty("JButton.shadow.hover");
var colorClick = c.getClientProperty("JButton.shadow.click");
return c.getModel().isArmed() ? colorClick instanceof Color ? (Color) colorClick
: DarkColors.get().getButtonShadowClickColor()
: colorHover instanceof Color ? (Color) colorHover
: DarkColors.get().getButtonShadowHoverColor();
return c.getModel().isArmed() ? colorClick instanceof Color ? (Color) colorClick : shadowClick
: colorHover instanceof Color ? (Color) colorHover : shadowHover;
}
@Contract("null -> false")
@ -221,10 +251,6 @@ public class DarkButtonUI extends BasicButtonUI {
&& "fullShadow".equals(((JButton) c).getClientProperty("JButton.variant"));
}
protected int getArcSize(final JComponent c) {
return DarkButtonBorder.getArc(c);
}
protected Color getBackgroundColor(@NotNull final JComponent c) {
var defaultButton = (c instanceof JButton && (((JButton) c).isDefaultButton()));
var rollOver = (c instanceof JButton && (((JButton) c).isRolloverEnabled()
@ -233,23 +259,23 @@ public class DarkButtonUI extends BasicButtonUI {
if (c.isEnabled()) {
if (defaultButton) {
if (clicked) {
return DarkColors.get().getButtonDefaultClickBackground();
return defaultClickBackground;
} else if (rollOver) {
return DarkColors.get().getButtonDefaultHoverBackground();
return defaultHoverBackground;
} else {
return DarkColors.get().getButtonDefaultBackground();
return defaultBackground;
}
} else {
if (clicked) {
return DarkColors.get().getButtonClickBackground();
return clickBackground;
} else if (rollOver) {
return DarkColors.get().getButtonHoverBackground();
return hoverBackground;
} else {
return DarkColors.get().getButtonBackground();
return background;
}
}
} else {
return DarkColors.get().getButtonInactiveBackground();
return inactiveBackground;
}
}
@ -284,8 +310,9 @@ public class DarkButtonUI extends BasicButtonUI {
return super.contains(c, x, y);
}
if (!(x >= 0 && x <= c.getWidth() && y >= 0 && y <= c.getHeight())) return false;
int bs = DarkButtonBorder.getBorderSize();
return new RoundRectangle2D.Float(bs, bs, c.getWidth() - 2 * bs, c.getWidth() - 2 * bs, getArcSize(c),
getArcSize(c)).contains(x, y);
int bs = borderSize;
int arc = getArc(c);
return new RoundRectangle2D.Float(bs, bs, c.getWidth() - 2 * bs, c.getWidth() - 2 * bs,
arc, arc).contains(x, y);
}
}

35
src/main/java/com/weis/darklaf/ui/button/DarkToggleButtonUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.button;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import com.weis.darklaf.util.GraphicsUtil;
@ -59,6 +58,13 @@ public class DarkToggleButtonUI extends DarkButtonUI {
}
};
protected Dimension sliderSize;
protected Color background;
protected Color backgroundInactive;
protected Color focusBorderColor;
protected Color borderColor;
protected Color inactiveBorderColor;
protected Color sliderColor;
protected Color inactiveSliderColor;
@NotNull
@Contract(value = "_ -> new", pure = true)
@ -70,6 +76,13 @@ public class DarkToggleButtonUI extends DarkButtonUI {
protected void installDefaults(final AbstractButton b) {
super.installDefaults(b);
sliderSize = UIManager.getDimension("ToggleButton.sliderSize");
background = UIManager.getColor("ToggleButton.activeFillColor");
backgroundInactive = UIManager.getColor("ToggleButton.inactiveFillColor");
focusBorderColor = UIManager.getColor("ToggleButton.focusedSliderBorderColor");
borderColor = UIManager.getColor("ToggleButton.sliderBorderColor");
inactiveBorderColor = UIManager.getColor("ToggleButton.disabledSliderBorderColor");
sliderColor = UIManager.getColor("ToggleButton.sliderColor");
inactiveSliderColor = UIManager.getColor("ToggleButton.disabledSliderColor");
}
@Override
@ -90,7 +103,7 @@ public class DarkToggleButtonUI extends DarkButtonUI {
if (isSlider(c)) {
Insets i = b.getInsets();
var bounds = getSliderBounds(c);
viewRect.x = bounds.x + bounds.width + DarkButtonBorder.getBorderSize();
viewRect.x = bounds.x + bounds.width + borderSize;
viewRect.y = i.top;
viewRect.width = width - (i.right + viewRect.x);
viewRect.height = height - (i.bottom + viewRect.y);
@ -130,9 +143,9 @@ public class DarkToggleButtonUI extends DarkButtonUI {
protected Color getBackgroundColor(@NotNull final JComponent c) {
if (c instanceof JToggleButton && c.isEnabled()) {
if (((JToggleButton) c).isSelected()) {
return DarkColors.get().getToggleButtonBackground();
return background;
} else {
return DarkColors.get().getToggleButtonInactiveBackground();
return backgroundInactive;
}
}
return super.getBackgroundColor(c);
@ -152,7 +165,7 @@ public class DarkToggleButtonUI extends DarkButtonUI {
public Dimension getPreferredSize(final JComponent c) {
Dimension d = super.getPreferredSize(c);
if (isSlider(c)) {
d.width += sliderSize.width + DarkButtonBorder.getBorderSize();
d.width += sliderSize.width + borderSize;
}
return d;
}
@ -198,16 +211,14 @@ public class DarkToggleButtonUI extends DarkButtonUI {
bounds.height, bounds.height).contains(x, y);
}
private static Color getToggleBorderColor(@NotNull final AbstractButton b) {
protected Color getToggleBorderColor(@NotNull final AbstractButton b) {
if (b.hasFocus()) {
return DarkColors.get().getToggleButtonFocusBorderColor();
return focusBorderColor;
}
return b.isEnabled() ? DarkColors.get().getToggleButtonBorderColor()
: DarkColors.get().getToggleButtonInactiveBorderColor();
return b.isEnabled() ? borderColor : inactiveBorderColor;
}
private static Color getSliderColor(@NotNull final AbstractButton b) {
return b.isEnabled() ? DarkColors.get().getToggleButtonSliderColor()
: DarkColors.get().getToggleButtonInactiveSliderColor();
protected Color getSliderColor(@NotNull final AbstractButton b) {
return b.isEnabled() ? sliderColor : inactiveSliderColor;
}
}

5
src/main/java/com/weis/darklaf/ui/cell/DarkCellRendererToggleButton.java

@ -25,7 +25,6 @@ package com.weis.darklaf.ui.cell;
import com.weis.darklaf.components.SelectableTreeNode;
import com.weis.darklaf.decorators.CellRenderer;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.tree.DarkTreeCellRenderer;
import org.jetbrains.annotations.NotNull;
@ -61,8 +60,8 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorTo
toggleButton.setHasFocus(focus);
boolean alternativeRow = UIManager.getBoolean("Table.alternateRowColor");
Color alternativeRowColor = DarkColors.get().getTableAlternativeBackground();
Color normalColor = DarkColors.get().getTableBackground();
Color alternativeRowColor = UIManager.getColor("Table.alternateRowBackground");
Color normalColor = UIManager.getColor("Table.background");
if (alternativeRow) {
if (!isSelected) {
if (row % 2 == 1) {

33
src/main/java/com/weis/darklaf/ui/checkbox/DarkCheckBoxUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.checkbox;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.icons.EmptyIcon;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
@ -63,6 +62,13 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI {
private Icon checkBoxSelectedFocusedIcon;
protected int arcSize;
protected int borderSize;
protected Color background;
protected Color inactiveBackground;
protected Color borderColor;
protected Color focusBorderColor;
protected Color inactiveBorderColor;
protected Color checkColor;
protected Color inactiveCheckColor;
@NotNull
@Contract("_ -> new")
@ -81,6 +87,13 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI {
checkBoxSelectedFocusedIcon = UIManager.getIcon("CheckBox.selectedFocused.icon");
arcSize = UIManager.getInt("CheckBox.arc");
borderSize = UIManager.getInt("CheckBox.borderThickness");
background = UIManager.getColor("CheckBox.activeFillColor");
inactiveBackground = UIManager.getColor("CheckBox.inactiveFillColor");
borderColor = UIManager.getColor("CheckBox.activeBorderColor");
focusBorderColor = UIManager.getColor("CheckBox.focusBorderColor");
inactiveBorderColor = UIManager.getColor("CheckBox.inactiveBorderColor");
checkColor = UIManager.getColor("CheckBox.selectionEnabledColor");
inactiveCheckColor = UIManager.getColor("CheckBox.selectionDisabledColor");
}
@Override
@ -219,14 +232,11 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI {
return new IconUIResource(EmptyIcon.create(20));
}
static void paintCheckBorder(@NotNull final Graphics2D g, final boolean enabled, final boolean focus,
final int arcSize, final int borderSize) {
protected void paintCheckBorder(@NotNull final Graphics2D g, final boolean enabled, final boolean focus,
final int arcSize, final int borderSize) {
var g2 = (Graphics2D) g.create();
Color bgColor = enabled ? DarkColors.get().getCheckBoxBackground()
: DarkColors.get().getCheckBoxInactiveBackground();
Color borderColor = focus ? DarkColors.get().getCheckBoxFocusBorderColor()
: enabled ? DarkColors.get().getCheckBoxBorderColor()
: DarkColors.get().getCheckBoxInactiveBorderColor();
Color bgColor = enabled ? background : inactiveBackground;
Color border = focus ? focusBorderColor : enabled ? borderColor : inactiveBorderColor;
g.setColor(bgColor);
DarkUIUtil.paintRoundRect(g, 0, 0, SIZE, SIZE, arcSize);
@ -237,17 +247,16 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI {
g2.translate(borderSize, borderSize);
}
g.setColor(borderColor);
g.setColor(border);
DarkUIUtil.paintLineBorder(g, 0, 0, SIZE, SIZE, arcSize, true);
g2.dispose();
}
static void paintCheckArrow(@NotNull final Graphics2D g, final boolean enabled) {
protected void paintCheckArrow(@NotNull final Graphics2D g, final boolean enabled) {
var config = GraphicsUtil.setupStrokePainting(g);
g.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
Color color = enabled ? DarkColors.get().getCheckBoxCheckColor()
: DarkColors.get().getCheckBoxCheckInactiveColor();
Color color = enabled ? checkColor : inactiveCheckColor;
g.setPaint(color);
Path2D check = new Path2D.Float(Path2D.WIND_EVEN_ODD);

5
src/main/java/com/weis/darklaf/ui/colorchooser/ColorPreviewComponent.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -12,9 +11,11 @@ import java.awt.*;
*/
final class ColorPreviewComponent extends JComponent {
private Color myColor;
protected Color borderColor;
ColorPreviewComponent() {
setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
borderColor = UIManager.getColor("ColorChooser.previewBorderColor");
}
public void setColor(final Color c) {
@ -36,7 +37,7 @@ final class ColorPreviewComponent extends JComponent {
g.setColor(myColor);
g.fillRect(i.left + 1, i.top + 1, width - 2, height - 2);
g.setColor(DarkColors.get().getColorChooserPreviewBorderColor());
g.setColor(borderColor);
g.fillRect(i.left, i.top, width, 1);
g.fillRect(i.left, i.top, 1, height);
g.fillRect(i.left + width - 1, i.top, 1, height);

22
src/main/java/com/weis/darklaf/ui/colorchooser/ColorWheel.java

@ -24,7 +24,6 @@
package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.ColorUtil;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
@ -51,6 +50,9 @@ public class ColorWheel extends JComponent {
private Color myColor;
private int myOpacity;
private boolean pressedInside;
protected Color dropFill;
protected Color dropBorder;
protected Color background;
public ColorWheel() {
setOpaque(true);
@ -105,6 +107,18 @@ public class ColorWheel extends JComponent {
pressedInside = false;
}
});
background = UIManager.getColor("ColorChooser.colorWheelBackground");
dropFill = UIManager.getColor("ColorChooser.colorWheelDropBackgroundColor");
dropBorder = UIManager.getColor("ColorChooser.colorWheelDropBorderColor");
}
@Override
public void updateUI() {
super.updateUI();
background = UIManager.getColor("ColorChooser.colorWheelBackground");
dropFill = UIManager.getColor("ColorChooser.colorWheelDropBackgroundColor");
dropBorder = UIManager.getColor("ColorChooser.colorWheelDropBorderColor");
}
private void setHSBValue(final float h, final float s, final float b, final int opacity) {
@ -171,7 +185,7 @@ public class ColorWheel extends JComponent {
_size - BORDER_SIZE * 2);
}
g2d.setColor(DarkColors.get().getPanelBackground());
g2d.setColor(background);
g2d.fillRect(0, 0, getWidth(), getHeight());
@ -188,9 +202,9 @@ public class ColorWheel extends JComponent {
final int x = (int) (mx + arcw * Math.cos(th));
final int y = (int) (my - arch * Math.sin(th));
g2d.setColor(DarkColors.get().getColorChooserColorWheelDropBackground());
g2d.setColor(dropFill);
g2d.fillRect(x - 2, y - 2, 4, 4);
g2d.setColor(DarkColors.get().getColorChooserColorWheelDropBorderColor());
g2d.setColor(dropBorder);
DarkUIUtil.drawRect(g, x - 2, y - 2, 4, 4, 1);
}

9
src/main/java/com/weis/darklaf/ui/colorchooser/DarkColorChooserPanel.java

@ -27,7 +27,6 @@ package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.color.DarkColorModel;
import com.weis.darklaf.components.DefaultColorPipette;
import com.weis.darklaf.decorators.AncestorAdapter;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.util.ColorUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -60,6 +59,8 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
private final boolean doneInit;
private Color currentColor;
private boolean isChanging;
private Icon pipetteIcon;
private Icon pipetteHoverIcon;
@Contract("null -> fail")
public DarkColorChooserPanel(final DarkColorModel... colorModels) {
@ -70,6 +71,8 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
previewComponent = new ColorPreviewComponent();
colorWheelPanel = new ColorWheelPanel(this, true, true);
pipette = new DefaultColorPipette(this, colorWheelPanel::setColor);
pipetteIcon = UIManager.getIcon("ColorChooser.pipette.icon");
pipetteHoverIcon = UIManager.getIcon("ColorChooser.pipetteRollover.icon");
formatBox = new JComboBox<>(colorModels);
formatBox.addActionListener(e -> {
@ -273,11 +276,11 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
}
protected Icon getPipetteIcon() {
return DarkIcons.get().getColorChooserPipette();
return pipetteIcon;
}
protected Icon getPipetteRolloverIcon() {
return DarkIcons.get().getColorChooserPipetteHover();
return pipetteHoverIcon;
}
@Override

4
src/main/java/com/weis/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java

@ -23,8 +23,6 @@
*/
package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.defaults.DarkColors;
import javax.accessibility.AccessibleContext;
import javax.swing.*;
import javax.swing.border.Border;
@ -91,7 +89,7 @@ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel {
recentSwatchPanel.addKeyListener(recentSwatchKeyListener);
JPanel mainHolder = new JPanel(new FlowLayout(FlowLayout.CENTER));
Border border = new LineBorder(DarkColors.get().getColorChooserSwatchBorderColor());
Border border = new LineBorder(UIManager.getColor("ColorChooser.swatchBorderColor"));
swatchPanel.setBorder(border);
mainHolder.add(swatchPanel);

3
src/main/java/com/weis/darklaf/ui/colorchooser/RecentSwatchPanel.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -22,7 +21,7 @@ class RecentSwatchPanel extends SwatchPanel {
protected void initColors() {
defaultRecentColor = DarkColors.get().getColorChooserDefaultRecentColor();
defaultRecentColor = UIManager.getColor("ColorChooser.swatchesDefaultRecentColor");
int numColors = numSwatches.width * numSwatches.height;
colors = new Color[numColors];

29
src/main/java/com/weis/darklaf/ui/colorchooser/SlideComponent.java

@ -26,7 +26,6 @@ package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.components.alignment.Alignment;
import com.weis.darklaf.components.tooltip.ToolTipContext;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.ColorUtil;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
@ -58,12 +57,18 @@ class SlideComponent extends JComponent implements ColorListener {
private int value = 0;
private Unit unitType = Unit.LEVEL;
private Color color;
protected Color borderColor;
protected Color shadowColor;
protected Color knobFill;
SlideComponent(final String title, final boolean vertical, final boolean isOpacity) {
this.title = title;
this.vertical = vertical;
this.isOpacity = isOpacity;
this.color = Color.WHITE;
this.borderColor = UIManager.getColor("ColorChooser.sliderBorderColor");
this.shadowColor = UIManager.getColor("ColorChooser.sliderShadow");
this.knobFill = UIManager.getColor("ColorChooser.sliderKnobColor");
toolTipContext.setAlignInside(false)
.setAlignment(vertical ? Alignment.WEST : Alignment.NORTH)
@ -170,6 +175,14 @@ class SlideComponent extends JComponent implements ColorListener {
listeners.add(listener);
}
@Override
public void updateUI() {
super.updateUI();
borderColor = UIManager.getColor("ColorChooser.sliderBorderColor");
shadowColor = UIManager.getColor("ColorChooser.sliderShadow");
knobFill = UIManager.getColor("ColorChooser.sliderKnobColor");
}
@Override
protected void paintComponent(final Graphics g) {
final Graphics2D g2d = (Graphics2D) g;
@ -179,7 +192,7 @@ class SlideComponent extends JComponent implements ColorListener {
g2d.setPaint(new GradientPaint(0f, 0f, beginColor, 0f, getHeight(), endColor));
g.fillRect(7, 10, 12, getHeight() - 20);
g.setColor(DarkColors.get().getColorChooserSliderBorderColor());
g.setColor(borderColor);
g.fillRect(7, 10, 12, 1);
g.fillRect(7, 10, 1, getHeight() - 20);
g.fillRect(7 + 12 - 1, 10, 1, getHeight() - 20);
@ -188,7 +201,7 @@ class SlideComponent extends JComponent implements ColorListener {
g2d.setPaint(new GradientPaint(0f, 0f, endColor, getWidth(), 0f, beginColor));
g.fillRect(10, 7, getWidth() - 20, 12);
g.setColor(DarkColors.get().getColorChooserSliderBorderColor());
g.setColor(borderColor);
g.fillRect(10, 7, 1, 12);
g.fillRect(10, 7, getWidth() - 20, 1);
g.fillRect(10, 7 + 12 - 1, getWidth() - 20, 1);
@ -208,7 +221,7 @@ class SlideComponent extends JComponent implements ColorListener {
}
}
private static void drawKnob(@NotNull final Graphics2D g2d, int x, int y, final boolean vertical) {
protected void drawKnob(@NotNull final Graphics2D g2d, int x, int y, final boolean vertical) {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (vertical) {
y -= 6;
@ -217,7 +230,7 @@ class SlideComponent extends JComponent implements ColorListener {
arrowShadow.addPoint(x + 7, y + 7);
arrowShadow.addPoint(x - 5, y + 13);
g2d.setColor(ColorUtil.toAlpha(DarkColors.get().getColorChooserSliderShadowColor(), 0.5));
g2d.setColor(ColorUtil.toAlpha(shadowColor, 0.5));
g2d.fill(arrowShadow);
Polygon arrowHead = new Polygon();
@ -225,7 +238,7 @@ class SlideComponent extends JComponent implements ColorListener {
arrowHead.addPoint(x + 6, y + 6);
arrowHead.addPoint(x - 6, y + 12);
g2d.setColor(DarkColors.get().getColorChooserSliderKnobColor());
g2d.setColor(knobFill);
g2d.fill(arrowHead);
} else {
x -= 6;
@ -235,7 +248,7 @@ class SlideComponent extends JComponent implements ColorListener {
arrowShadow.addPoint(x + 13, y - 5);
arrowShadow.addPoint(x + 7, y + 7);
g2d.setColor(ColorUtil.toAlpha(DarkColors.get().getColorChooserSliderShadowColor(), 0.5));
g2d.setColor(ColorUtil.toAlpha(shadowColor, 0.5));
g2d.fill(arrowShadow);
Polygon arrowHead = new Polygon();
@ -243,7 +256,7 @@ class SlideComponent extends JComponent implements ColorListener {
arrowHead.addPoint(x + 12, y - 6);
arrowHead.addPoint(x + 6, y + 6);
g2d.setColor(DarkColors.get().getColorChooserSliderKnobColor());
g2d.setColor(knobFill);
g2d.fill(arrowHead);
}
}

3
src/main/java/com/weis/darklaf/ui/colorchooser/SwatchPanel.java

@ -2,7 +2,6 @@ package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.components.alignment.Alignment;
import com.weis.darklaf.components.tooltip.ToolTipContext;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
@ -40,7 +39,7 @@ abstract class SwatchPanel extends JPanel {
initColors();
setToolTipText(""); // register for events
setOpaque(true);
setBackground(DarkColors.get().getColorChooserSwatchGridColor());
setBackground(UIManager.getColor("ColorChooser.swatchGridColor"));
setFocusable(true);
setInheritsPopupMenu(true);
addFocusListener(new FocusAdapter() {

30
src/main/java/com/weis/darklaf/ui/combobox/DarkComboBoxUI.java

@ -24,7 +24,6 @@
package com.weis.darklaf.ui.combobox;
import com.weis.darklaf.components.ArrowButton;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
@ -65,6 +64,12 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border {
private Insets boxPadding;
protected int arcSize;
protected int borderSize;
protected Color background;
protected Color inactiveBackground;
protected Color inactiveForeground;
protected Color focusBorderColor;
protected Color borderColor;
protected Color inactiveBorderColor;
@NotNull
@Contract("_ -> new")
@ -78,6 +83,12 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border {
comboBox.setBorder(this);
boxPadding = UIManager.getInsets("ComboBox.padding");
borderSize = UIManager.getInt("ComboBox.borderThickness");
background = UIManager.getColor("ComboBox.activeBackground");
inactiveBackground = UIManager.getColor("ComboBox.inactiveBackground");
inactiveForeground = UIManager.getColor("ComboBox.disabledForeground");
focusBorderColor = UIManager.getColor("ComboBox.focusBorderColor");
borderColor = UIManager.getColor("ComboBox.activeBorderColor");
inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor");
}
@Override
@ -256,14 +267,8 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border {
return getMinimumSize(c);
}
private Color getBackground() {
return comboBox.isEnabled() ? DarkColors.get().getComboBoxBackground()
: DarkColors.get().getComboBoxInactiveBackground();
}
private Color getForeground() {
return comboBox.isEnabled() ? comboBox.getForeground()
: DarkColors.get().getComboBoxInactiveForeground();
return comboBox.isEnabled() ? comboBox.getForeground() : inactiveForeground;
}
@Override
@ -310,7 +315,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border {
if (!isTableCellEditor && !isTreeCellEditor) {
if (hasFocus) {
DarkUIUtil.paintFocusBorder(g, width, height, arcSize, borderSize);
g.setColor(DarkColors.get().getComboBoxFocusBorderColor());
g.setColor(focusBorderColor);
} else {
g.setColor(getBorderColor());
}
@ -338,6 +343,10 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border {
config.restore();
}
private Color getBackground() {
return comboBox.isEnabled() ? background : inactiveBackground;
}
public void paintCurrentValue(final Graphics g, final Rectangle bounds, final boolean hasFocus) {
ListCellRenderer<Object> renderer = comboBox.getRenderer();
Component c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(),
@ -379,8 +388,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border {
}
private Color getBorderColor() {
return comboBox.isEnabled() ? DarkColors.get().getComboBoxBorderColor()
: DarkColors.get().getComboBoxInactiveBorderColor();
return comboBox.isEnabled() ? borderColor : inactiveBorderColor;
}
@Override

12
src/main/java/com/weis/darklaf/ui/filechooser/DarkFileChooserListViewBorder.java

@ -24,18 +24,12 @@
package com.weis.darklaf.ui.filechooser;
import com.weis.darklaf.components.border.MutableLineBorder;
import com.weis.darklaf.defaults.DarkColors;
import java.awt.*;
import javax.swing.*;
public class DarkFileChooserListViewBorder extends MutableLineBorder.UIResource {
public DarkFileChooserListViewBorder() {
super(1, 1, 1, 1, Color.BLACK);
}
@Override
protected Color getColor() {
return DarkColors.get().getFileChooserListViewBorderColor();
super(1, 1, 1, 1, null);
setColor(UIManager.getColor("FileChooser.borderColor"));
}
}

3
src/main/java/com/weis/darklaf/ui/filechooser/DarkFilePaneUIBridge.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.filechooser;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.list.DarkListCellRenderer;
import com.weis.darklaf.ui.table.DarkTableCellEditor;
import com.weis.darklaf.ui.table.DarkTableCellRenderer;
@ -483,7 +482,7 @@ public class DarkFilePaneUIBridge extends JPanel implements PropertyChangeListen
Locale l = getFileChooser().getLocale();
listViewBorder = UIManager.getBorder("FileChooser.listViewBorder");
listViewBackground = DarkColors.get().getFilePaneListViewBackground();
listViewBackground = UIManager.getColor("FileChooser.listViewBackground");
listViewWindowsStyle = UIManager.getBoolean("FileChooser.listViewWindowsStyle");
readOnly = UIManager.getBoolean("FileChooser.readOnly");

14
src/main/java/com/weis/darklaf/ui/internalframe/DarkDesktopIconBorder.java

@ -1,11 +1,9 @@
package com.weis.darklaf.ui.internalframe;
import com.weis.darklaf.components.border.MutableLineBorder;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
/**
* @author Jannis Weis
@ -13,13 +11,7 @@ import java.awt.*;
public class DarkDesktopIconBorder extends MutableLineBorder implements UIResource {
public DarkDesktopIconBorder() {
super(1, 1, 1, 1, DarkColors.get().getDesktopIconBorderColor());
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
final int width, final int height) {
setColor(DarkColors.get().getDesktopIconBorderColor());
super.paintBorder(c, g, x, y, width, height);
super(1, 1, 1, 1, null);
setColor(UIManager.getColor("DesktopIcon.borderColor"));
}
}

5
src/main/java/com/weis/darklaf/ui/internalframe/DarkDesktopIconUI.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.internalframe;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -40,8 +39,8 @@ public class DarkDesktopIconUI extends BasicDesktopIconUI {
button = new JButton(title, icon);
button.setOpaque(false);
button.putClientProperty("JButton.variant", "fullShadow");
button.putClientProperty("JButton.shadow.hover", DarkColors.get().getDesktopIconHoverBackground());
button.putClientProperty("JButton.shadow.click", DarkColors.get().getDesktopIconClickBackground());
button.putClientProperty("JButton.shadow.hover", UIManager.getColor("DesktopIcon.hoverColor"));
button.putClientProperty("JButton.shadow.click", UIManager.getColor("DesktopIcon.hoverColor"));
button.setRolloverEnabled(true);
button.addActionListener(e -> deiconize());
button.setFont(desktopIcon.getFont());

5
src/main/java/com/weis/darklaf/ui/internalframe/DarkInternalFrameBorder.java

@ -24,7 +24,6 @@
package com.weis.darklaf.ui.internalframe;
import com.weis.darklaf.components.border.DropShadowBorder;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -38,8 +37,9 @@ import java.awt.*;
public class DarkInternalFrameBorder extends DropShadowBorder implements UIResource {
public DarkInternalFrameBorder() {
super(Color.BLACK, 9, .1f, 9,
super(null, 9, .1f, 9,
true, true, true, true);
setShadowColor(UIManager.getColor("InternalFrame.borderShadowColor"));
}
@Override
@ -49,7 +49,6 @@ public class DarkInternalFrameBorder extends DropShadowBorder implements UIResou
return;
}
updateSize(c);
setShadowColor(DarkColors.get().getInternalFrameBorderShadowColor());
super.paintBorder(c, graphics, x, y, width, height);
}

23
src/main/java/com/weis/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.internalframe;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.icons.EmptyIcon;
import com.weis.darklaf.ui.rootpane.TitlePaneIcon;
import com.weis.darklaf.util.GraphicsUtil;
@ -87,20 +86,20 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane {
maxIcon = maximizeIcon;
iconIcon = iconifyIcon;
selectedTitleColor = DarkColors.get().getInternalFrameTitleSelectedBackground();
selectedTextColor = DarkColors.get().getInternalFrameTitleSelectedForeground();
notSelectedTitleColor = DarkColors.get().getInternalFrameTitleBackground();
notSelectedTextColor = DarkColors.get().getInternalFrameTitleForeground();
selectedTitleColor = UIManager.getColor("InternalFrameTitlePane.selectedBackgroundColor");
selectedTextColor = UIManager.getColor("InternalFrameTitlePane.selectedTextForeground");
notSelectedTitleColor = UIManager.getColor("InternalFrameTitlePane.backgroundColor");
notSelectedTextColor = UIManager.getColor("InternalFrameTitlePane.textForeground");
selectedButtonColor = DarkColors.get().getInternalFrameSelectedButtonBackground();
selectedButtonColorHover = DarkColors.get().getInternalFrameSelectedButtonHoverBackground();
selectedButtonColorClick = DarkColors.get().getInternalFrameSelectedButtonClickBackground();
selectedButtonColor = UIManager.getColor("InternalFrameTitlePane.selectedButtonColor");
selectedButtonColorHover = UIManager.getColor("InternalFrameTitlePane.selectedButtonHoverColor");
selectedButtonColorClick = UIManager.getColor("InternalFrameTitlePane.selectedButtonClickColor");
buttonColor = DarkColors.get().getInternalFrameButtonBackground();
buttonColorHover = DarkColors.get().getInternalFrameButtonHoverBackground();
buttonColorClick = DarkColors.get().getInternalFrameButtonClickBackground();
buttonColor = UIManager.getColor("InternalFrameTitlePane.buttonColor");
buttonColorHover = UIManager.getColor("InternalFrameTitlePane.buttonHoverColor");
buttonColorClick = UIManager.getColor("InternalFrameTitlePane.buttonClickColor");
border = DarkColors.get().getInternalFrameBorderColor();
border = UIManager.getColor("InternalFrameTitlePane.borderColor");
}
@Override

10
src/main/java/com/weis/darklaf/ui/list/DarkListCellFocusBorder.java

@ -23,19 +23,25 @@
*/
package com.weis.darklaf.ui.list;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.cell.DarkCellBorder;
import com.weis.darklaf.util.DarkUIUtil;
import javax.swing.*;
import java.awt.*;
public class DarkListCellFocusBorder extends DarkCellBorder {
protected Color borderColor;
public DarkListCellFocusBorder() {
borderColor = UIManager.getColor("List.focusBorderColor");
}
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y,
final int width, final int height) {
super.paintBorder(c, g, x, y, width, height);
g.setColor(DarkColors.get().getListFocusBorderColor());
g.setColor(borderColor);
DarkUIUtil.drawRect(g, 0, 0, width, height, 1);
}
}

10
src/main/java/com/weis/darklaf/ui/menu/DarkMenuBarBorder.java

@ -23,9 +23,9 @@
*/
package com.weis.darklaf.ui.menu;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource;
@ -36,10 +36,16 @@ import java.awt.*;
*/
public class DarkMenuBarBorder implements Border, UIResource {
protected Color borderColor;
public DarkMenuBarBorder() {
borderColor = UIManager.getColor("MenuBar.borderColor");
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
final int w, final int h) {
g.setColor(DarkColors.get().getMenuBarBorderColor());
g.setColor(borderColor);
g.fillRect(x, y + h - 1, w, 1);
}

11
src/main/java/com/weis/darklaf/ui/menu/DarkMenuBarUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.menu;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -36,9 +35,17 @@ import java.awt.*;
*/
public class DarkMenuBarUI extends MetalMenuBarUI {
protected Color background;
@Override
protected void installDefaults() {
super.installDefaults();
background = UIManager.getColor("MenuBar.background");
}
@Override
public void paint(@NotNull final Graphics g, @NotNull final JComponent c) {
g.setColor(DarkColors.get().getMenuItemBackground());
g.setColor(background);
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
}

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

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.menu;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.LazyActionMap;
import org.jetbrains.annotations.Contract;
@ -58,8 +57,8 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
public void installUI(final JComponent c) {
super.installUI(c);
acceleratorFont = UIManager.getFont("MenuItem.font");
acceleratorForeground = DarkColors.get().getMenuItemAcceleratorForeground();
acceleratorSelectionForeground = DarkColors.get().getMenuItemAcceleratorSelectionForeground();
acceleratorForeground = UIManager.getColor("MenuItem.foreground");
acceleratorSelectionForeground = UIManager.getColor("MenuItem.selectionForeground");
arrowIcon = null;
}

5
src/main/java/com/weis/darklaf/ui/menu/DarkMenuUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.menu;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
import sun.swing.MenuItemLayoutHelper;
@ -46,8 +45,8 @@ public class DarkMenuUI extends BasicMenuUI {
protected void installDefaults() {
super.installDefaults();
acceleratorFont = UIManager.getFont("MenuItem.font");
acceleratorForeground = DarkColors.get().getMenuItemForeground();
acceleratorSelectionForeground = DarkColors.get().getMenuItemSelectionForeground();
acceleratorForeground = UIManager.getColor("MenuItem.foreground");
acceleratorSelectionForeground = UIManager.getColor("MenuItem.selectionForeground");
arrowIconHover = UIManager.getIcon("MenuItem.arrowHover.icon");
}

19
src/main/java/com/weis/darklaf/ui/progressbar/DarkProgressBarUI.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.progressbar;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
@ -49,15 +48,15 @@ public class DarkProgressBarUI extends BasicProgressBarUI {
super.installDefaults();
UIManager.put("ProgressBar.repaintInterval", isSimplified() ? REPAINT_INTERVAL_SIMPLIFIED : REPAINT_INTERVAL_DEFAULT);
UIManager.put("ProgressBar.cycleTime", isSimplified() ? CYCLE_TIME_SIMPLIFIED : CYCLE_TIME_DEFAULT);
trackColor = DarkColors.get().getProgressBarTrackBackground();
progressColor = DarkColors.get().getProgressBarProgressColor();
indeterminateStartColor = DarkColors.get().getProgressBarIndeterminateStartColor();
indeterminateEndColor = DarkColors.get().getProgressBarIndeterminateEndColor();
failedColor = DarkColors.get().getProgressBarFailedColor();
failedEndColor = DarkColors.get().getProgressBarFailedEndColor();
passedColor = DarkColors.get().getProgressBarPassedColor();
passedEndColor = DarkColors.get().getProgressBarPassedEndColor();
trackColor = UIManager.getColor("ProgressBar.trackColor");
progressColor = UIManager.getColor("ProgressBar.progressColor");
indeterminateStartColor = UIManager.getColor("ProgressBar.indeterminateStartColor");
indeterminateEndColor = UIManager.getColor("ProgressBar.indeterminateEndColor");
failedColor = UIManager.getColor("ProgressBar.failedColor");
failedEndColor = UIManager.getColor("ProgressBar.failedEndColor");
passedColor = UIManager.getColor("ProgressBar.passedColor");
passedEndColor = UIManager.getColor("ProgressBar.passedEndColor");
}
@Override

5
src/main/java/com/weis/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java

@ -24,7 +24,6 @@
package com.weis.darklaf.ui.radiobutton;
import com.weis.darklaf.decorators.MouseClickListener;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.menu.DarkMenuItemUIBase;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -59,8 +58,8 @@ public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase {
public void installUI(final JComponent c) {
super.installUI(c);
acceleratorFont = UIManager.getFont("MenuItem.font");
acceleratorForeground = DarkColors.get().getMenuItemAcceleratorForeground();
acceleratorSelectionForeground = DarkColors.get().getMenuItemAcceleratorSelectionForeground();
acceleratorForeground = UIManager.getColor("MenuItem.foreground");
acceleratorSelectionForeground = UIManager.getColor("MenuItem.selectionForeground");
c.putClientProperty("RadioButtonMenuItem.doNotCloseOnMouseClick", Boolean.TRUE);
}

33
src/main/java/com/weis/darklaf/ui/radiobutton/DarkRadioButtonUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.radiobutton;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.icons.EmptyIcon;
import com.weis.darklaf.ui.checkbox.DarkCheckBoxUI;
import com.weis.darklaf.util.DarkUIUtil;
@ -62,6 +61,14 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI {
private Icon radioSelectedDisabledIcon;
private Icon radioSelectedFocusedIcon;
protected Color background;
protected Color inactiveBackground;
protected Color focusBorderColor;
protected Color borderColor;
protected Color inactiveBorderColor;
protected Color checkColor;
protected Color inactiveCheckColor;
@NotNull
@Contract("_ -> new")
@ -78,6 +85,13 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI {
radioSelectedIcon = UIManager.getIcon("RadioButton.selected.icon");
radioSelectedDisabledIcon = UIManager.getIcon("RadioButton.selectedDisabled.icon");
radioSelectedFocusedIcon = UIManager.getIcon("RadioButton.selectedFocused.icon");
background = UIManager.getColor("RadioButton.activeFillColor");
inactiveBackground = UIManager.getColor("RadioButton.inactiveFillColor");
focusBorderColor = UIManager.getColor("RadioButton.focusBorderColor");
borderColor = UIManager.getColor("RadioButton.activeBorderColor");
inactiveBorderColor = UIManager.getColor("RadioButton.inactiveBorderColor");
checkColor = UIManager.getColor("RadioButton.selectionEnabledColor");
inactiveCheckColor = UIManager.getColor("RadioButton.selectionDisabledColor");
}
@Override
@ -169,13 +183,11 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI {
return new IconUIResource(EmptyIcon.create(20));
}
static void paintCheckBorder(@NotNull final Graphics2D g, final boolean enabled, final boolean focus) {
protected void paintCheckBorder(@NotNull final Graphics2D g, final boolean enabled, final boolean focus) {
var g2 = (Graphics2D) g.create();
Color bgColor = enabled ? DarkColors.get().getRadioButtonBackground()
: DarkColors.get().getRadioButtonInactiveBackground();
Color borderColor = focus ? DarkColors.get().getRadioButtonFocusBorderColor()
: enabled ? DarkColors.get().getRadioButtonBorderColor()
: DarkColors.get().getRadioButtonInactiveBorderColor();
Color bgColor = enabled ? background : inactiveBackground;
Color border = focus ? focusBorderColor
: enabled ? borderColor : inactiveBorderColor;
g.setColor(bgColor);
g.fillOval(0, 0, SIZE, SIZE);
@ -184,15 +196,14 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI {
DarkUIUtil.paintFocusOval(g2, 1, 1, SIZE - 1, SIZE - 1);
}
g.setColor(borderColor);
g.setColor(border);
g.drawOval(0, 0, SIZE, SIZE);
g2.dispose();
}
static void paintCheckBullet(@NotNull final Graphics2D g, final boolean enabled) {
Color color = enabled ? DarkColors.get().getRadioButtonCheckColor()
: DarkColors.get().getRadioButtonCheckInactiveColor();
protected void paintCheckBullet(@NotNull final Graphics2D g, final boolean enabled) {
Color color = enabled ? checkColor : inactiveCheckColor;
g.setColor(color);
g.translate(0.2, 0.2);
g.fillOval((SIZE - BULLET_RAD) / 2, (SIZE - BULLET_RAD) / 2, BULLET_RAD, BULLET_RAD);

16
src/main/java/com/weis/darklaf/ui/rootpane/CloseButtonUI.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.rootpane;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.button.DarkButtonUI;
import org.jetbrains.annotations.NotNull;
@ -10,11 +9,20 @@ import java.awt.*;
/**
* @author Jannis Weis
*/
class CloseButtonUI extends DarkButtonUI {
public class CloseButtonUI extends DarkButtonUI {
protected Color closeHover;
protected Color closeClick;
@Override
protected void installDefaults(final AbstractButton b) {
super.installDefaults(b);
closeHover = UIManager.getColor("TitlePane.close.rollOverColor");
closeClick = UIManager.getColor("TitlePane.close.clickColor");
}
@Override
protected Color getShadowColor(@NotNull final AbstractButton c) {
return c.getModel().isArmed() ? DarkColors.get().getTitleCloseClickBackground()
: DarkColors.get().getTitleCloseHoverBackground();
return c.getModel().isArmed() ? closeClick : closeHover;
}
}

23
src/main/java/com/weis/darklaf/ui/rootpane/DarkTitlePane.java

@ -25,7 +25,6 @@
package com.weis.darklaf.ui.rootpane;
import com.weis.darklaf.decorators.AncestorAdapter;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.platform.windows.JNIDecorations;
import com.weis.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
@ -293,27 +292,27 @@ public class DarkTitlePane extends JComponent {
private void determineColors() {
switch (getWindowDecorationStyle()) {
case JRootPane.ERROR_DIALOG:
activeBackground = DarkColors.get().getOptionPaneErrorDialogTitleBackground();
activeForeground = DarkColors.get().getOptionPaneErrorDialogTitleForeground();
activeBackground = UIManager.getColor("OptionPane.errorDialog.titlePane.background");
activeForeground = UIManager.getColor("OptionPane.errorDialog.titlePane.foreground");
break;
case JRootPane.QUESTION_DIALOG:
case JRootPane.COLOR_CHOOSER_DIALOG:
case JRootPane.FILE_CHOOSER_DIALOG:
activeBackground = DarkColors.get().getOptionPaneQuestionDialogTitleBackground();
activeForeground = DarkColors.get().getOptionPaneQuestionDialogTitleForeground();
activeBackground = UIManager.getColor("OptionPane.questionDialog.titlePane.background");
activeForeground = UIManager.getColor("OptionPane.questionDialog.titlePane.foreground");
break;
case JRootPane.WARNING_DIALOG:
activeBackground = DarkColors.get().getOptionPaneWarningDialogTitleBackground();
activeForeground = DarkColors.get().getOptionPaneWarningDialogTitleForeground();
activeBackground = UIManager.getColor("OptionPane.warningDialog.titlePane.background");
activeForeground = UIManager.getColor("OptionPane.warningDialog.titlePane.foreground");
break;
default: //JRootPane.Frame
activeBackground = DarkColors.get().getTitleBackground();
activeForeground = DarkColors.get().getTitleForeground();
activeBackground = UIManager.getColor("TitlePane.background");
activeForeground = UIManager.getColor("TitlePane.foreground");
break;
}
inactiveBackground = DarkColors.get().getTitleInactiveBackground();
inactiveForeground = DarkColors.get().getTitleInactiveForeground();
border = DarkColors.get().getTitleBorderColor();
inactiveBackground = UIManager.getColor("TitlePane.inactiveBackground");
inactiveForeground = UIManager.getColor("TitlePane.inactiveForeground");
border = UIManager.getColor("TitlePane.borderColor");
}
private void installDefaults() {

17
src/main/java/com/weis/darklaf/ui/scrollpane/DarkScrollBarUI.java

@ -24,7 +24,6 @@
package com.weis.darklaf.ui.scrollpane;
import com.weis.darklaf.decorators.MouseMovementListener;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.Animator;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
@ -162,6 +161,11 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
mouseMotionListener.mouseMoved(e);
}
};
protected Color thumbBorderColor;
protected Color thumbFadeStartColor;
protected Color thumbFadeEndColor;
protected Color trackBackground;
@NotNull
@Contract("_ -> new")
@ -358,6 +362,10 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
UIManager.put("ScrollBar.incrementButtonGap", incGap);
UIManager.put("ScrollBar.decrementButtonGap", decGap);
}
thumbBorderColor = UIManager.getColor("ScrollBar.thumbBorderColor");
thumbFadeStartColor = UIManager.getColor("ScrollBar.fadeStartColor");
thumbFadeEndColor = UIManager.getColor("ScrollBar.fadeEndColor");
trackBackground = UIManager.getColor("ScrollBar.trackColor");
}
@Override
@ -471,7 +479,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
protected void paintMaxiThumb(@NotNull final Graphics2D g, @NotNull final Rectangle rect) {
final var c = g.getComposite();
g.setComposite(COMPOSITE.derive(THUMB_ALPHA));
g.setColor(DarkColors.get().getScrollBarThumbBorderColor());
g.setColor(thumbBorderColor);
DarkUIUtil.drawRect(g, rect.x, rect.y, rect.width, rect.height, 1);
g.setColor(getThumbColor());
g.fillRect(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
@ -480,8 +488,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
@NotNull
private Color getThumbColor() {
return DarkUIUtil.blendColors(DarkColors.get().getScrollBarThumbEndColor(),
DarkColors.get().getScrollBarThumbStartColor(), thumbAlpha);
return DarkUIUtil.blendColors(thumbFadeEndColor, thumbFadeStartColor, thumbAlpha);
}
@Override
@ -508,7 +515,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
@NotNull
@Contract(value = " -> new", pure = true)
protected Color getTrackColor() {
return DarkColors.get().getScrollBarTrackBackground();
return trackBackground;
}
@NotNull

87
src/main/java/com/weis/darklaf/ui/slider/DarkSliderUI.java

@ -1,8 +1,6 @@
package com.weis.darklaf.ui.slider;
import com.weis.darklaf.decorators.MouseClickListener;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import com.weis.darklaf.util.GraphicsUtil;
@ -51,6 +49,29 @@ public class DarkSliderUI extends BasicSliderUI {
protected int arcSize;
protected int trackSize;
protected Dimension thumbSize;
protected Color inactiveTickForeground;
protected Color trackBackground;
protected Color selectedTrackBackground;
protected Color selectedTrackInactiveBackground;
protected Color selectedVolumeTrackBackground;
protected Color selectedVolumeTrackInactiveBackground;
protected Color thumbBackground;
protected Color thumbInactiveBackground;
protected Color volumeThumbBackground;
protected Color volumeThumbInactiveBackground;
protected Color thumbBorderColor;
protected Color thumbInactiveBorderColor;
protected Icon volume0;
protected Icon volume1;
protected Icon volume2;
protected Icon volume3;
protected Icon volume4;
protected Icon volume0Inactive;
protected Icon volume1Inactive;
protected Icon volume2Inactive;
protected Icon volume3Inactive;
protected Icon volume4Inactive;
public DarkSliderUI(final JSlider b) {
super(b);
@ -75,6 +96,29 @@ public class DarkSliderUI extends BasicSliderUI {
trackSize = UIManager.getInt("Slider.trackThickness");
plainThumbRadius = UIManager.getInt("Slider.plainThumbRadius");
thumbSize = UIManager.getDimension("Slider.thumbSize");
inactiveTickForeground = UIManager.getColor("Slider.disabledTickColor");
trackBackground = UIManager.getColor("Slider.trackBackground");
selectedTrackBackground = UIManager.getColor("Slider.selectedTrackColor");
selectedTrackInactiveBackground = UIManager.getColor("Slider.disabledTrackColor");
selectedVolumeTrackBackground = UIManager.getColor("Slider.volume.selectedTrackColor");
selectedVolumeTrackInactiveBackground = UIManager.getColor("Slider.volume.disabledTrackColor");
thumbBackground = UIManager.getColor("Slider.activeThumbFill");
thumbInactiveBackground = UIManager.getColor("Slider.inactiveThumbFill");
volumeThumbBackground = UIManager.getColor("Slider.volume.activeThumbFill");
volumeThumbInactiveBackground = UIManager.getColor("Slider.volume.inactiveThumbFill");
thumbBorderColor = UIManager.getColor("Slider.thumbBorderColor");
thumbInactiveBorderColor = UIManager.getColor("Slider.thumbBorderColorDisabled");
volume0 = UIManager.getIcon("Slider.volume.enabled_level_0.icon");
volume1 = UIManager.getIcon("Slider.volume.enabled_level_1.icon");
volume2 = UIManager.getIcon("Slider.volume.enabled_level_2.icon");
volume3 = UIManager.getIcon("Slider.volume.enabled_level_3.icon");
volume4 = UIManager.getIcon("Slider.volume.enabled_level_4.icon");
volume0Inactive = UIManager.getIcon("Slider.volume.disabled_level_0.icon");
volume1Inactive = UIManager.getIcon("Slider.volume.disabled_level_1.icon");
volume2Inactive = UIManager.getIcon("Slider.volume.disabled_level_2.icon");
volume3Inactive = UIManager.getIcon("Slider.volume.disabled_level_3.icon");
volume4Inactive = UIManager.getIcon("Slider.volume.disabled_level_4.icon");
}
@Override
@ -255,7 +299,7 @@ public class DarkSliderUI extends BasicSliderUI {
@NotNull
protected Color getDisabledTickColor() {
return DarkColors.get().getSliderInactiveTickColor();
return inactiveTickForeground;
}
private static boolean showVolumeIcon(final JComponent c) {
@ -269,20 +313,15 @@ public class DarkSliderUI extends BasicSliderUI {
double percentage = value / (double) range;
boolean enabled = slider.isEnabled();
if (Math.abs(percentage) < 1E-6) {
return enabled ? DarkIcons.get().getSliderVolumeLevel0()
: DarkIcons.get().getSliderVolumeLevel0Inactive();
return enabled ? volume0 : volume0Inactive;
} else if (percentage < 0.25) {
return enabled ? DarkIcons.get().getSliderVolumeLevel1()
: DarkIcons.get().getSliderVolumeLevel1Inactive();
return enabled ? volume1 : volume1Inactive;
} else if (percentage < 0.5) {
return enabled ? DarkIcons.get().getSliderVolumeLevel2()
: DarkIcons.get().getSliderVolumeLevel2Inactive();
return enabled ? volume2 : volume2Inactive;
} else if (percentage < 0.75) {
return enabled ? DarkIcons.get().getSliderVolumeLevel3()
: DarkIcons.get().getSliderVolumeLevel3Inactive();
return enabled ? volume3 : volume3Inactive;
} else {
return enabled ? DarkIcons.get().getSliderVolumeLevel4()
: DarkIcons.get().getSliderVolumeLevel4Inactive();
return enabled ? volume4 : volume4Inactive;
}
}
@ -491,38 +530,28 @@ public class DarkSliderUI extends BasicSliderUI {
@NotNull
protected Color getThumbColor() {
if (isVolumeSlider(slider)) {
return slider.isEnabled()
? DarkColors.get().getSliderVolumeThumbBackground()
: DarkColors.get().getSliderVolumeThumbInactiveBackground();
return slider.isEnabled() ? volumeThumbBackground : volumeThumbInactiveBackground;
} else {
return slider.isEnabled()
? DarkColors.get().getSliderThumbBackground()
: DarkColors.get().getSliderThumbInactiveBackground();
return slider.isEnabled() ? thumbBackground : thumbInactiveBackground;
}
}
@NotNull
protected Color getThumbBorderColor() {
return slider.isEnabled()
? DarkColors.get().getSliderThumbBorderColor()
: DarkColors.get().getSliderThumbInactiveBorderColor();
return slider.isEnabled() ? thumbBorderColor : thumbInactiveBorderColor;
}
@NotNull
protected Color getTrackBackground() {
return DarkColors.get().getSliderTrackBackground();
return trackBackground;
}
@NotNull
protected Color getSelectedTrackColor() {
if (isVolumeSlider(slider)) {
return slider.isEnabled()
? DarkColors.get().getSliderVolumeSelectedTrackBackground()
: DarkColors.get().getSliderVolumeSelectedTrackInactiveBackground();
return slider.isEnabled() ? selectedVolumeTrackBackground : selectedVolumeTrackInactiveBackground;
} else {
return slider.isEnabled()
? DarkColors.get().getSliderSelectedTrackBackground()
: DarkColors.get().getSliderSelectedTrackInactiveBackground();
return slider.isEnabled() ? selectedTrackBackground : selectedTrackInactiveBackground;
}
}

33
src/main/java/com/weis/darklaf/ui/spinner/DarkSpinnerBorder.java

@ -1,7 +1,5 @@
package com.weis.darklaf.ui.spinner;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkDefaults;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.NotNull;
@ -18,6 +16,19 @@ import java.awt.*;
*/
public class DarkSpinnerBorder implements Border, UIResource {
protected Color focusBorderColor;
protected Color borderColor;
protected Color inactiveBorderColor;
protected int arc;
protected int borderSize;
public DarkSpinnerBorder() {
focusBorderColor = UIManager.getColor("Spinner.focusBorderColor");
borderColor = UIManager.getColor("Spinner.activeBorderColor");
inactiveBorderColor = UIManager.getColor("Spinner.inactiveBorderColor");
arc = UIManager.getInt("Spinner.arc");
borderSize = UIManager.getInt("Spinner.borderThickness");
}
@Override
public void paintBorder(@NotNull final Component c, final Graphics g2,
@ -29,10 +40,7 @@ public class DarkSpinnerBorder implements Border, UIResource {
GraphicsContext config = new GraphicsContext(g);
g.translate(x, y);
int borderSize = getBorderSize();
int size = tableCellEditor ? 0 : borderSize;
int arc = getArc();
if (c instanceof JSpinner) {
JSpinner spinner = (JSpinner) c;
@ -57,7 +65,7 @@ public class DarkSpinnerBorder implements Border, UIResource {
g.setColor(getBorderColor(c));
if (!tableCellEditor && !treeCellEditor) {
if (DarkUIUtil.hasFocus(c)) {
g.setColor(DarkColors.get().getSpinnerFocusBorderColor());
g.setColor(focusBorderColor);
}
DarkUIUtil.paintLineBorder(g, size, size, width - 2 * size, height - 2 * size, arc, true);
} else if (tableCellEditor && (c.getParent() instanceof JTable)) {
@ -78,17 +86,8 @@ public class DarkSpinnerBorder implements Border, UIResource {
config.restore();
}
public static int getBorderSize() {
return DarkDefaults.get().getSpinnerBorderSize();
}
public static int getArc() {
return DarkDefaults.get().getSpinnerArc();
}
private static Color getBorderColor(@NotNull final Component c) {
return c.isEnabled() ? DarkColors.get().getSpinnerBorderColor()
: DarkColors.get().getSpinnerInactiveBorderColor();
protected Color getBorderColor(@NotNull final Component c) {
return c.isEnabled() ? borderColor : inactiveBorderColor;
}
@Override

45
src/main/java/com/weis/darklaf/ui/spinner/DarkSpinnerUI.java

@ -25,8 +25,6 @@ package com.weis.darklaf.ui.spinner;
import com.weis.darklaf.components.ArrowButton;
import com.weis.darklaf.decorators.LayoutManagerDelegate;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.icons.UIAwareIcon;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
@ -80,6 +78,14 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
private JComponent editor;
private Color compColor;
private JButton prevButton;
protected Color background;
protected Color inactiveBackground;
protected int arc;
protected int borderSize;
protected UIAwareIcon arrowDownIcon;
protected UIAwareIcon arrowUpIcon;
protected UIAwareIcon plusIcon;
protected UIAwareIcon minusIcon;
@NotNull
@Contract("_ -> new")
@ -87,6 +93,20 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
return new DarkSpinnerUI();
}
@Override
protected void installDefaults() {
super.installDefaults();
arc = UIManager.getInt("Spinner.arc");
borderSize = UIManager.getInt("Spinner.borderThickness");
background = UIManager.getColor("Spinner.activeBackground");
inactiveBackground = UIManager.getColor("Spinner.inactiveBackground");
arrowDownIcon = (UIAwareIcon) UIManager.getIcon("ArrowButton.down.icon");
arrowUpIcon = (UIAwareIcon) UIManager.getIcon("ArrowButton.up.icon");
minusIcon = (UIAwareIcon) UIManager.getIcon("Spinner.minus.icon");
plusIcon = (UIAwareIcon) UIManager.getIcon("Spinner.plus.icon");
}
@Override
protected void installListeners() {
super.installListeners();
@ -118,7 +138,6 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
super.layoutContainer(parent);
if (editor != null && !spinner.getComponentOrientation().isLeftToRight()) {
var bounds = editor.getBounds();
int borderSize = DarkSpinnerBorder.getBorderSize();
bounds.x += borderSize;
bounds.width -= borderSize;
editor.setBounds(bounds);
@ -188,18 +207,15 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
protected SpinnerIcon getArrowIcon(final int direction) {
if (direction == SwingConstants.SOUTH) {
return new SpinnerIcon(spinner, DarkIcons.get().getSpinnerArrowDown(),
DarkIcons.get().getSpinnerMathDown());
return new SpinnerIcon(spinner, arrowDownIcon, minusIcon);
} else {
return new SpinnerIcon(spinner, DarkIcons.get().getSpinnerArrowUp(),
DarkIcons.get().getSpinnerMathUp());
return new SpinnerIcon(spinner, arrowUpIcon, plusIcon);
}
}
@Override
public void paint(final Graphics g, @NotNull final JComponent c) {
int size = DarkSpinnerBorder.getBorderSize();
int arc = DarkSpinnerBorder.getArc();
int size = borderSize;
int width = c.getWidth();
int height = c.getHeight();
JComponent editor = spinner.getEditor();
@ -235,9 +251,8 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
}
}
public static Color getBackground(final JComponent c) {
return c == null || !c.isEnabled() ? DarkColors.get().getSpinnerInactiveBackground()
: DarkColors.get().getSpinnerBackground();
protected Color getBackground(final JComponent c) {
return c == null || !c.isEnabled() ? inactiveBackground : background;
}
protected static boolean isTableCellEditor(@NotNull final Component c) {
@ -263,14 +278,10 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
} else {
rect.subtract(iconRect);
}
g.setColor(getSpinBackground());
g.setColor(getBackground(spinner));
g.fill(rect);
}
public static Color getSpinBackground() {
return getBackground(null);
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
var key = evt.getPropertyName();

26
src/main/java/com/weis/darklaf/ui/splitpane/DarkSplitPaneDivider.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.splitpane;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.icons.EmptyIcon;
import org.jetbrains.annotations.Contract;
@ -38,8 +37,21 @@ import java.awt.*;
*/
public class DarkSplitPaneDivider extends BasicSplitPaneDivider {
protected Icon leftOneTouch;
protected Icon rightOneTouch;
protected Icon topOneTouch;
protected Icon bottomOneTouch;
protected Icon verticalSplit;
protected Icon horizontalSplit;
public DarkSplitPaneDivider(final BasicSplitPaneUI ui) {
super(ui);
leftOneTouch = UIManager.getIcon("SplitPaneDivider.leftOneTouch.icon");
rightOneTouch = UIManager.getIcon("SplitPaneDivider.rightOneTouch.icon");
topOneTouch = UIManager.getIcon("SplitPaneDivider.topOneTouch.icon");
bottomOneTouch = UIManager.getIcon("SplitPaneDivider.bottomOneTouch.icon");
verticalSplit = UIManager.getIcon("SplitPane.verticalGlue.icon");
horizontalSplit = UIManager.getIcon("SplitPane.horizontalGlue.icon");
}
@ -58,11 +70,11 @@ public class DarkSplitPaneDivider extends BasicSplitPaneDivider {
}
protected Icon getVerticalSplitIcon() {
return DarkIcons.get().getSplitPaneDividerVerticalSplit();
return verticalSplit;
}
protected Icon getHorizontalSplitIcon() {
return DarkIcons.get().getSplitPaneDividerHorizontalSplit();
return horizontalSplit;
}
@Override
@ -76,19 +88,19 @@ public class DarkSplitPaneDivider extends BasicSplitPaneDivider {
}
protected Icon getLeftOneTouchIcon() {
return DarkIcons.get().getSplitPaneDividerLeftOneTouch();
return leftOneTouch;
}
protected Icon getRightOneTouchIcon() {
return DarkIcons.get().getSplitPaneDividerRightOneTouch();
return rightOneTouch;
}
protected Icon getTopOneTouchIcon() {
return DarkIcons.get().getSplitPaneDividerTopOneTouch();
return topOneTouch;
}
protected Icon getBottomOneTouchIcon() {
return DarkIcons.get().getSplitPaneDividerBottomOneTouch();
return bottomOneTouch;
}
protected static class OneTouchButton extends JButton implements UIResource {

10
src/main/java/com/weis/darklaf/ui/splitpane/DarkSplitPaneUI.java

@ -24,7 +24,6 @@
package com.weis.darklaf.ui.splitpane;
import com.weis.darklaf.decorators.LayoutManagerDelegate;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -44,6 +43,7 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
private static final int DIVIDER_DRAG_SIZE = 10;
private static final int DIVIDER_DRAG_OFFSET = 5;
private Style style;
private Color dividerLine;
protected DarkSplitPaneUI(final Style style) {
this.style = style;
@ -62,6 +62,12 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
splitPane.setComponentZOrder(getDivider(), 0);
}
@Override
protected void installDefaults() {
super.installDefaults();
dividerLine = UIManager.getColor("SplitPane.dividerLineColor");
}
@Override
protected void installListeners() {
super.installListeners();
@ -136,7 +142,7 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL
}
protected Color getDividerLineColor() {
return DarkColors.get().getSplitPaneDividerLineColor();
return dividerLine;
}
private enum Style {

16
src/main/java/com/weis/darklaf/ui/statusbar/DarkStatusBarUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.statusbar;
import com.weis.darklaf.defaults.DarkColors;
import org.jdesktop.swingx.JXStatusBar;
import org.jdesktop.swingx.plaf.basic.BasicStatusBarUI;
import org.jetbrains.annotations.Contract;
@ -38,19 +37,30 @@ import java.awt.*;
*/
public class DarkStatusBarUI extends BasicStatusBarUI {
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkStatusBarUI();
}
protected Color background;
protected Color borderColor;
@Override
protected void installDefaults(final JXStatusBar sb) {
super.installDefaults(sb);
background = UIManager.getColor("StatusBar.background");
borderColor = UIManager.getColor("StatusBar.topColor");
}
@Override
protected void paintBackground(final Graphics2D g, @NotNull final JXStatusBar bar) {
if (bar.isOpaque()) {
g.setColor(DarkColors.get().getStatusBarBackground());
g.setColor(background);
g.fillRect(0, 0, bar.getWidth(), bar.getHeight());
}
g.setColor(DarkColors.get().getStatusBarBorderColor());
g.setColor(borderColor);
g.fillRect(0, 0, bar.getWidth(), 1);
}
}

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

@ -1,8 +1,6 @@
package com.weis.darklaf.ui.tabbedpane;
import com.weis.darklaf.components.UIResourceWrapper;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
@ -57,6 +55,19 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
protected boolean dragging;
protected Rectangle dragRect = new Rectangle();
protected Color dragBorderColor;
protected Color dropBackground;
protected Color tabBorderColor;
protected Color accent;
protected Color focusAccent;
protected Color selectedHoverBackground;
protected Color selectedBackground;
protected Color hoverBackground;
protected Color tabAreaBackground;
protected Icon moreTabsIcon;
protected Icon newTabIcon;
protected DarkScrollHandler scrollHandler;
protected Component leadingComp;
@ -73,7 +84,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
}
protected Color getDragBorderColor() {
return DarkColors.get().getTabbedPaneDragBorderColor();
return dragBorderColor;
}
protected Action getNewTabAction() {
@ -128,6 +139,19 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
@Override
protected void installDefaults() {
super.installDefaults();
dragBorderColor = UIManager.getColor("TabbedPane.dragBorderColor");
dropBackground = UIManager.getColor("TabbedPane.dropFill");
tabBorderColor = UIManager.getColor("TabbedPane.tabBorderColor");
accent = UIManager.getColor("TabbedPane.accent");
focusAccent = UIManager.getColor("TabbedPane.accentFocus");
selectedHoverBackground = UIManager.getColor("TabbedPane.selectedHoverBackground");
selectedBackground = UIManager.getColor("TabbedPane.selectedBackground");
hoverBackground = UIManager.getColor("TabbedPane.hoverBackground");
tabAreaBackground = UIManager.getColor("TabbedPane.tabAreaBackground");
moreTabsIcon = UIManager.getIcon("TabbedPane.moreTabs.icon");
newTabIcon = UIManager.getIcon("TabbedPane.newTab.icon");
var ins = tabPane.getClientProperty("JTabbedPane.tabAreaInsets");
if (ins instanceof Insets) {
tabAreaInsets = (Insets) ins;
@ -259,11 +283,15 @@ 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.setColor(getTabAreaBackground());
g.fillRect(0, 0, tabPane.getWidth(), maxTabHeight - 1);
super.paintTabArea(g, tabPlacement, selectedIndex);
}
protected Color getTabAreaBackground() {
return tabAreaBackground;
}
protected void paintTabAreaBorder(@NotNull final Graphics g, final int tabPlacement,
final int x, final int y, final int w, final int h) {
g.setColor(getTabBorderColor());
@ -373,7 +401,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
protected Color getDropColor() {
if (scrollableTabLayoutEnabled()) {
return DarkColors.get().getTabbedPaneDropBackground();
return dropBackground;
} else {
return getTabBackgroundColor(0, false, true);
}
@ -457,13 +485,11 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
return insets;
}
protected Color getTabBackgroundColor(final int tabIndex, final boolean isSelected, final boolean hover) {
public Color getTabBackgroundColor(final int tabIndex, final boolean isSelected, final boolean hover) {
if (isSelected) {
return hover ? DarkColors.get().getTabbedPaneTabSelectedHoverBackground()
: DarkColors.get().getTabbedPaneTabSelectedBackground();
return hover ? selectedHoverBackground : selectedBackground;
} else {
return hover ? DarkColors.get().getTabbedPaneTabHoverBackground()
: tabPane.getBackgroundAt(tabIndex);
return hover ? hoverBackground : tabPane.getBackgroundAt(tabIndex);
}
}
@ -477,7 +503,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
}
protected Color getTabBorderColor() {
return DarkColors.get().getTabbedPaneTabBorderColor();
return tabBorderColor;
}
protected DarkScrollHandler getScrollHandler() {
@ -530,12 +556,11 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
}
protected Color getAccentColor(final boolean focus) {
return focus ? DarkColors.get().getTabbedPaneFocusAccentColor()
: DarkColors.get().getTabbedPaneAccentColor();
return focus ? focusAccent : accent;
}
protected Icon getMoreTabsIcon() {
return DarkIcons.get().getTabbedPaneMoreTabs();
return moreTabsIcon;
}
protected void layoutLeadingComponent(final Component comp, final int tabWidth, final int tabHeight,
@ -646,7 +671,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
}
public Icon getNewTabIcon() {
return DarkIcons.get().getTabbedPaneNewTabs();
return newTabIcon;
}
public JComponent createNewTabButton() {

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

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.tabbedpane;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.LazyActionMap;
import org.jetbrains.annotations.NotNull;
@ -220,6 +219,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
protected boolean isRunsDirty;
protected boolean calculatedBaseline;
protected Color selectedForeground;
// UI Installation/De-installation
protected int baseline;
@ -475,6 +476,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");
tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
selectedForeground = UIManager.getColor("TabbedPane.selectedForeground");
Object opaque = UIManager.get("TabbedPane.opaque");
if (opaque == null) {
opaque = Boolean.FALSE;
@ -1174,7 +1176,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
Color fg = tabPane.getForegroundAt(tabIndex);
if (isSelected && (fg instanceof UIResource)) {
Color selectedFG = DarkColors.get().getTabbedPaneSelectedForeground();
Color selectedFG = selectedForeground;
if (selectedFG != null) {
fg = selectedFG;
}

8
src/main/java/com/weis/darklaf/ui/tabbedpane/MoreTabsButton.java

@ -34,7 +34,7 @@ public class MoreTabsButton extends DarkTabAreaButton {
protected final static String INFINITY = "\u221e";
protected final static int PAD = 2;
private DarkTabbedPaneUI ui;
protected DarkTabbedPaneUI ui;
protected final Icon icon;
public MoreTabsButton(final DarkTabbedPaneUI ui) {
@ -47,6 +47,12 @@ public class MoreTabsButton extends DarkTabAreaButton {
setFont(getFont().deriveFont(8f));
}
@Override
public Color getBackground() {
if (ui == null) return super.getBackground();
return ui.getTabAreaBackground();
}
protected void paintButton(@NotNull final Graphics g) {
FontMetrics metrics = g.getFontMetrics();
String label = getLabelString();

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

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.tabbedpane;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -37,7 +36,7 @@ public class ScrollableTabPanel extends JPanel implements UIResource {
super(null);
this.ui = ui;
setOpaque(ui.tabPane.isOpaque());
Color bgColor = DarkColors.get().getTabbedPaneTabAreaBackground();
Color bgColor = UIManager.getColor("TabbedPane.tabAreaBackground");
if (bgColor == null) {
bgColor = ui.tabPane.getBackground();
}

5
src/main/java/com/weis/darklaf/ui/tabbedpane/ScrollableTabViewport.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.tabbedpane;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -33,15 +32,13 @@ import java.awt.*;
@SuppressWarnings("serial")
// Superclass is not serializable across versions
class ScrollableTabViewport extends JViewport implements UIResource {
private DarkTabbedPaneUIBridge ui;
public ScrollableTabViewport(@NotNull final DarkTabbedPaneUIBridge ui) {
super();
this.ui = ui;
setName("TabbedPane.scrollableViewport");
setScrollMode(SIMPLE_SCROLL_MODE);
setOpaque(ui.tabPane.isOpaque());
Color bgColor = DarkColors.get().getTabbedPaneTabAreaBackground();
Color bgColor = UIManager.getColor("TabbedPane.tabAreaBackground");
if (bgColor == null) {
bgColor = ui.tabPane.getBackground();
}

19
src/main/java/com/weis/darklaf/ui/tabframe/DarkPanelPopupUI.java

@ -29,12 +29,12 @@ import com.weis.darklaf.components.border.MutableLineBorder;
import com.weis.darklaf.components.tabframe.PanelPopup;
import com.weis.darklaf.components.tabframe.TabFrame;
import com.weis.darklaf.components.tooltip.ToolTipContext;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.panel.DarkPanelUI;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.FocusManager;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.ComponentUI;
@ -88,12 +88,12 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
}
protected void installDefaults() {
headerBackground = DarkColors.get().getTabFramePopupHeaderBackground();
headerButtonHoverBackground = DarkColors.get().getTabFramePopupButtonHoverBackground();
headerButtonClickBackground = DarkColors.get().getTabFramePopupButtonClickBackground();
headerFocusBackground = DarkColors.get().getTabFramePopupFocusHeaderBackground();
headerButtonFocusHoverBackground = DarkColors.get().getTabFramePopupButtonFocusHoverBackground();
headerButtonFocusClickBackground = DarkColors.get().getTabFramePopupButtonFocusClickBackground();
headerBackground = UIManager.getColor("TabFramePopup.headerBackground");
headerButtonHoverBackground = UIManager.getColor("TabFramePopup.headerButtonHoverBackground");
headerButtonClickBackground = UIManager.getColor("TabFramePopup.headerButtonClickBackground");
headerFocusBackground = UIManager.getColor("TabFramePopup.headerFocusBackground");
headerButtonFocusHoverBackground = UIManager.getColor("TabFramePopup.headerButtonFocusHoverBackground");
headerButtonFocusClickBackground = UIManager.getColor("TabFramePopup.headerButtonFocusClickBackground");
accelerator = UIManager.getString("TabFramePopup.closeAccelerator");
popupComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.put(KeyStroke.getKeyStroke(accelerator), accelerator);
@ -175,7 +175,7 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
}
protected MutableLineBorder createBorder() {
var color = DarkColors.get().getTabFramePopupBorderColor();
var color = UIManager.getColor("TabFramePopup.borderColor");
return new MutableLineBorder.UIResource(0, 0, 0, 0, color);
}
@ -342,6 +342,9 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
@Override
public void eventDispatched(@NotNull final AWTEvent event) {
if (event.getID() == FocusEvent.FOCUS_GAINED) {
var focusOwner = FocusManager.getCurrentManager().getFocusOwner();
if (focusOwner instanceof TabFrame) return;
if (focusOwner instanceof JRootPane) return;
boolean focus = DarkUIUtil.hasFocus(popupComponent);
setHeaderBackground(focus);
}

153
src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java

@ -0,0 +1,153 @@
/*
* 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.
*/
package com.weis.darklaf.ui.tabframe;
import com.weis.darklaf.components.JXPopupMenu;
import com.weis.darklaf.components.alignment.Alignment;
import com.weis.darklaf.components.tabframe.TabFrameTab;
import com.weis.darklaf.icons.EmptyIcon;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
public class DarkTabFrameComponentPopupMenu extends JXPopupMenu implements PropertyChangeListener {
private final TabFrameTab tab;
private JMenuItem[] actions;
private int disabled = -1;
public DarkTabFrameComponentPopupMenu(final TabFrameTab tab) {
this.tab = tab;
JMenu moveToMenu = new JMenu("Move to");
var aligns = Alignment.values();
actions = new JMenuItem[aligns.length];
Alignment a = Alignment.NORTH_WEST;
while (a != Alignment.NORTH) {
createAndAdd(a, moveToMenu);
a = a.anticlockwise();
}
createAndAdd(a, moveToMenu);
add(moveToMenu);
if (tab.getOrientation() != null) {
disabled = tab.getOrientation().ordinal();
actions[tab.getOrientation().ordinal()].setEnabled(false);
}
tab.getComponent().addPropertyChangeListener(this);
}
protected void createAndAdd(final Alignment a, @NotNull final JMenu menu) {
var menuItem = createMenuItem(a);
actions[a.ordinal()] = menuItem;
menu.add(menuItem);
}
protected JMenuItem createMenuItem(final Alignment a) {
var menuItem = new JMenuItem();
menuItem.addActionListener(e -> moveTo(a));
menuItem.setText(getDescription(a));
menuItem.setIcon(createIcon(a, true));
menuItem.setDisabledIcon(createIcon(a, false));
return menuItem;
}
protected void moveTo(@NotNull final Alignment a) {
if (disabled >= 0) {
actions[disabled].setEnabled(true);
}
disabled = a.ordinal();
actions[a.ordinal()].setEnabled(false);
tab.getTabFrame().moveTab(tab, a);
}
protected String getDescription(@NotNull final Alignment a) {
switch (a) {
case NORTH:
return "Top Left";
case SOUTH:
return "Bottom Right";
case EAST:
return "Right Top";
case WEST:
return "Left Bottom";
case NORTH_EAST:
return "Top Right";
case NORTH_WEST:
return "Left Top";
case SOUTH_EAST:
return "Right Bottom";
case SOUTH_WEST:
return "Bottom Left";
case CENTER:
default:
return "";
}
}
protected Icon createIcon(@NotNull final Alignment a, final boolean enabled) {
var suffix = enabled ? "" : "Disabled";
switch (a) {
case NORTH:
return UIManager.getIcon("TabFrame.moveToTopLeft" + suffix + ".icon");
case SOUTH:
return UIManager.getIcon("TabFrame.moveToBottomRight" + suffix + ".icon");
case EAST:
return UIManager.getIcon("TabFrame.moveToRightTop" + suffix + ".icon");
case WEST:
return UIManager.getIcon("TabFrame.moveToLeftBottom" + suffix + ".icon");
case NORTH_EAST:
return UIManager.getIcon("TabFrame.moveToTopRight" + suffix + ".icon");
case NORTH_WEST:
return UIManager.getIcon("TabFrame.moveToLeftTop" + suffix + ".icon");
case SOUTH_EAST:
return UIManager.getIcon("TabFrame.moveToRightBottom" + suffix + ".icon");
case SOUTH_WEST:
return UIManager.getIcon("TabFrame.moveToBottomLeft" + suffix + ".icon");
case CENTER:
default:
return EmptyIcon.create(0);
}
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
if ("orientation".equals(evt.getPropertyName())) {
var a = evt.getNewValue();
if (a instanceof Alignment) {
if (disabled >= 0) {
actions[disabled].setEnabled(true);
}
disabled = ((Alignment) a).ordinal();
actions[disabled].setEnabled(false);
}
} else if ("componentPopupMenu".equals(evt.getPropertyName())) {
if (evt.getNewValue() != this) {
tab.getComponent().removePropertyChangeListener(this);
}
}
}
}

5
src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java

@ -26,7 +26,6 @@ package com.weis.darklaf.ui.tabframe;
import com.weis.darklaf.components.tabframe.TabFrame;
import com.weis.darklaf.components.tabframe.TabFrameTabContainer;
import com.weis.darklaf.decorators.HoverListener;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.panel.DarkPanelUI;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
@ -134,8 +133,8 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
protected void installDefaults(final JPanel p) {
super.installDefaults(p);
tabContainer.setOpaque(true);
selectedColor = DarkColors.get().getTabFrameTabSelectedBackground();
hoverColor = DarkColors.get().getTabFrameTabHoverBackground();
selectedColor = UIManager.getColor("TabFrameTab.selectedBackground");
hoverColor = UIManager.getColor("TabFrameTab.hoverBackground");
}
protected void uninstallAccelerator(final TabFrame tabFrame) {

10
src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java

@ -27,7 +27,6 @@ import com.weis.darklaf.components.alignment.Alignment;
import com.weis.darklaf.components.tabframe.TabFrame;
import com.weis.darklaf.components.tabframe.TabFrameTabLabel;
import com.weis.darklaf.decorators.HoverListener;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.icons.RotatableIcon;
import com.weis.darklaf.ui.label.DarkLabelUI;
import com.weis.darklaf.util.DarkUIUtil;
@ -132,11 +131,12 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
super.installDefaults(c);
tabComponent.setFont(UIManager.getFont("TabFrameTab.font"));
tabComponent.setOpaque(true);
defaultFontColor = DarkColors.get().getTabFrameTabForeground();
selectedColor = DarkColors.get().getTabFrameTabSelectedBackground();
hoverColor = DarkColors.get().getTabFrameTabHoverBackground();
selectedFontColor = DarkColors.get().getTabFrameTabSelectedForeground();
defaultFontColor = UIManager.getColor("TabFrameTab.foreground");
selectedColor = UIManager.getColor("TabFrameTab.selectedBackground");
hoverColor = UIManager.getColor("TabFrameTab.hoverBackground");
selectedFontColor = UIManager.getColor("TabFrameTab.selectedForeground");
LookAndFeel.installBorder(c, "TabFrameTab.border");
tabComponent.setComponentPopupMenu(new DarkTabFrameComponentPopupMenu(tabComponent));
}
@Override

8
src/main/java/com/weis/darklaf/ui/tabframe/DarkTabFrameUI.java

@ -28,8 +28,6 @@ import com.weis.darklaf.components.tabframe.PopupContainer;
import com.weis.darklaf.components.tabframe.TabFrame;
import com.weis.darklaf.components.tabframe.TabFramePopup;
import com.weis.darklaf.components.tabframe.TabFrameUI;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkDefaults;
import com.weis.darklaf.util.DarkUIUtil;
import org.jdesktop.jxlayer.JXLayer;
import org.jetbrains.annotations.Contract;
@ -62,6 +60,7 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener {
private MutableLineBorder leftBorder;
private MutableLineBorder rightBorder;
private Color lineColor;
private int tabHeight;
@NotNull
@Contract("_ -> new")
@ -80,7 +79,8 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener {
protected void installDefaults() {
layout = createLayout();
tabFrame.setLayout(layout);
lineColor = DarkColors.get().getTabFrameBorderColor();
lineColor = UIManager.getColor("TabFrame.line");
tabHeight = UIManager.getInt("TabFrame.tabHeight");
topBorder = new MutableLineBorder.UIResource(0, 0, 1, 0, lineColor);
bottomBorder = new MutableLineBorder.UIResource(1, 0, 0, 0, lineColor);
rightBorder = new MutableLineBorder.UIResource(0, 0, 1, 0, lineColor);
@ -147,7 +147,7 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener {
}
public int getTabSize(final TabFrame tabFrame) {
return DarkDefaults.get().getTabFrameTabHeight();
return tabHeight;
}
public JComponent getLeftContainer() {

81
src/main/java/com/weis/darklaf/ui/tabframe/DarkTabbedPopupUI.java

@ -26,8 +26,8 @@ package com.weis.darklaf.ui.tabframe;
import com.weis.darklaf.components.JPanelUIResource;
import com.weis.darklaf.components.border.MutableLineBorder;
import com.weis.darklaf.components.tabframe.TabbedPopup;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.tabbedpane.DarkTabbedPaneUI;
import com.weis.darklaf.ui.tabbedpane.MoreTabsButton;
import com.weis.darklaf.ui.tabbedpane.NewTabButton;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -46,6 +46,7 @@ public class DarkTabbedPopupUI extends DarkPanelPopupUI {
protected Color headerFocusHoverBackground;
protected Color headerFocusSelectedBackground;
protected Color headerFocusSelectedHoverBackground;
protected Color tabBorderColor;
private TabbedPopup popupComponent;
private JTabbedPane tabbedPane;
private MutableLineBorder border;
@ -66,12 +67,13 @@ public class DarkTabbedPopupUI extends DarkPanelPopupUI {
@Override
protected void installDefaults() {
super.installDefaults();
headerHoverBackground = DarkColors.get().getTabFramePopupHeaderHoverBackground();
headerSelectedBackground = DarkColors.get().getTabFramePopupHeaderSelectedBackground();
headerSelectedHoverBackground = DarkColors.get().getTabFramePopupHeaderSelectedHoverBackground();
headerFocusHoverBackground = DarkColors.get().getTabFramePopupHeaderFocusHoverBackground();
headerFocusSelectedBackground = DarkColors.get().getTabFramePopupHeaderFocusSelectedBackground();
headerFocusSelectedHoverBackground = DarkColors.get().getTabFramePopupHeaderFocusSelectedHoverBackground();
headerHoverBackground = UIManager.getColor("TabFramePopup.headerHoverBackground");
headerSelectedBackground = UIManager.getColor("TabFramePopup.headerSelectedBackground");
headerSelectedHoverBackground = UIManager.getColor("TabFramePopup.headerSelectedHoverBackground");
headerFocusHoverBackground = UIManager.getColor("TabFramePopup.headerFocusHoverBackground");
headerFocusSelectedBackground = UIManager.getColor("TabFramePopup.headerFocusSelectedBackground");
headerFocusSelectedHoverBackground = UIManager.getColor("TabFramePopup.headerFocusSelectedHoverBackground");
tabBorderColor = UIManager.getColor("TabFramePopup.borderColor");
}
@Override
@ -128,31 +130,56 @@ public class DarkTabbedPopupUI extends DarkPanelPopupUI {
}
}
protected static class TabFrameMoreTabsButton extends MoreTabsButton {
public TabFrameMoreTabsButton(final DarkTabbedPaneUI ui) {
super(ui);
}
}
protected class TabFrameNewTabButton extends NewTabButton {
protected TabFrameNewTabButton(@NotNull final DarkTabbedPaneUI ui) {
super(ui);
}
@Override
protected JButton createButton() {
var button = new HeaderButton(ui.getNewTabIcon(), DarkTabbedPopupUI.this);
button.putClientProperty("JButton.variant", "shadow");
button.putClientProperty("JButton.buttonType", "square");
button.putClientProperty("JButton.thin", Boolean.TRUE);
button.setRolloverEnabled(true);
button.setOpaque(false);
return button;
}
}
protected class DarkTabFrameTabbedPaneUI extends DarkTabbedPaneUI {
protected Color getTabBackgroundColor(final int tabIndex, final boolean isSelected, final boolean hover) {
@Override
protected Color getTabAreaBackground() {
return hasFocus() ? headerFocusBackground : headerBackground;
}
public Color getTabBackgroundColor(final int tabIndex, final boolean isSelected, final boolean hover) {
if (hasFocus()) {
if (isSelected) {
return hover ? headerFocusSelectedHoverBackground
: headerFocusSelectedBackground;
return hover ? headerFocusSelectedHoverBackground : headerFocusSelectedBackground;
} else {
return hover ? headerFocusHoverBackground
: headerFocusBackground;
return hover ? headerFocusHoverBackground : headerFocusBackground;
}
} else {
if (isSelected) {
return hover ? headerSelectedHoverBackground
: headerSelectedBackground;
return hover ? headerSelectedHoverBackground : headerSelectedBackground;
} else {
return hover ? headerHoverBackground
: headerBackground;
return hover ? headerHoverBackground : headerBackground;
}
}
}
@Override
protected Color getTabBorderColor() {
return DarkColors.get().getTabFramePopupBorderColor();
return tabBorderColor;
}
@Override
@ -167,25 +194,7 @@ public class DarkTabbedPopupUI extends DarkPanelPopupUI {
@Override
public JButton createMoreTabsButton() {
return super.createMoreTabsButton();
}
}
protected class TabFrameNewTabButton extends NewTabButton {
protected TabFrameNewTabButton(@NotNull final DarkTabbedPaneUI ui) {
super(ui);
}
@Override
protected JButton createButton() {
var button = new HeaderButton(ui.getNewTabIcon(), DarkTabbedPopupUI.this);
button.putClientProperty("JButton.variant", "shadow");
button.putClientProperty("JButton.buttonType", "square");
button.putClientProperty("JButton.thin", Boolean.TRUE);
button.setRolloverEnabled(true);
button.setOpaque(false);
return button;
return new TabFrameMoreTabsButton(this);
}
}
}

20
src/main/java/com/weis/darklaf/ui/table/DarkTableBorder.java

@ -24,9 +24,8 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.components.border.MutableLineBorder;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
@ -37,21 +36,10 @@ public class DarkTableBorder extends MutableLineBorder implements UIResource {
public DarkTableBorder() {
super(1, 1, 1, 1, null);
setColor(UIManager.getColor("TableHeader.borderColor"));
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
final int width, final int height) {
setColor(getBorderColor());
super.paintBorder(c, g, x, y, width, height);
}
protected Color getBorderColor() {
return DarkColors.get().getTableHeaderBorderColor();
}
@Override
public boolean isBorderOpaque() {
return true;
public Color getBorderColor() {
return getColor();
}
}

5
src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.combobox.DarkComboBoxUI;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -225,8 +224,8 @@ public class DarkTableCellEditor extends DefaultCellEditor {
}
boolean alternativeRow = UIManager.getBoolean("Table.alternateRowColor");
Color alternativeRowColor = DarkColors.get().getTableAlternativeBackground();
Color normalColor = DarkColors.get().getTableBackground();
Color alternativeRowColor = UIManager.getColor("Table.alternateRowBackground");
Color normalColor = UIManager.getColor("Table.background");
if (alternativeRow) {
if (!isSelected) {
if (row % 2 == 1) {

5
src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditorToggleButton.java

@ -1,7 +1,6 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.decorators.CellRenderer;
import com.weis.darklaf.defaults.DarkColors;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
@ -32,8 +31,8 @@ public class DarkTableCellEditorToggleButton extends AbstractCellEditor implemen
toggleButton.setHorizontalAlignment(table.getComponentOrientation().isLeftToRight() ? LEFT : RIGHT);
boolean alternativeRow = UIManager.getBoolean("Table.alternateRowColor");
Color alternativeRowColor = DarkColors.get().getTableAlternativeBackground();
Color normalColor = DarkColors.get().getTableBackground();
Color alternativeRowColor = UIManager.getColor("Table.alternateRowBackground");
Color normalColor = UIManager.getColor("Table.background");
if (alternativeRow) {
if (!isSelected) {
if (row % 2 == 1) {

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

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.cell.DarkCellBorder;
import com.weis.darklaf.util.DarkUIUtil;
@ -12,12 +11,20 @@ import java.awt.*;
*/
public class DarkTableCellFocusBorder extends DarkCellBorder {
protected Color rowBorderColor;
protected Color borderColor;
public DarkTableCellFocusBorder() {
rowBorderColor = UIManager.getColor("Table.focusRowBorderColor");
borderColor = UIManager.getColor("Table.focusBorderColor");
}
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y,
final int width, final int height) {
super.paintBorder(c, g, x, y, width, height);
if (isRowFocusBorder(c)) {
g.setColor(DarkColors.get().getTableRowBorderColor());
g.setColor(rowBorderColor);
g.fillRect(0, 0, width, 1);
g.fillRect(0, height - 1, width, 1);
if (forcePaintLeft(c)) {
@ -27,7 +34,7 @@ public class DarkTableCellFocusBorder extends DarkCellBorder {
g.fillRect(width - 1, 0, 1, height);
}
} else {
g.setColor(DarkColors.get().getTableFocusBorderColor());
g.setColor(borderColor);
DarkUIUtil.drawRect(g, 0, 0, width, height, 1);
}
}

5
src/main/java/com/weis/darklaf/ui/table/DarkTableCellRenderer.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.cell.DarkCellRendererToggleButton;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
@ -60,8 +59,8 @@ public class DarkTableCellRenderer extends DefaultTableCellRenderer {
}
boolean alternativeRow = UIManager.getBoolean("Table.alternateRowColor");
Color alternativeRowColor = DarkColors.get().getTableAlternativeBackground();
Color normalColor = DarkColors.get().getTableBackground();
Color alternativeRowColor = UIManager.getColor("Table.alternateRowBackground");
Color normalColor = UIManager.getColor("Table.background");
if (alternativeRow) {
if (!isSelected) {
if (row % 2 == 1) {

21
src/main/java/com/weis/darklaf/ui/table/DarkTableHeaderBorder.java

@ -24,11 +24,9 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.components.border.MutableLineBorder;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
/**
* @author Jannis Weis
@ -37,21 +35,6 @@ public class DarkTableHeaderBorder extends MutableLineBorder implements UIResour
public DarkTableHeaderBorder() {
super(0, 0, 1, 0, null);
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
final int width, final int height) {
setColor(getBorderColor());
super.paintBorder(c, g, x, y, width, height);
}
protected Color getBorderColor() {
return DarkColors.get().getTableHeaderBorderColor();
}
@Override
public boolean isBorderOpaque() {
return true;
setColor(UIManager.getColor("TableHeader.borderColor"));
}
}

14
src/main/java/com/weis/darklaf/ui/table/DarkTableHeaderCorner.java

@ -23,8 +23,6 @@
*/
package com.weis.darklaf.ui.table;
import com.weis.darklaf.defaults.DarkColors;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
@ -34,6 +32,14 @@ import java.awt.*;
*/
public class DarkTableHeaderCorner extends JComponent implements UIResource {
protected Color borderColor;
protected Color background;
public DarkTableHeaderCorner() {
background = UIManager.getColor("TableHeader.background");
borderColor = UIManager.getColor("TableHeader.borderColor");
}
@Override
protected void paintComponent(final Graphics g) {
super.paintComponent(g);
@ -45,10 +51,10 @@ public class DarkTableHeaderCorner extends JComponent implements UIResource {
}
protected Color getHeaderBackground() {
return DarkColors.get().getTableHeaderBackground();
return background;
}
protected Color getBorderColor() {
return DarkColors.get().getTableHeaderBorderColor();
return borderColor;
}
}

15
src/main/java/com/weis/darklaf/ui/table/DarkTableHeaderUI.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.table;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -42,6 +41,8 @@ import java.awt.*;
public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
private static final int HEADER_HEIGHT = 26;
protected Color borderColor;
protected Color background;
@NotNull
@Contract("_ -> new")
@ -53,7 +54,11 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
public void installUI(final JComponent c) {
super.installUI(c);
var dim = header.getPreferredSize();
header.setPreferredSize(new Dimension(dim.width, Math.max(dim.height, HEADER_HEIGHT)));
int headerHeight = UIManager.getInt("TableHeader.height");
if (headerHeight < 0) {
headerHeight = HEADER_HEIGHT;
}
header.setPreferredSize(new Dimension(dim.width, Math.max(dim.height, headerHeight)));
if (header.getDefaultRenderer() instanceof DefaultTableCellRenderer) {
DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) header.getDefaultRenderer();
renderer.setHorizontalAlignment(SwingConstants.LEADING);
@ -63,6 +68,8 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
@Override
protected void installDefaults() {
super.installDefaults();
background = UIManager.getColor("TableHeader.background");
borderColor = UIManager.getColor("TableHeader.borderColor");
LookAndFeel.installBorder(header, "TableHeader.border");
}
@ -233,11 +240,11 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
}
protected Color getHeaderBackground() {
return DarkColors.get().getTableHeaderBackground();
return background;
}
protected Color getBorderColor() {
return DarkColors.get().getTableHeaderBorderColor();
return borderColor;
}
protected boolean isScrollPaneRtl() {

14
src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -26,12 +25,14 @@ import java.util.function.Supplier;
public class DarkTableUI extends DarkTableUIBridge {
private static final int ROW_HEIGHT = 22;
protected Color selectionBackground;
protected Color selectionFocusBackground;
private final FocusListener focusListener = new FocusListener() {
@Override
public void focusGained(final FocusEvent e) {
var bg = table.getSelectionBackground();
if (bg instanceof UIResource) {
table.setSelectionBackground(DarkColors.get().getTableFocusSelectionBackground());
table.setSelectionBackground(selectionFocusBackground);
}
table.repaint();
}
@ -43,7 +44,7 @@ public class DarkTableUI extends DarkTableUIBridge {
if (table.isEditing()) {
table.setSelectionBackground(table.getBackground());
} else {
table.setSelectionBackground(DarkColors.get().getTableSelectionBackground());
table.setSelectionBackground(selectionBackground);
}
}
table.repaint();
@ -75,6 +76,7 @@ public class DarkTableUI extends DarkTableUIBridge {
}
}
};
protected Color borderColor;
@NotNull
@Contract("_ -> new")
@ -82,6 +84,7 @@ public class DarkTableUI extends DarkTableUIBridge {
return new DarkTableUI();
}
@Override
protected void paintGrid(@NotNull final Graphics g,
final int rMin, final int rMax, final int cMin, final int cMax) {
@ -311,7 +314,7 @@ public class DarkTableUI extends DarkTableUIBridge {
}
protected Color getBorderColor() {
return DarkColors.get().getTableHeaderBorderColor();
return borderColor;
}
protected boolean isInScrollPane() {
@ -406,6 +409,9 @@ public class DarkTableUI extends DarkTableUIBridge {
UIManager.getBoolean("Table.renderBooleanAsCheckBox"));
table.putClientProperty("JTable.booleanRenderType", UIManager.getString("Table.booleanRenderType"));
setupRendererComponents(table);
borderColor = UIManager.getColor("TableHeader.borderColor");
selectionFocusBackground = UIManager.getColor("Table.focusSelectionBackground");
selectionBackground = UIManager.getColor("Table.selectionNoFocusBackground");
}
@Override

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

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.table;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
@ -39,6 +38,16 @@ import java.awt.*;
*/
public class DarkTableUIBridge extends TableUIBridge {
protected Color dropLine;
protected Color dropLineShort;
@Override
protected void installDefaults() {
super.installDefaults();
dropLine = UIManager.getColor("Table.dropLineColor");
dropLineShort = UIManager.getColor("Table.dropLineShortColor");
}
/**
* Paint a representation of the <code>table</code> instance
* that was set in installUI().
@ -144,8 +153,8 @@ public class DarkTableUIBridge extends TableUIBridge {
return;
}
Color color = DarkColors.get().getTableDropLineColor();
Color shortColor = DarkColors.get().getTableDropLineShortColor();
Color color = dropLine;
Color shortColor = dropLineShort;
if (color == null && shortColor == null) {
return;
}

9
src/main/java/com/weis/darklaf/ui/table/TextFieldTableCellEditorBorder.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.ui.text.DarkTextFieldUI;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -13,10 +12,16 @@ import java.awt.*;
*/
public class TextFieldTableCellEditorBorder extends DarkTableCellBorder {
protected Color borderColor;
public TextFieldTableCellEditorBorder() {
borderColor = UIManager.getColor("TextField.border.enabled");
}
@Override
public void paintBorder(@NotNull final Component c, @NotNull final Graphics g, final int x, final int y,
final int width, final int height) {
g.setColor(DarkTextFieldUI.getBorderColor(false, false, true, true));
g.setColor(borderColor);
var table = DarkUIUtil.getParentOfType(JTable.class, c);
if (table != null) {
if (!table.getShowHorizontalLines()) {

39
src/main/java/com/weis/darklaf/ui/taskpane/DarkTaskPaneUI.java

@ -23,8 +23,6 @@
*/
package com.weis.darklaf.ui.taskpane;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkDefaults;
import com.weis.darklaf.util.DarkUIUtil;
import org.jdesktop.swingx.JXCollapsiblePane;
import org.jdesktop.swingx.JXHyperlink;
@ -49,6 +47,16 @@ public class DarkTaskPaneUI extends MetalTaskPaneUI {
}
protected boolean isCollapsed;
protected Color borderColor;
protected int arc;
@Override
protected void installDefaults() {
super.installDefaults();
borderColor = UIManager.getColor("TaskPane.borderColor");
arc = UIManager.getInt("TaskPane.arc");
}
@Override
protected void installListeners() {
super.installListeners();
@ -64,8 +72,7 @@ public class DarkTaskPaneUI extends MetalTaskPaneUI {
@Override
protected Border createContentPaneBorder() {
Color borderColor = DarkColors.get().getTaskPaneBorderColor();
return new CompoundBorder(new DarkContentPaneBorder(borderColor),
return new CompoundBorder(new DarkContentPaneBorder(borderColor, arc),
BorderFactory.createEmptyBorder(10, 10, 10, 10));
}
@ -77,38 +84,34 @@ public class DarkTaskPaneUI extends MetalTaskPaneUI {
@Override
protected int getRoundHeight() {
return getArcSize();
}
@Contract(pure = true)
protected static int getArcSize() {
return DarkDefaults.get().getTaskPaneArc();
return arc;
}
protected static class DarkContentPaneBorder implements Border, UIResource {
protected Color color;
protected int arc;
@Contract(pure = true)
public DarkContentPaneBorder(final Color color) {
public DarkContentPaneBorder(final Color color, final int arc) {
this.arc = arc;
this.color = color;
}
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
final int width, final int height) {
var clip = g.getClip().getBounds();
int h = height + getArcSize();
int h = height + arc;
g.setClip(clip.x, clip.y, width, h / 2 + 1);
g.setColor(color);
DarkUIUtil.drawRect(g, x, y - 1, width, h, 1);
if (c.isOpaque()) {
g.setColor(c.getBackground());
g.setClip(clip.x, clip.x + h - getArcSize(), width, getArcSize());
DarkUIUtil.paintRoundRect((Graphics2D) g, x + 0.5f, y + 0.5f,
width - 1, h - 1, getArcSize());
g.setClip(clip.x, clip.x + h - arc, width, arc);
DarkUIUtil.paintRoundRect((Graphics2D) g, x + 0.5f, y + 0.5f, width - 1, h - 1, arc);
}
g.setClip(clip.x, clip.y + h / 2 - 1, width, h / 2 + 2);
g.setColor(color);
DarkUIUtil.paintLineBorder((Graphics2D) g, x, y, width, h, getArcSize(), false);
DarkUIUtil.paintLineBorder((Graphics2D) g, x, y, width, h, arc, false);
g.setClip(clip);
}
@ -128,10 +131,6 @@ public class DarkTaskPaneUI extends MetalTaskPaneUI {
protected class DarkPaneBorder extends PaneBorder {
public DarkPaneBorder() {
borderColor = DarkColors.get().getTaskPaneBorderColor();
}
@Override
protected void paintTitleBackground(@NotNull final JXTaskPane group, final Graphics g2) {
var g = (Graphics2D) g2;

65
src/main/java/com/weis/darklaf/ui/text/DarkPasswordFieldUI.java

@ -24,7 +24,6 @@
package com.weis.darklaf.ui.text;
import com.weis.darklaf.decorators.MouseMovementListener;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
@ -92,6 +91,10 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge {
getComponent().repaint();
}
};
protected static Icon show;
protected static Icon showPressed;
protected int borderSize;
protected int arc;
@NotNull
@Contract("_ -> new")
@ -99,8 +102,17 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge {
return new DarkPasswordFieldUI();
}
@Override
protected void installDefaults() {
super.installDefaults();
borderSize = UIManager.getInt("PasswordField.borderThickness");
arc = UIManager.getInt("PasswordField.arc");
show = UIManager.getIcon("PasswordField.show.icon");
showPressed = UIManager.getIcon("PasswordField.showPressed.icon");
}
protected void updateCursor(final Point p) {
boolean insideTextArea = DarkTextFieldUI.getDrawingRect(getComponent()).contains(p)
boolean insideTextArea = getDrawingRect(getComponent()).contains(p)
&& p.x >= DarkTextFieldUI.getTextRect(getComponent()).x
&& p.x < getShowIconCoord().x;
if (insideTextArea) {
@ -114,7 +126,7 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge {
@NotNull
private Point getShowIconCoord() {
Rectangle r = DarkTextFieldUI.getDrawingRect(getComponent());
Rectangle r = getDrawingRect(getComponent());
int w = getShowIcon().getIconWidth();
return new Point(r.x + r.width - w - DarkTextBorder.PADDING, r.y + (r.height - w) / 2);
}
@ -123,9 +135,8 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge {
return showShowIcon() && DarkTextFieldUI.isOver(getShowIconCoord(), getShowIcon(), p);
}
@Contract(pure = true)
public static Icon getShowIcon() {
return DarkIcons.get().getPasswordFiledShow();
protected static Icon getShowIcon() {
return show;
}
private boolean showShowIcon() {
@ -162,26 +173,6 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge {
c.removeKeyListener(keyListener);
}
@Contract(pure = true)
public static Icon getShowTriggeredIcon() {
return DarkIcons.get().getPasswordFiledShowPressed();
}
@Contract("null -> false")
public static boolean hasShowIcon(final Component c) {
return c instanceof JPasswordField
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("PasswordField.view"));
}
private void paintShowIcon(final Graphics2D g) {
var p = getShowIconCoord();
if (showTriggered) {
getShowTriggeredIcon().paintIcon(getComponent(), g, p.x, p.y);
} else {
getShowIcon().paintIcon(getComponent(), g, p.x, p.y);
}
}
protected void paintBackground(final Graphics graphics) {
Graphics2D g = (Graphics2D) graphics;
JTextComponent c = getComponent();
@ -200,8 +191,7 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge {
}
int width = c.getWidth();
int height = c.getHeight();
int w = DarkTextBorder.getBorderSize();
int arc = DarkTextBorder.getArcSize(c);
int w = borderSize;
DarkUIUtil.paintRoundRect(g, w, w, width - 2 * w, height - 2 * w, arc);
if (hasShowIcon(c) && showShowIcon()) {
paintShowIcon(g);
@ -211,4 +201,23 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge {
}
config.restore();
}
@Contract("null -> false")
public static boolean hasShowIcon(final Component c) {
return c instanceof JPasswordField
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("PasswordField.view"));
}
private void paintShowIcon(final Graphics2D g) {
var p = getShowIconCoord();
if (showTriggered) {
getShowTriggeredIcon().paintIcon(getComponent(), g, p.x, p.y);
} else {
getShowIcon().paintIcon(getComponent(), g, p.x, p.y);
}
}
protected Icon getShowTriggeredIcon() {
return showPressed;
}
}

84
src/main/java/com/weis/darklaf/ui/text/DarkTextBorder.java

@ -23,15 +23,17 @@
*/
package com.weis.darklaf.ui.text;
import com.weis.darklaf.defaults.DarkDefaults;
import com.weis.darklaf.ui.table.TextFieldTableCellEditorBorder;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import com.weis.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.UIResource;
import javax.swing.text.JTextComponent;
import java.awt.*;
/**
@ -44,27 +46,48 @@ public class DarkTextBorder implements Border, UIResource {
public final static int PADDING = 4;
protected Color errorBorderColor;
protected Color focusErrorBorderColor;
protected Color focusBorderColor;
protected Color borderColor;
protected Color inactiveBorderColor;
protected int borderSize;
protected int arc;
protected int minimumArc;
protected int searchArc;
public DarkTextBorder() {
focusErrorBorderColor = UIManager.getColor("TextField.border.focusError");
focusBorderColor = UIManager.getColor("TextField.border.focus");
errorBorderColor = UIManager.getColor("TextField.border.error");
borderColor = UIManager.getColor("TextField.border.enabled");
inactiveBorderColor = UIManager.getColor("TextField.border.disabled");
borderSize = UIManager.getInt("TextField.borderThickness");
arc = UIManager.getInt("TextField.arc");
searchArc = UIManager.getInt("TextField.searchArc");
minimumArc = UIManager.getInt("TextField.minimumArc");
}
public void paintBorder(final Component c, final Graphics g2, final int x, final int y,
final int width, final int height) {
if (isCellEditor(c)) {
editorBorder.paintBorder(c, g2, x, y, width, height);
return;
}
int borderSize = getBorderSize();
Graphics2D g = (Graphics2D) g2;
g.translate(x, y);
GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
int arcSize = getArcSize(c);
int focusArcSize = getFocusArcSize(c);
if (!DarkTextFieldUI.isSearchField(c)) {
if (DarkTextFieldUI.hasError(c)) {
if (hasError(c)) {
DarkUIUtil.paintOutlineBorder(g, width, height, focusArcSize, borderSize,
c.hasFocus(), DarkUIUtil.Outline.error);
} else if (c.hasFocus()) {
DarkUIUtil.paintFocusBorder(g, width, height, focusArcSize, borderSize);
}
g.setColor(DarkTextFieldUI.getBorderColor(c));
g.setColor(getBorderColor(c));
if (DarkTextFieldUI.chooseAlternativeArc(c)) {
DarkUIUtil.paintLineBorder(g, borderSize, borderSize, width - 2 * borderSize,
@ -74,12 +97,12 @@ public class DarkTextBorder implements Border, UIResource {
height - 2 * borderSize, 0, true);
}
} else if (DarkTextFieldUI.isSearchField(c)) {
g.setColor(DarkTextFieldUI.getBorderColor(c));
g.setColor(getBorderColor(c));
if (((JComponent) c).getClientProperty("JTextField.Search.noBorderRing") != Boolean.TRUE) {
if (c.hasFocus()) {
DarkUIUtil.paintFocusBorder(g, width, height, arcSize, borderSize);
}
g.setColor(DarkTextFieldUI.getBorderColor(c));
g.setColor(getBorderColor(c));
DarkUIUtil.paintLineBorder(g, borderSize, borderSize, width - 2 * borderSize,
height - 2 * borderSize, arcSize, true);
}
@ -88,32 +111,50 @@ public class DarkTextBorder implements Border, UIResource {
config.restore();
}
public static int getBorderSize() {
return DarkDefaults.get().getTextFieldBorderSize();
@Contract("null -> false")
protected static boolean isCellEditor(final Component c) {
return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("JTextField.cellEditor"));
}
public static int getArcSize(final Component c) {
protected int getArcSize(final Component c) {
boolean alt = DarkTextFieldUI.chooseAlternativeArc(c);
if (!alt && !DarkTextFieldUI.isSearchField(c)) {
return 0;
}
int arcSize = UIManager.getInt("TextField.arc");
int searchArcSize = UIManager.getInt("TextField.searchArc");
return DarkTextFieldUI.isSearchField(c) ? (alt ? arcSize : searchArcSize)
: (alt ? searchArcSize : arcSize);
return DarkTextFieldUI.isSearchField(c) ? (alt ? arc : searchArc) : (alt ? searchArc : arc);
}
public static int getFocusArcSize(final Component c) {
int arcSize = UIManager.getInt("TextField.focusArc");
int searchArcSize = UIManager.getInt("TextField.searchFocusArc");
protected int getFocusArcSize(final Component c) {
boolean alt = DarkTextFieldUI.chooseAlternativeArc(c);
return DarkTextFieldUI.isSearchField(c) ? (alt ? arcSize : searchArcSize)
: (alt ? searchArcSize : arcSize);
if (!alt && !DarkTextFieldUI.isSearchField(c)) {
return minimumArc;
}
return DarkTextFieldUI.isSearchField(c) ? (alt ? arc : searchArc) : (alt ? searchArc : arc);
}
protected static boolean isCellEditor(final Component c) {
@Contract("null -> false")
protected static boolean hasError(final Component c) {
return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("JTextField.cellEditor"));
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("JTextField.hasError"));
}
protected Color getBorderColor(@NotNull final Component c) {
boolean editable = !(c instanceof JTextComponent) || ((JTextComponent) c).isEditable();
boolean focus = DarkUIUtil.hasFocus(c);
boolean error = hasError(c);
return getBorderColor(focus, error, editable, c.isEnabled());
}
protected Color getBorderColor(final boolean focus, final boolean error,
final boolean editable, final boolean enabled) {
if (focus) {
return error ? focusErrorBorderColor : focusBorderColor;
} else if (error) {
return errorBorderColor;
} else {
return enabled && editable ? borderColor : inactiveBorderColor;
}
}
@Override
@ -121,7 +162,6 @@ public class DarkTextBorder implements Border, UIResource {
if (isCellEditor(c)) {
return editorBorder.getBorderInsets(c);
}
int borderSize = getBorderSize();
Insets insets = new Insets(borderSize + PADDING, borderSize + PADDING,
borderSize + PADDING, borderSize + PADDING);
if (DarkTextFieldUI.isSearchField(c)) {

83
src/main/java/com/weis/darklaf/ui/text/DarkTextFieldUI.java

@ -3,8 +3,6 @@ package com.weis.darklaf.ui.text;
import com.weis.darklaf.decorators.MouseClickListener;
import com.weis.darklaf.decorators.MouseMovementListener;
import com.weis.darklaf.decorators.PopupMenuAdapter;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
@ -73,6 +71,13 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh
};
protected int arcSize;
protected int searchArcSize;
protected static Icon clear;
protected static Icon clearHover;
protected static Icon search;
protected static Icon searchWithHistory;
protected int borderSize;
protected Color background;
protected Color inactiveBackground;
@NotNull
@Contract("_ -> new")
@ -81,9 +86,8 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh
}
@Contract(pure = true)
public static Icon getClearIcon(final boolean clearHovered) {
return clearHovered ? DarkIcons.get().getTextFieldClearHover()
: DarkIcons.get().getTextFieldClear();
protected static Icon getClearIcon(final boolean clearHovered) {
return clearHovered ? clearHover : clear;
}
@NotNull
@ -93,46 +97,23 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh
return new Rectangle(i.left, i.top, dim.width - i.left - i.right, dim.height - i.top - i.bottom);
}
public static Color getBorderColor(@NotNull final boolean focus, final boolean error,
final boolean editable, final boolean enabled) {
if (focus) {
if (error) {
return DarkColors.get().getTextFieldFocusErrorBorderColor();
} else {
return DarkColors.get().getTextFieldFocusBorderColor();
}
} else if (error) {
return DarkColors.get().getTextFieldErrorBorderColor();
}
return enabled && editable
? DarkColors.get().getTextFieldBorderColor()
: DarkColors.get().getTextFieldInactiveBorderColor();
}
public static Color getBorderColor(@NotNull final Component c) {
boolean editable = !(c instanceof JTextComponent) || ((JTextComponent) c).isEditable();
boolean focus = DarkUIUtil.hasFocus(c);
boolean error = hasError(c);
return getBorderColor(focus, error, editable, c.isEnabled());
}
@Contract("null -> false")
protected static boolean hasError(final Component c) {
return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("JTextField.hasError"));
}
public static Icon getSearchIcon(final Component c) {
return isSearchFieldWithHistoryPopup(c)
? DarkIcons.get().getTextFieldSearchHistory()
: DarkIcons.get().getTextFieldSearch();
protected static Icon getSearchIcon(final Component c) {
return isSearchFieldWithHistoryPopup(c) ? searchWithHistory : search;
}
@Override
protected void installDefaults() {
super.installDefaults();
arcSize = UIManager.getInt("TextField.arc");
borderSize = UIManager.getInt("TextField.borderThickness");
searchArcSize = UIManager.getInt("TextField.searchArc");
background = UIManager.getColor("TextField.background");
inactiveBackground = UIManager.getColor("TextField.disabledBackground");
clearHover = UIManager.getIcon("TextField.search.clearHover.icon");
clear = UIManager.getIcon("TextField.search.clear.icon");
searchWithHistory = UIManager.getIcon("TextField.search.searchWithHistory.icon");
search = UIManager.getIcon("TextField.search.search.icon");
}
public static boolean chooseAlternativeArc(@NotNull final Component c) {
@ -189,16 +170,15 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh
return new Point(r.x + DarkTextBorder.PADDING, r.y + (r.height - w) / 2);
}
private void paintBorderBackground(@NotNull final Graphics2D g, @NotNull final JTextComponent c) {
protected void paintBorderBackground(@NotNull final Graphics2D g, @NotNull final JTextComponent c) {
g.setColor(getBackgroundColor(c));
Rectangle r = getDrawingRect(getComponent());
int arc = DarkTextBorder.getArcSize(c);
int arc = getArcSize(c);
DarkUIUtil.paintRoundRect(g, r.x, r.y, r.width, r.height, arc);
}
public static Color getBackgroundColor(@NotNull final JTextComponent c) {
return c.isEnabled() && c.isEditable() ? DarkColors.get().getTextFieldBackground()
: DarkColors.get().getTextFieldInactiveBackground();
protected Color getBackgroundColor(@NotNull final JTextComponent c) {
return c.isEnabled() && c.isEditable() ? background : inactiveBackground;
}
public static boolean isSearchFieldWithHistoryPopup(final Component c) {
@ -212,15 +192,24 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh
@NotNull
@Contract("_ -> new")
public static Rectangle getDrawingRect(@NotNull final JTextComponent c) {
int w = DarkTextBorder.getBorderSize();
public Rectangle getDrawingRect(@NotNull final JTextComponent c) {
int w = borderSize;
return new Rectangle(w, w, c.getWidth() - 2 * w, c.getHeight() - 2 * w);
}
private void paintSearchField(@NotNull final Graphics2D g, @NotNull final JTextComponent c) {
protected int getArcSize(final Component c) {
boolean alt = chooseAlternativeArc(c);
if (!alt && !isSearchField(c)) {
return 0;
}
return DarkTextFieldUI.isSearchField(c) ? (alt ? arcSize : searchArcSize)
: (alt ? searchArcSize : arcSize);
}
protected void paintSearchField(@NotNull final Graphics2D g, @NotNull final JTextComponent c) {
g.setColor(getBackgroundColor(c));
Rectangle r = getDrawingRect(getComponent());
int arc = DarkTextBorder.getArcSize(c);
int arc = getArcSize(c);
DarkUIUtil.paintRoundRect(g, r.x, r.y, r.width, r.height, arc);
paintSearchIcon(g);
if (c.getText().length() > 0) {

11
src/main/java/com/weis/darklaf/ui/titledborder/DarkTitledBorder.java

@ -24,19 +24,14 @@
package com.weis.darklaf.ui.titledborder;
import com.weis.darklaf.components.border.MutableLineBorder;
import com.weis.darklaf.defaults.DarkColors;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
public class DarkTitledBorder extends MutableLineBorder implements UIResource {
public DarkTitledBorder() {
super(1, 0, 0, 0, DarkColors.get().getTitledBorderBorderColor());
}
@Override
protected Color getColor() {
return DarkColors.get().getTitledBorderBorderColor();
super(1, 0, 0, 0, null);
setColor(UIManager.getColor("TitledBorder.borderColor"));
}
}

14
src/main/java/com/weis/darklaf/ui/toolbar/DarkToolBarBorder.java

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.toolbar;
import com.weis.darklaf.defaults.DarkIcons;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -15,6 +14,15 @@ import java.awt.*;
*/
public class DarkToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
protected Icon horizontalGrip;
protected Icon verticalGrip;
public DarkToolBarBorder() {
horizontalGrip = UIManager.getIcon("ToolBar.horizontalGrip.icon");
verticalGrip = UIManager.getIcon("ToolBar.verticalGrip.icon");
}
public void paintBorder(final Component c, @NotNull final Graphics g,
final int x, final int y, final int w, final int h) {
g.translate(x, y);
@ -43,11 +51,11 @@ public class DarkToolBarBorder extends AbstractBorder implements UIResource, Swi
}
protected Icon getHorizontalGrip() {
return DarkIcons.get().getToolBarHorizontalGrip();
return horizontalGrip;
}
protected Icon getVerticalGrip() {
return DarkIcons.get().getToolBarVerticalGrip();
return verticalGrip;
}
public Insets getBorderInsets(final Component c, final Insets newInsets) {

10
src/main/java/com/weis/darklaf/ui/toolbar/DarkToolBarUI.java

@ -1,7 +1,6 @@
package com.weis.darklaf.ui.toolbar;
import com.weis.darklaf.decorators.MouseResponder;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -24,6 +23,7 @@ public class DarkToolBarUI extends DarkToolBarUIBridge {
private Dimension verticalDim = new Dimension(0, 0);
private Dimension horizontalDim = new Dimension(0, 0);
private Timer timer = new Timer(5, e -> dragTo());
protected Color background;
@NotNull
@Contract(value = "_ -> new", pure = true)
@ -48,6 +48,12 @@ public class DarkToolBarUI extends DarkToolBarUIBridge {
floatingToolBar = createFloatingWindow(toolBar);
}
@Override
protected void installDefaults() {
super.installDefaults();
background = UIManager.getColor("ToolBar.background");
}
@Override
protected void installListeners() {
super.installListeners();
@ -271,7 +277,7 @@ public class DarkToolBarUI extends DarkToolBarUIBridge {
}
public void paint(@NotNull final Graphics g, @NotNull final JComponent c) {
g.setColor(DarkColors.get().getToolBarBackground());
g.setColor(background);
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}

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

@ -1,6 +1,5 @@
package com.weis.darklaf.ui.toolbar;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.LazyActionMap;
import sun.swing.DefaultLookup;
@ -323,18 +322,18 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons
"ToolBar.font");
// Toolbar specific defaults
if (dockingColor == null || dockingColor instanceof UIResource) {
dockingColor = DarkColors.get().getToolBarDockingBackground();
dockingColor = UIManager.getColor("ToolBar.dockingBackground");
}
if (floatingColor == null || floatingColor instanceof UIResource) {
floatingColor = DarkColors.get().getToolBarFloatingBackground();
floatingColor = UIManager.getColor("ToolBar.floatingBackground");
}
if (dockingBorderColor == null ||
dockingBorderColor instanceof UIResource) {
dockingBorderColor = DarkColors.get().getToolBarDockingBorderColor();
dockingBorderColor = UIManager.getColor("ToolBar.dockingForeground");
}
if (floatingBorderColor == null ||
floatingBorderColor instanceof UIResource) {
floatingBorderColor = DarkColors.get().getToolBarFloatingBorderColor();
floatingBorderColor = UIManager.getColor("ToolBar.floatingForeground");
}
// ToolBar rollover button borders

8
src/main/java/com/weis/darklaf/ui/toolbar/DropPreviewPanel.java

@ -23,7 +23,6 @@
*/
package com.weis.darklaf.ui.toolbar;
import com.weis.darklaf.defaults.DarkColors;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -35,6 +34,11 @@ import java.awt.*;
public class DropPreviewPanel extends JComponent {
private JToolBar toolBar;
private Color dropBackground;
public DropPreviewPanel() {
dropBackground = UIManager.getColor("ToolBar.dropColor");
}
public void setToolBar(final JToolBar toolBar) {
this.toolBar = toolBar;
@ -49,7 +53,7 @@ public class DropPreviewPanel extends JComponent {
protected Color getBackgroundColor() {
var useToolbar = Boolean.TRUE.equals(toolBar.getClientProperty("JToolBar.drag.useToolbarBackground"));
if (!useToolbar) {
var c = DarkColors.get().getToolBarDropBackground();
var c = dropBackground;
if (c == null) {
return toolBar.getBackground();
}

8
src/main/java/com/weis/darklaf/ui/tooltip/DarkTooltipBorder.java

@ -4,7 +4,6 @@ import com.weis.darklaf.components.alignment.Alignment;
import com.weis.darklaf.components.border.BubbleBorder;
import com.weis.darklaf.components.border.DropShadowBorder;
import com.weis.darklaf.components.tooltip.ToolTipStyle;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
@ -27,11 +26,12 @@ public class DarkTooltipBorder implements Border, UIResource {
private final BubbleBorder bubbleBorder;
public DarkTooltipBorder() {
bubbleBorder = new BubbleBorder(DarkColors.get().getToolTipBorderColor());
bubbleBorder = new BubbleBorder(UIManager.getColor("ToolTip.borderColor"));
bubbleBorder.setThickness(1);
bubbleBorder.setPointerSize(8);
bubbleBorder.setPointerWidth(12);
bubbleBorder.setPointerSide(Alignment.CENTER);
shadowBorder.setShadowColor(UIManager.getColor("ToolTip.borderShadowColor"));
}
@ -49,9 +49,6 @@ public class DarkTooltipBorder implements Border, UIResource {
@Override
public void paintBorder(final Component c, final Graphics g,
final int x, final int y, final int width, final int height) {
if (bubbleBorder.getColor() == null) {
bubbleBorder.setColor(DarkColors.get().getToolTipBorderColor());
}
if (isPlain(c)) {
g.setColor(bubbleBorder.getColor());
DarkUIUtil.drawRect(g, x, y, width, height, 1);
@ -68,7 +65,6 @@ public class DarkTooltipBorder implements Border, UIResource {
clip.subtract(bubbleArea);
g.setClip(clip);
shadowBorder.setShadowColor(DarkColors.get().getToolTipShadowColor());
shadowBorder.paintBorder(c, g, x, y, width, height);
g.setClip(oldClip);

10
src/main/java/com/weis/darklaf/ui/tree/DarkTreeCellBorder.java

@ -23,10 +23,10 @@
*/
package com.weis.darklaf.ui.tree;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource;
@ -37,10 +37,16 @@ import java.awt.*;
*/
public class DarkTreeCellBorder implements Border, UIResource {
protected Color borderColor;
public DarkTreeCellBorder() {
borderColor = UIManager.getColor("Tree.editorBorderColor");
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x,
final int y, final int width, final int height) {
g.setColor(DarkColors.get().getTreeEditorBorderColor());
g.setColor(borderColor);
DarkUIUtil.drawRect(g, 0, 0, width, height, 1);
}

65
src/main/java/com/weis/darklaf/ui/tree/DarkTreeUI.java

@ -23,8 +23,6 @@
*/
package com.weis.darklaf.ui.tree;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.defaults.DarkIcons;
import com.weis.darklaf.util.SystemInfo;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -100,6 +98,20 @@ public class DarkTreeUI extends BasicTreeUI {
};
private boolean myOldRepaintAllRowValue;
protected Color alternativeBackground;
protected Color lineColor;
protected Color focusSelectedLineColor;
protected Color selectedLineColor;
protected Color selectionBackground;
protected Color focusSelectionBackground;
protected Icon expandedFocusSelected;
protected Icon expandedSelected;
protected Icon expandedFocus;
protected Icon expanded;
protected Icon collapsedFocusSelected;
protected Icon collapsedSelected;
protected Icon collapsedFocus;
protected Icon collapsed;
@NotNull
@ -137,6 +149,20 @@ public class DarkTreeUI extends BasicTreeUI {
@Override
protected void installDefaults() {
super.installDefaults();
selectionBackground = UIManager.getColor("Tree.unfocusedSelectionBackground");
focusSelectionBackground = UIManager.getColor("Tree.selectionBackground");
focusSelectedLineColor = UIManager.getColor("Tree.lineFocusSelected");
selectedLineColor = UIManager.getColor("Tree.lineSelected");
lineColor = UIManager.getColor("Tree.lineUnselected");
alternativeBackground = UIManager.getColor("Tree.alternateRowBackground");
expandedFocusSelected = UIManager.getIcon("Tree.expanded.selected.focused.icon");
expandedSelected = UIManager.getIcon("Tree.expanded.selected.unfocused.icon");
expandedFocus = UIManager.getIcon("Tree.expanded.unselected.focused.icon");
expanded = UIManager.getIcon("Tree.expanded.unselected.unfocused.icon");
collapsedFocusSelected = UIManager.getIcon("Tree.collapsed.selected.focused.icon");
collapsedSelected = UIManager.getIcon("Tree.collapsed.selected.unfocused.icon");
collapsedFocus = UIManager.getIcon("Tree.collapsed.unselected.focused.icon");
collapsed = UIManager.getIcon("Tree.collapsed.unselected.unfocused.icon");
tree.putClientProperty("JTree.renderBooleanAsCheckBox",
UIManager.getBoolean("Tree.renderBooleanAsCheckBox"));
tree.putClientProperty("JTree.booleanRenderType", UIManager.getString("Tree.booleanRenderType"));
@ -452,7 +478,7 @@ public class DarkTreeUI extends BasicTreeUI {
return getTreeSelectionBackground(tree.hasFocus() || isTableTree || tree.isEditing());
}
if (Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY)) && row % 2 == 1) {
return DarkColors.get().getTreeAlternativeBackground();
return alternativeBackground;
} else {
return tree.getBackground();
}
@ -463,50 +489,33 @@ public class DarkTreeUI extends BasicTreeUI {
}
protected Color getTreeSelectionBackground(final boolean focused) {
return focused ? DarkColors.get().getTreeFocusSelectionBackground()
: DarkColors.get().getTreeSelectionBackground();
return focused ? focusSelectionBackground : selectionBackground;
}
protected Color getLineColor(final TreePath path) {
if (selectedChildOf(path)) {
if (tree.hasFocus() || tree.isEditing()) {
return DarkColors.get().getTreeLineFocusColor();
return focusSelectedLineColor;
} else {
return DarkColors.get().getTreeLineSelectedColor();
return selectedLineColor;
}
}
return DarkColors.get().getTreeLineColor();
return lineColor;
}
protected Icon getExpandedIcon(final boolean selected, final boolean focused) {
if (selected) {
if (focused) {
return DarkIcons.get().getTreeExpandedFocusedSelected();
} else {
return DarkIcons.get().getTreeExpandedSelected();
}
return focused ? expandedFocusSelected : expandedSelected;
} else {
if (focused) {
return DarkIcons.get().getTreeExpandedFocused();
} else {
return DarkIcons.get().getTreeExpanded();
}
return focused ? expandedFocus : expanded;
}
}
protected Icon getCollapsedIcon(final boolean selected, final boolean focused) {
if (selected) {
if (focused) {
return DarkIcons.get().getTreeCollapsedFocusedSelected();
} else {
return DarkIcons.get().getTreeCollapsedSelected();
}
return focused ? collapsedFocusSelected : collapsedSelected;
} else {
if (focused) {
return DarkIcons.get().getTreeCollapsedFocused();
} else {
return DarkIcons.get().getTreeCollapsed();
}
return focused ? collapsedFocus : collapsed;
}
}

17
src/main/java/com/weis/darklaf/util/DarkUIUtil.java

@ -24,14 +24,12 @@
package com.weis.darklaf.util;
import com.weis.darklaf.decorators.CellRenderer;
import com.weis.darklaf.defaults.DarkColors;
import com.weis.darklaf.ui.menu.DarkPopupMenuUI;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import sun.awt.SunToolkit;
import javax.swing.FocusManager;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.table.TableCellRenderer;
@ -57,19 +55,19 @@ public final class DarkUIUtil {
public static final boolean USE_QUARTZ = "true".equals(System.getProperty("apple.awt.graphics.UseQuartz"));
private static Color getErrorGlow() {
return DarkColors.get().getErrorGlow();
return UIManager.getColor("glowError");
}
private static Color getErrorFocusGlow() {
return DarkColors.get().getErrorFocusGlow();
return UIManager.getColor("glowFocusError");
}
private static Color getFocusGlow() {
return DarkColors.get().getFocusGlow();
return UIManager.getColor("glowFocus");
}
private static Color getWarningGlow() {
return DarkColors.get().getWarningGlow();
return UIManager.getColor("glowWarning");
}
public static void paintOutlineBorder(final Graphics2D g, final int width, final int height, final float arc,
@ -78,7 +76,6 @@ public final class DarkUIUtil {
doPaint(g, width, height, arc, bw);
}
@SuppressWarnings("SuspiciousNameCombination")
private static void doPaint(@NotNull final Graphics2D g, final int width, final int height, final float arc,
final float bw) {
var context = GraphicsUtil.setupStrokePainting(g);
@ -148,6 +145,8 @@ public final class DarkUIUtil {
@NotNull
public static Color blendColors(@NotNull final Color color1, @NotNull final Color color2, final double percent) {
if (percent == 1) return color1;
if (percent == 0) return color2;
double inverse_percent = 1.0 - percent;
int redPart = (int) (color1.getRed() * percent + color2.getRed() * inverse_percent);
int greenPart = (int) (color1.getGreen() * percent + color2.getGreen() * inverse_percent);
@ -181,9 +180,7 @@ public final class DarkUIUtil {
return hasFocus(c);
}
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
final Component owner2 = FocusManager.getCurrentManager().getFocusOwner();
return (owner != null && SwingUtilities.isDescendingFrom(owner, c))
|| (owner2 != null && SwingUtilities.isDescendingFrom(owner2, c));
return (owner != null && SwingUtilities.isDescendingFrom(owner, c));
}
public static boolean hasFocus(final Window w) {

120
src/main/java/com/weis/darklaf/util/LafUtil.java → src/main/java/com/weis/darklaf/util/PropertyLoader.java

@ -23,9 +23,9 @@
*/
package com.weis.darklaf.util;
import com.weis.darklaf.icons.DarkUIAwareIcon;
import com.weis.darklaf.icons.EmptyIcon;
import com.weis.darklaf.icons.IconLoader;
import com.weis.darklaf.icons.DarkUIAwareIcon;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -39,6 +39,8 @@ import java.awt.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -49,12 +51,30 @@ import java.util.logging.Logger;
* @author Konstantin Bulenkov
* @author Jannis Weis
*/
public final class LafUtil {
private static final Logger LOGGER = Logger.getLogger(LafUtil.class.getName());
public final class PropertyLoader {
private static final Logger LOGGER = Logger.getLogger(PropertyLoader.class.getName());
private static final IconLoader ICON_LOADER = IconLoader.get();
private static final String DUAL_KEY = "[dual]";
private static final String AWARE_KEY = "[aware]";
private static final String PATCH_KEY = "[patch]";
private static final String REFERENCE_PREFIX = "%";
private static final Collection<ObjectRequest> objectsToLoad = new HashSet<>();
public static void finish() {
for (var request : objectsToLoad) {
try {
request.resolve();
} catch (RuntimeException e) {
LOGGER.log(Level.SEVERE, "Could not load" + request, e.getMessage());
}
}
reset();
}
public static void reset() {
objectsToLoad.clear();
}
@NotNull
public static Properties loadProperties(@NotNull final Class<?> clazz, final String name, final String path) {
@ -67,21 +87,53 @@ public final class LafUtil {
return properties;
}
public static void putProperties(@NotNull final Properties properties, final Properties accumulator,
final UIDefaults currentDefaults) {
for (final String key : properties.stringPropertyNames()) {
final String value = properties.getProperty(key);
var parsed = parseValue(key, value, accumulator);
if (parsed instanceof ObjectRequest) {
objectsToLoad.add((ObjectRequest) parsed);
} else if (parsed != null) {
accumulator.put(parseKey(key), parsed);
} else {
currentDefaults.remove(parseKey(key));
}
}
}
private static Object parseValue(@NotNull final String key, @NotNull final String value,
final Map<Object, Object> defaults) {
return parseValue(key, value, false, defaults);
}
private static String parseKey(@NotNull final String key) {
return key.startsWith(REFERENCE_PREFIX) ? key.substring(REFERENCE_PREFIX.length()) : key;
}
@Nullable
public static Object parseValue(@NotNull final String key, @NotNull final String value,
final Map<Object, Object> defaults) {
private static Object parseValue(@NotNull final String propertyKey, @NotNull final String value,
final boolean ignoreRequest, final Map<Object, Object> defaults) {
if ("null".equals(value)) {
return null;
}
Object returnVal = new LoadError("Could not parse value '" + value + "' for key '" + key + "'");
var key = propertyKey;
boolean skipObjects = ignoreRequest;
if (key.startsWith(REFERENCE_PREFIX)) {
key = parseKey(key);
skipObjects = true;
}
Object returnVal = new LoadError();
if (key.endsWith("Insets")) {
returnVal = parseInsets(value);
} else if (key.endsWith(".border") || key.endsWith("Border")) {
returnVal = parseObject(value);
} else if (key.endsWith(".component") || key.endsWith("Component")) {
returnVal = parseObject(value);
} else if (key.endsWith("Renderer")) {
returnVal = parseObject(value);
} else if (!skipObjects
&& (key.endsWith("Border")
|| key.endsWith(".border")
|| key.endsWith(".component")
|| key.endsWith("Component")
|| key.endsWith("Renderer"))) {
return new ObjectRequest(key, value);
} else if (key.endsWith(".font")) {
returnVal = parseFont(value);
} else if (key.endsWith(".icon") || key.endsWith("Icon")) {
@ -93,8 +145,8 @@ public final class LafUtil {
} else if (value.startsWith("%")) {
var val = value.substring(1);
if (!defaults.containsKey(val)) {
LOGGER.warning("Could not reference value '" + val + "'while loading '" + key + "' " +
". May be a forward reference");
LOGGER.warning("Could not reference value '" + val + "'while loading '" + key + "'. " +
"May be a forward reference");
}
returnVal = defaults.get(val);
}
@ -127,13 +179,12 @@ public final class LafUtil {
Integer.parseInt(numbers.get(3)));
}
@NotNull
@Nullable
private static Object parseObject(final String value) {
try {
return Class.forName(value).getDeclaredConstructor().newInstance();
} catch (@NotNull final Exception e) {
return new LoadError(e.getMessage());
}
} catch (@NotNull final Exception ignored) { }
return null;
}
@NotNull
@ -204,10 +255,41 @@ public final class LafUtil {
}
private static final class LoadError {
}
private static final class ObjectRequest {
final String value;
final String key;
@Contract(pure = true)
private LoadError(final String message) {
private ObjectRequest(final String key, final String value) {
this.key = key;
this.value = value;
}
private void resolve() {
Object obj = parseObject(value);
var defaults = UIManager.getLookAndFeelDefaults();
if (obj == null) {
obj = parseValue(key, value, true, defaults);
if (obj instanceof ObjectRequest) {
LOGGER.severe("Failed to resolve object. " + this);
return;
}
}
if (obj == null) {
defaults.remove(key);
} else {
defaults.put(key, obj);
}
}
@NotNull
@Contract(pure = true)
@Override
public String toString() {
return "[" + key + "," + value + "]";
}
}
}

13
src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java

@ -298,10 +298,9 @@ public class TransformUI extends MouseEventUI<JComponent> {
* @return a {@link AffineTransform} instance or {@code null}
*/
@NotNull
public AffineTransform getPreferredTransform(
final Dimension size, final JXLayer<? extends JComponent> layer) {
return this.transformModel.getPreferredTransform(size, layer);
public AffineTransform getPreferredTransform(final Dimension size, final JXLayer<? extends JComponent> layer) {
return this.transformModel != null ? this.transformModel.getPreferredTransform(size, layer)
: new AffineTransform();
}
/*
@ -533,8 +532,7 @@ public class TransformUI extends MouseEventUI<JComponent> {
* @see #paint(Graphics, JComponent)
*/
@Override
protected final void paintLayer(
@NotNull final Graphics2D g2, @NotNull final JXLayer<? extends JComponent> layer) {
protected final void paintLayer(@NotNull final Graphics2D g2, @NotNull final JXLayer<? extends JComponent> layer) {
JComponent view = layer.getView();
if (view != null) {
if (view.getX() < 0 || view.getY() < 0) {
@ -560,7 +558,8 @@ public class TransformUI extends MouseEventUI<JComponent> {
@NotNull
@Override
protected final AffineTransform getTransform(final JXLayer<? extends JComponent> layer) {
return transformModel.getTransform(layer);
return transformModel != null ? transformModel.getTransform(layer)
: new AffineTransform();
}
/**

4
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToBottomLeft.svg

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M9,10 L9,13 L3,13 L3,10 L9,10 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 246 B

5
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToBottomRight.svg

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M9,10 L9,13 L3,13 L3,10 L9,10 Z"
transform="matrix(-1 0 0 1 16 0)"/>
</svg>

After

Width:  |  Height:  |  Size: 290 B

4
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToLeftBottom.svg

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M3,10 L3,13 L13,13 L13,3 L3,3 L3,10 L3,13 L6,13 L6,7 L3,7 L3,10 Z M2,2 L14,2 L14,14 L2,14 L2,2 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 249 B

4
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToLeftTop.svg

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M3,3 L6,3 L6,9 L3,9 L3,3 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 241 B

5
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToRightBottom.svg

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M3,10 L3,13 L13,13 L13,3 L3,3 L3,10 L3,13 L6,13 L6,7 L3,7 L3,10 Z M2,2 L14,2 L14,14 L2,14 L2,2 Z"
transform="matrix(-1 0 0 1 16 0)"/>
</svg>

After

Width:  |  Height:  |  Size: 293 B

5
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToRightTop.svg

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M3,3 L6,3 L6,9 L3,9 L3,3 Z"
transform="matrix(-1 0 0 1 16 0)"/>
</svg>

After

Width:  |  Height:  |  Size: 285 B

5
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToTopLeft.svg

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M9,10 L9,13 L3,13 L3,10 L9,10 Z"
transform="matrix(1 0 0 -1 0 16)"/>
</svg>

After

Width:  |  Height:  |  Size: 290 B

5
src/main/resources/com/weis/darklaf/icons/dark/navigation/moveToTopRight.svg

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#AFB1B3" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M9,10 L9,13 L3,13 L3,10 L9,10 Z"
transform="rotate(180 8 8)"/>
</svg>

After

Width:  |  Height:  |  Size: 284 B

4
src/main/resources/com/weis/darklaf/icons/light/navigation/moveToBottomLeft.svg

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#6E6E6E" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M9,10 L9,13 L3,13 L3,10 L9,10 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 246 B

5
src/main/resources/com/weis/darklaf/icons/light/navigation/moveToBottomRight.svg

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#6E6E6E" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M9,10 L9,13 L3,13 L3,10 L9,10 Z"
transform="matrix(-1 0 0 1 16 0)"/>
</svg>

After

Width:  |  Height:  |  Size: 290 B

4
src/main/resources/com/weis/darklaf/icons/light/navigation/moveToLeftBottom.svg

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#6E6E6E" fill-rule="evenodd"
d="M3,10 L3,13 L13,13 L13,3 L3,3 L3,10 L3,13 L6,13 L6,7 L3,7 L3,10 Z M2,2 L14,2 L14,14 L2,14 L2,2 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 249 B

4
src/main/resources/com/weis/darklaf/icons/light/navigation/moveToLeftTop.svg

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#6E6E6E" fill-rule="evenodd"
d="M2,2 L14,2 L14,14 L2,14 L2,2 Z M3,3 L3,13 L13,13 L13,3 L3,3 Z M3,3 L6,3 L6,9 L3,9 L3,3 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 241 B

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save