Browse Source

Move macOS specific behaviour into separate class.

pull/187/head
weisj 4 years ago
parent
commit
2c1eadf881
  1. 40
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkMacTooltipUI.java
  2. 6
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java
  3. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties

40
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;
}
}

6
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.

2
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

Loading…
Cancel
Save