Browse Source

Tooltip: Correct shadow size insets for top alignment.

pull/235/head
weisj 4 years ago
parent
commit
cbf0260358
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 7
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  2. 17
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java
  3. 14
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java

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

@ -366,8 +366,11 @@ public class ToolTipContext {
public void updateToolTip() {
if (toolTip != null) {
toolTip.putClientProperty(DarkToolTipUI.KEY_POINTER_LOCATION,
alignment == Alignment.CENTER ? centerAlignment.opposite()
: alignInside ? alignment : alignment.opposite());
alignment == Alignment.CENTER
? centerAlignment.opposite()
: alignInside
? alignment
: alignment.opposite());
toolTip.putClientProperty(DarkToolTipUI.KEY_INSETS, insets);
toolTip.doLayout();
}

17
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java

@ -55,9 +55,10 @@ public class DarkToolTipUI extends BasicToolTipUI
boolean inside = isInside(e);
if (!inside) {
ToolTipManager.sharedInstance()
.mouseExited(new MouseEvent(toolTip.getComponent(), e.getID(), e.getWhen(), e.getModifiersEx(),
Integer.MIN_VALUE, Integer.MIN_VALUE, e.getClickCount(), e.isPopupTrigger(),
e.getButton()));
.mouseExited(new MouseEvent(
toolTip.getComponent(), e.getID(), e.getWhen(),
e.getModifiersEx(), Integer.MIN_VALUE, Integer.MIN_VALUE,
e.getClickCount(), e.isPopupTrigger(), e.getButton()));
}
}
};
@ -77,8 +78,11 @@ public class DarkToolTipUI extends BasicToolTipUI
if (p.y == c.getHeight()) p.y--;
p.x = Math.max(p.x, 0);
p.y = Math.max(p.y, 0);
ToolTipManager.sharedInstance().mouseEntered(new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiersEx(),
p.x, p.y, e.getClickCount(), e.isPopupTrigger(), e.getButton()));
ToolTipManager.sharedInstance()
.mouseEntered(new MouseEvent(
c, e.getID(), e.getWhen(),
e.getModifiersEx(), p.x, p.y,
e.getClickCount(), e.isPopupTrigger(), e.getButton()));
}
@Override
@ -209,7 +213,10 @@ public class DarkToolTipUI extends BasicToolTipUI
Insets insets = c.getInsets();
Rectangle paintTextR = new Rectangle(insets.left, insets.top, size.width - (insets.left + insets.right),
size.height - (insets.top + insets.bottom));
Rectangle r = new Rectangle(paintTextR);
StringPainter.drawString(g, c, tipText, paintTextR);
g.setColor(Color.GREEN);
PaintUtil.drawRect(g, r);
}
}

14
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java

@ -99,7 +99,7 @@ public class DarkTooltipBorder implements Border, AlignableTooltipBorder {
} else if (align == Alignment.WEST) {
si.left -= pointerSize;
} else if (align.isNorth()) {
si.top = 0;
si.top -= pointerSize;
}
}
@ -147,14 +147,10 @@ public class DarkTooltipBorder implements Border, AlignableTooltipBorder {
Insets ins = new Insets(0, 0, 0, 0);
Insets bi = bubbleBorder.getBorderInsets(c);
Insets si = shadowBorder.getBorderInsets(c);
ins.bottom = Math.max(bi.bottom, si.bottom);
ins.left = Math.max(bi.left, si.left);
ins.right = Math.max(bi.right, si.right);
ins.top = Math.max(bi.top, si.top);
ins.left += uIns.left;
ins.top += uIns.top;
ins.right += uIns.right;
ins.bottom += uIns.bottom;
ins.bottom = Math.max(bi.bottom, si.bottom) + uIns.bottom;
ins.left = Math.max(bi.left, si.left) + uIns.left;
ins.right = Math.max(bi.right, si.right) + uIns.right;
ins.top = Math.max(bi.top, si.top) + uIns.top;
return ins;
}

Loading…
Cancel
Save