Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the rest of helper methods for ITooltip #72

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/main/java/com/cleanroommc/modularui/api/widget/ITooltip.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,41 @@ default W tooltipShowUpTimer(int showUpTimer) {
return getThis();
}

/**
* Sets whether the tooltip should automatically update on every render tick. In most of the cases you don't need this,
* as ValueSyncHandler handles tooltip update for you when value is updated. However, if you don't handle differently,
* you either need to manually set change listener for the sync value, or set auto update to true.
*
* @param update true if the tooltip should automatically update
* @return this
*/
default W tooltipAutoUpdate(boolean update) {
tooltip().setAutoUpdate(update);
return getThis();
}

/**
* Sets whether the tooltip has a title margin, which is 2px space between first and second line inserted by default.
*
* @param hasTitleMargin true if the tooltip should have a title margin
* @return this
*/
default W tooltipHasTitleMargin(boolean hasTitleMargin) {
tooltip().setHasTitleMargin(hasTitleMargin);
return getThis();
}

/**
* Sets the line padding for the tooltip. 1px by default, and you can disable it by passing 0.
*
* @param linePadding line padding in px
* @return this
*/
default W tooltipLinePadding(int linePadding) {
tooltip().setLinePadding(linePadding);
return getThis();
}

/**
* Adds any drawable as a new line. Inlining elements is currently not possible.
*
Expand All @@ -167,4 +202,26 @@ default W addTooltipLine(IDrawable drawable) {
default W addTooltipLine(String line) {
return addTooltipLine(IKey.str(line));
}

/**
* Helper method to add multiple drawable lines.
*
* @param lines collection of drawable elements
* @return this
*/
default W addTooltipDrawableLines(Iterable<IDrawable> lines) {
tooltip().addDrawableLines(lines);
return getThis();
}

/**
* Helper method to add multiple text lines.
*
* @param lines lines of text
* @return this
*/
default W addTooltipStringLines(Iterable<String> lines) {
tooltip().addStringLines(lines);
return getThis();
}
}