1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
package me.shedaniel.rei.api.widgets;
import me.shedaniel.math.api.Point;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.OptionalInt;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
public abstract class Button extends BaseWidget<Button> {
public abstract void setTextColor(@Nullable BiFunction<@NotNull Button, @NotNull Point, @NotNull Integer> textColorFunction);
public final Button textColor(@Nullable BiFunction<@NotNull Button, @NotNull Point, @NotNull Integer> textColorFunction) {
setTextColor(textColorFunction);
return this;
}
public abstract int getTextColor(Point mouse);
public abstract void setTextureId(@Nullable BiFunction<@NotNull Button, @NotNull Point, @NotNull Integer> textureIdFunction);
public final Button textureId(@Nullable BiFunction<@NotNull Button, @NotNull Point, @NotNull Integer> textureIdFunction) {
setTextureId(textureIdFunction);
return this;
}
public abstract int getTextureId(Point mouse);
public abstract void onClick();
public abstract boolean isEnabled();
public abstract void setEnabled(boolean enabled);
public final Button enabled(boolean enabled) {
setEnabled(enabled);
return this;
}
public abstract OptionalInt getTint();
public abstract void setTint(int tint);
public abstract void removeTint();
public final Button tint(@Nullable Integer tint) {
if (tint == null)
removeTint();
else setTint(tint);
return this;
}
@NotNull
public abstract String getText();
public abstract void setText(@NotNull String text);
@NotNull
public final Button text(@NotNull String text) {
setText(text);
return this;
}
@Nullable
public abstract Consumer<Button> getOnClick();
public abstract void setOnClick(@Nullable Consumer<Button> onClick);
@NotNull
public final Button onClick(@Nullable Consumer<Button> onClick) {
setOnClick(onClick);
return this;
}
@Nullable
public abstract Consumer<Button> getOnRender();
public abstract void setOnRender(@Nullable Consumer<Button> onRender);
@NotNull
public final Button onRender(@Nullable Consumer<Button> onRender) {
setOnRender(onRender);
return this;
}
/**
* @return whether the button is focusable by pressing tab, ignored if not clickable.
*/
public abstract boolean isFocusable();
/**
* Sets whether the button is focusable by pressing tab, ignored if not clickable.
*
* @param focusable whether the button is focusable by pressing tab, ignored if not clickable.
*/
public abstract void setFocusable(boolean focusable);
/**
* Sets whether the button is focusable by pressing tab, ignored if not clickable.
*
* @param focusable whether the label is focusable by pressing tab, ignored if not clickable.
* @return the button itself.
*/
@NotNull
public final Button focusable(boolean focusable) {
setFocusable(focusable);
return this;
}
/**
* @return the tooltip from the current tooltip function, null if no tooltip.
*/
@Nullable
public abstract String getTooltip();
/**
* Sets the tooltip function used to get the tooltip.
*
* @param tooltip the tooltip function used to get the tooltip.
*/
public abstract void setTooltip(@Nullable Function<@NotNull Button, @Nullable String> tooltip);
/**
* Sets the tooltip.
*
* @param tooltip the lines of tooltip.
* @return the button itself.
*/
@NotNull
public final Button tooltipLines(@NotNull String... tooltip) {
return tooltipLine(String.join("\n", tooltip));
}
/**
* Sets the tooltip.
*
* @param tooltip the line of tooltip.
* @return the button itself.
*/
@NotNull
public final Button tooltipLine(@Nullable String tooltip) {
return tooltipSupplier(label -> tooltip);
}
/**
* Sets the tooltip function.
*
* @param tooltip the tooltip function used to get the tooltip.
* @return the button itself.
*/
@NotNull
public final Button tooltipSupplier(@Nullable Function<@NotNull Button, @Nullable String> tooltip) {
setTooltip(tooltip);
return this;
}
public abstract boolean isFocused();
}
|