Browse Source

Made the default ToolTipContext changeable.

pull/130/head
weisj 5 years ago
parent
commit
25bdd3ab1d
  1. 19
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  2. 8
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java

19
core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java

@ -40,6 +40,25 @@ import java.util.function.Function;
public class ToolTipContext {
private static ToolTipContext defaultContext;
public static ToolTipContext getDefaultContext() {
if (defaultContext == null) defaultContext = createDefaultContext();
return defaultContext;
}
private static ToolTipContext createDefaultContext() {
return new ToolTipContext().setAlignment(Alignment.SOUTH)
.setCenterAlignment(Alignment.SOUTH)
.setAlignInside(false)
.setIgnoreBorder(true)
.setUseBestFit(true);
}
public static void setDefaultContext(final ToolTipContext defaultContext) {
ToolTipContext.defaultContext = defaultContext;
}
private final Insets calcInsets = new Insets(0, 0, 0, 0);
private JComponent target;
private final MouseListener mouseListener = new MouseAdapter() {

8
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java

@ -34,12 +34,6 @@ import java.util.function.BiConsumer;
public class ToolTipUtil {
private final static ToolTipContext DEFAULT_CONTEXT = new ToolTipContext().setAlignment(Alignment.SOUTH)
.setCenterAlignment(Alignment.SOUTH)
.setAlignInside(false)
.setIgnoreBorder(true)
.setUseBestFit(true);
public static void applyContext(final JToolTip toolTip) {
JComponent target = toolTip.getComponent();
if (target == null) return;
@ -150,7 +144,7 @@ public class ToolTipUtil {
}
Object style = tooltip.getComponent().getClientProperty(DarkTooltipUI.KEY_STYLE);
if (ToolTipStyle.BALLOON.equals(DarkTooltipUI.getStyle(style))) {
return DEFAULT_CONTEXT;
return ToolTipContext.getDefaultContext();
}
return null;
}

Loading…
Cancel
Save