aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-03-10 02:03:11 +0800
committershedaniel <daniel@shedaniel.me>2020-03-10 02:03:11 +0800
commit9ce069457bca016c8793c73844e5cc984deac365 (patch)
tree367195b8ec8402638a2d9af267eb45c2dd08ae89 /src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java
parentb31a280413f5ec916f44fbd96d0690f8ce1a9186 (diff)
downloadRoughlyEnoughItems-9ce069457bca016c8793c73844e5cc984deac365.tar.gz
RoughlyEnoughItems-9ce069457bca016c8793c73844e5cc984deac365.tar.bz2
RoughlyEnoughItems-9ce069457bca016c8793c73844e5cc984deac365.zip
new widget api
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java
index a878f45be..376a49e65 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java
@@ -23,9 +23,10 @@
package me.shedaniel.rei.gui.widget;
-import me.shedaniel.math.api.Point;
+import me.shedaniel.math.Point;
import me.shedaniel.math.api.Rectangle;
import me.shedaniel.rei.api.REIHelper;
+import me.shedaniel.rei.api.widgets.Widgets;
import net.minecraft.client.gui.Element;
import org.jetbrains.annotations.ApiStatus;
@@ -35,6 +36,12 @@ import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;
+/**
+ * @see Widgets#createLabel(Point, String)
+ * @see Widgets#createClickableLabel(Point, String, Consumer)
+ */
+@Deprecated
+@ApiStatus.ScheduledForRemoval
public class LabelWidget extends WidgetWithBounds {
private Point pos;
@@ -45,6 +52,11 @@ public class LabelWidget extends WidgetWithBounds {
private Supplier<String> tooltipSupplier;
@ApiStatus.Internal
+ public LabelWidget(me.shedaniel.math.api.Point point, String text) {
+ this((Point) point, text);
+ }
+
+ @ApiStatus.Internal
public LabelWidget(Point point, String text) {
this.pos = point;
this.text = text;
@@ -55,6 +67,14 @@ public class LabelWidget extends WidgetWithBounds {
return new LabelWidget(point, text);
}
+ public static LabelWidget create(me.shedaniel.math.api.Point point, String text) {
+ return new LabelWidget(point, text);
+ }
+
+ public static ClickableLabelWidget createClickable(me.shedaniel.math.api.Point point, String text, Consumer<ClickableLabelWidget> onClicked) {
+ return createClickable((Point) point, text, onClicked);
+ }
+
public static ClickableLabelWidget createClickable(Point point, String text, Consumer<ClickableLabelWidget> onClicked) {
ClickableLabelWidget[] widget = {null};
widget[0] = new ClickableLabelWidget(point, text) {
@@ -110,11 +130,25 @@ public class LabelWidget extends WidgetWithBounds {
this.defaultColor = defaultColor;
}
- public Point getPosition() {
+ /**
+ * @return the position of this label
+ * @deprecated Use {@link #getLocation()}
+ */
+ @Deprecated
+ @ApiStatus.ScheduledForRemoval
+ public me.shedaniel.math.api.Point getPosition() {
+ return new me.shedaniel.math.api.Point(getLocation());
+ }
+
+ public Point getLocation() {
return pos;
}
- public LabelWidget setPosition(Point position) {
+ public LabelWidget setPosition(me.shedaniel.math.api.Point position) {
+ return setLocation(position);
+ }
+
+ public LabelWidget setLocation(Point position) {
this.pos = position;
return this;
}