Skip to content

Commit 5656199

Browse files
authored
Add the rest of helper methods for ITooltip (#72)
1 parent ed3b487 commit 5656199

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

src/main/java/com/cleanroommc/modularui/api/widget/ITooltip.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,41 @@ default W tooltipShowUpTimer(int showUpTimer) {
147147
return getThis();
148148
}
149149

150+
/**
151+
* Sets whether the tooltip should automatically update on every render tick. In most of the cases you don't need this,
152+
* as ValueSyncHandler handles tooltip update for you when value is updated. However, if you don't handle differently,
153+
* you either need to manually set change listener for the sync value, or set auto update to true.
154+
*
155+
* @param update true if the tooltip should automatically update
156+
* @return this
157+
*/
158+
default W tooltipAutoUpdate(boolean update) {
159+
tooltip().setAutoUpdate(update);
160+
return getThis();
161+
}
162+
163+
/**
164+
* Sets whether the tooltip has a title margin, which is 2px space between first and second line inserted by default.
165+
*
166+
* @param hasTitleMargin true if the tooltip should have a title margin
167+
* @return this
168+
*/
169+
default W tooltipHasTitleMargin(boolean hasTitleMargin) {
170+
tooltip().setHasTitleMargin(hasTitleMargin);
171+
return getThis();
172+
}
173+
174+
/**
175+
* Sets the line padding for the tooltip. 1px by default, and you can disable it by passing 0.
176+
*
177+
* @param linePadding line padding in px
178+
* @return this
179+
*/
180+
default W tooltipLinePadding(int linePadding) {
181+
tooltip().setLinePadding(linePadding);
182+
return getThis();
183+
}
184+
150185
/**
151186
* Adds any drawable as a new line. Inlining elements is currently not possible.
152187
*
@@ -167,4 +202,26 @@ default W addTooltipLine(IDrawable drawable) {
167202
default W addTooltipLine(String line) {
168203
return addTooltipLine(IKey.str(line));
169204
}
205+
206+
/**
207+
* Helper method to add multiple drawable lines.
208+
*
209+
* @param lines collection of drawable elements
210+
* @return this
211+
*/
212+
default W addTooltipDrawableLines(Iterable<IDrawable> lines) {
213+
tooltip().addDrawableLines(lines);
214+
return getThis();
215+
}
216+
217+
/**
218+
* Helper method to add multiple text lines.
219+
*
220+
* @param lines lines of text
221+
* @return this
222+
*/
223+
default W addTooltipStringLines(Iterable<String> lines) {
224+
tooltip().addStringLines(lines);
225+
return getThis();
226+
}
170227
}

0 commit comments

Comments
 (0)