From 2c1eadf8814ac3afdb0d8d0a6e232a9f8a09eae0 Mon Sep 17 00:00:00 2001 From: weisj Date: Sun, 5 Jul 2020 20:28:08 +0200 Subject: [PATCH] Move macOS specific behaviour into separate class. --- .../darklaf/ui/tooltip/DarkMacTooltipUI.java | 40 +++++++++++++++++++ .../darklaf/ui/tooltip/DarkToolTipUI.java | 6 ++- .../properties/platform/mac.properties | 2 + 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkMacTooltipUI.java diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkMacTooltipUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkMacTooltipUI.java new file mode 100644 index 00000000..7f610af7 --- /dev/null +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkMacTooltipUI.java @@ -0,0 +1,40 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +package com.github.weisj.darklaf.ui.tooltip; + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + +public class DarkMacTooltipUI extends DarkToolTipUI { + + public static ComponentUI createUI(final JComponent c) { + return new DarkMacTooltipUI(); + } + + @Override + protected boolean useDecoratedPopup() { + return true; + } +} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java index 9e50af11..e7cb202f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java @@ -120,7 +120,7 @@ public class DarkToolTipUI extends BasicToolTipUI implements PropertyChangeListe @Override protected void installDefaults(final JComponent c) { super.installDefaults(c); - toolTip.putClientProperty(DarkPopupFactory.KEY_NO_DECORATION, true); + toolTip.putClientProperty(DarkPopupFactory.KEY_NO_DECORATION, !useDecoratedPopup()); toolTip.putClientProperty(DarkPopupFactory.KEY_START_HIDDEN, true); toolTip.putClientProperty(DarkPopupFactory.KEY_FORCE_HEAVYWEIGHT, true); fadeAnimator = new FadeInAnimator(); @@ -128,6 +128,10 @@ public class DarkToolTipUI extends BasicToolTipUI implements PropertyChangeListe updateStyle(); } + protected boolean useDecoratedPopup() { + return false; + } + @Override public void update(final Graphics g, final JComponent c) { // Ensures no background is painted. diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties index 16e3d820..d09a2be9 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties @@ -28,6 +28,8 @@ ScrollBarUI = com.github.weisj.darklaf.ui.scrollpane.Dark ScrollBar.smallWidth = 10 ScrollBar.width = 12 +TooltipUI = com.github.weisj.darklaf.ui.tooltip.DarkMacTooltipUI + Table.alternateRowColor = true Tree.alternateRowColor = true List.alternateRowColor = true