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
@ -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. |
@ -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); |
||||
} |
||||
} |
@ -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,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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
|
@ -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); |
||||
} |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 241 B |
After Width: | Height: | Size: 293 B |
After Width: | Height: | Size: 285 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 284 B |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 241 B |