Add documentation for IWailaVariableWidthTooltipRenderer (#44)

This commit is contained in:
SuperSoupr authored and GitHub committed 2025-10-20 21:47:51 +00:00
1 parent e82729a113
commit 07b9d1bf92
2 files changed
+23 -3

No files matched your search

@@ -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.</br>
* Called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render.</br>
*
* @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.</br>
* 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.</br>
*
* @return The width of the longest line in the tooltip
*
*/
int getMaxLineWidth();
}
@@ -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);
}