diff --git a/src/main/java/mcp/mobius/waila/api/IWailaVariableWidthTooltipRenderer.java b/src/main/java/mcp/mobius/waila/api/IWailaVariableWidthTooltipRenderer.java index e6d9686..95cc74d 100644 --- a/src/main/java/mcp/mobius/waila/api/IWailaVariableWidthTooltipRenderer.java +++ b/src/main/java/mcp/mobius/waila/api/IWailaVariableWidthTooltipRenderer.java @@ -1,9 +1,29 @@ package mcp.mobius.waila.api; +/** + * Interface for tooltip renderers that adjust their width depending on the width of the rest of the tooltip. + * setMaxLineWidth is called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render to inform the + * renderer of the width of the longest line in the tooltip. + */ public interface IWailaVariableWidthTooltipRenderer extends IWailaTooltipRenderer { - void setMaxStringW(int width); + /** + * Informs the renderer of what the length of the longest line is.
+ * Called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render.
+ * + * @param width The width of the longest line in the tooltip. + * + */ + void setMaxLineWidth(int width); - int getMaxStringW(); + /** + * Returns the width of the longest line in the current tooltip.
+ * With icons disabled the tooltip's background box is always 2 pixels wider to the right of the line than it is to + * the left.
+ * + * @return The width of the longest line in the tooltip + * + */ + int getMaxLineWidth(); } diff --git a/src/main/java/mcp/mobius/waila/overlay/Tooltip.java b/src/main/java/mcp/mobius/waila/overlay/Tooltip.java index 6cda248..b9d8905 100644 --- a/src/main/java/mcp/mobius/waila/overlay/Tooltip.java +++ b/src/main/java/mcp/mobius/waila/overlay/Tooltip.java @@ -183,7 +183,7 @@ public class Tooltip { new Point(offsetX, offsetY), renderMatcher.group("args").split(",")); if (renderer instanceof IWailaVariableWidthTooltipRenderer variableWidthRenderer) { - variableWidthRenderer.setMaxStringW(maxStringW); + variableWidthRenderer.setMaxLineWidth(maxStringW); } this.elements2nd.add(renderable); }