From 9ce069457bca016c8793c73844e5cc984deac365 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 10 Mar 2020 02:03:11 +0800 Subject: new widget api Signed-off-by: shedaniel --- .../me/shedaniel/rei/gui/widget/LabelWidget.java | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java') 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; @@ -44,6 +51,11 @@ public class LabelWidget extends WidgetWithBounds { private boolean centered = true; private Supplier 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; @@ -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 onClicked) { + return createClickable((Point) point, text, onClicked); + } + public static ClickableLabelWidget createClickable(Point point, String text, Consumer 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; } -- cgit