diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-07-29 12:25:47 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-07-29 14:25:53 +0800 |
| commit | ba446965dad004cb38679f0f0e1a526151d84213 (patch) | |
| tree | 60fe2736316a63d47cf533a02bf29fbd5045b91c /src/main/java/me/shedaniel/rei/api/widgets/Label.java | |
| parent | 929ca0ed6de9dd25208304cd0f51a8f2d0f22ceb (diff) | |
| download | RoughlyEnoughItems-ba446965dad004cb38679f0f0e1a526151d84213.tar.gz RoughlyEnoughItems-ba446965dad004cb38679f0f0e1a526151d84213.tar.bz2 RoughlyEnoughItems-ba446965dad004cb38679f0f0e1a526151d84213.zip | |
5.x - 20w30a
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/api/widgets/Label.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/api/widgets/Label.java | 306 |
1 files changed, 0 insertions, 306 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/widgets/Label.java b/src/main/java/me/shedaniel/rei/api/widgets/Label.java deleted file mode 100644 index a4b296b54..000000000 --- a/src/main/java/me/shedaniel/rei/api/widgets/Label.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.api.widgets; - -import me.shedaniel.math.Point; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.gui.widget.WidgetWithBounds; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Function; - -public abstract class Label extends WidgetWithBounds { - public static final int LEFT_ALIGNED = -1; - public static final int CENTER = 0; - public static final int RIGHT_ALIGNED = 1; - - /** - * @return whether the label is clickable, ignores if onClick is set. - */ - public abstract boolean isClickable(); - - /** - * Sets whether the label is clickable, ignores if onClick is set. - * - * @param clickable whether the label is clickable. - */ - public abstract void setClickable(boolean clickable); - - /** - * Sets the label as clickable, ignores if onClick is set. - * - * @return the label itself. - */ - @NotNull - public final Label clickable() { - return clickable(true); - } - - /** - * Sets whether the label is clickable, ignores if onClick is set. - * - * @param clickable whether the label is clickable. - * @return the label itself. - */ - @NotNull - public final Label clickable(boolean clickable) { - setClickable(clickable); - return this; - } - - /** - * @return the consumer on click, only applicable if the label is clickable, null if not set. - */ - @Nullable - public abstract Consumer<Label> getOnClick(); - - /** - * Sets the on click consumer, only applicable if the label is clickable. - * - * @param onClick the on click consumer, only applicable if the label is clickable. - */ - public abstract void setOnClick(@Nullable Consumer<Label> onClick); - - /** - * Sets the on click consumer, only applicable if the label is clickable. - * - * @param onClick the on click consumer, only applicable if the label is clickable. - * @return the label itself. - */ - @NotNull - public final Label onClick(@Nullable Consumer<Label> onClick) { - setOnClick(onClick); - return this; - } - - /** - * @return the consumer before render, null if not set. - */ - @Nullable - public abstract BiConsumer<MatrixStack, Label> getOnRender(); - - /** - * Sets the consumer before render. - * - * @param onRender the consumer before render. - */ - public abstract void setOnRender(@Nullable BiConsumer<MatrixStack, Label> onRender); - - /** - * Sets the consumer before render. - * - * @param onRender the consumer before render. - * @return the label itself. - */ - @NotNull - public final Label onRender(@Nullable BiConsumer<MatrixStack, Label> onRender) { - setOnRender(onRender); - return this; - } - - /** - * @return whether the label is focusable by pressing tab, ignored if not clickable. - */ - public abstract boolean isFocusable(); - - /** - * Sets whether the label is focusable by pressing tab, ignored if not clickable. - * - * @param focusable whether the label is focusable by pressing tab, ignored if not clickable. - */ - public abstract void setFocusable(boolean focusable); - - /** - * Sets whether the label 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 label itself. - */ - @NotNull - public final Label 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<Label, @Nullable String> tooltip); - - /** - * Sets the tooltip. - * - * @param tooltip the lines of tooltip. - * @return the label itself. - */ - @NotNull - public final Label tooltipLines(@NotNull String... tooltip) { - return tooltipLine(String.join("\n", tooltip)); - } - - /** - * Sets the tooltip. - * - * @param tooltip the line of tooltip. - * @return the label itself. - */ - @NotNull - public final Label tooltipLine(@Nullable String tooltip) { - return tooltipSupplier(label -> tooltip); - } - - /** - * Sets the tooltip function. - * - * @param tooltip the tooltip function used to get the tooltip. - * @return the label itself. - */ - @NotNull - public final Label tooltipSupplier(@Nullable Function<Label, @Nullable String> tooltip) { - setTooltip(tooltip); - return this; - } - - /** - * Gets the horizontal alignment of the label, defaulted as centered. - * - * @return {@link Label#LEFT_ALIGNED} if left aligned, {@link Label#CENTER} if centered or {@link Label#RIGHT_ALIGNED} if right aligned}. - */ - public abstract int getHorizontalAlignment(); - - @NotNull - public final Label centered() { - return horizontalAlignment(CENTER); - } - - @NotNull - public final Label leftAligned() { - return horizontalAlignment(LEFT_ALIGNED); - } - - @NotNull - public final Label rightAligned() { - return horizontalAlignment(RIGHT_ALIGNED); - } - - public abstract void setHorizontalAlignment(int horizontalAlignment); - - public final Label horizontalAlignment(int horizontalAlignment) { - setHorizontalAlignment(horizontalAlignment); - return this; - } - - public abstract boolean hasShadow(); - - @NotNull - public final Label noShadow() { - return shadow(false); - } - - @NotNull - public final Label shadow() { - return shadow(true); - } - - public abstract void setShadow(boolean hasShadow); - - @NotNull - public final Label shadow(boolean hasShadow) { - setShadow(hasShadow); - return this; - } - - public abstract int getColor(); - - public abstract void setColor(int color); - - @NotNull - public final Label color(int lightModeColor, int darkModeColor) { - return color(REIHelper.getInstance().isDarkThemeEnabled() ? darkModeColor : lightModeColor); - } - - @NotNull - public final Label color(int color) { - setColor(color); - return this; - } - - public abstract int getHoveredColor(); - - public abstract void setHoveredColor(int hoveredColor); - - @NotNull - public final Label hoveredColor(int lightModeColor, int darkModeColor) { - return hoveredColor(REIHelper.getInstance().isDarkThemeEnabled() ? darkModeColor : lightModeColor); - } - - @NotNull - public final Label hoveredColor(int color) { - setHoveredColor(color); - return this; - } - - @NotNull - public abstract Point getPoint(); - - public final int getX() { - return getPoint().getX(); - } - - public final int getY() { - return getPoint().getY(); - } - - public abstract void setPoint(@NotNull Point point); - - @NotNull - public final Label point(@NotNull Point point) { - setPoint(point); - return this; - } - - @NotNull - public abstract Text getText(); - - public abstract void setText(@NotNull Text text); - - @NotNull - public final Label text(@NotNull Text text) { - setText(text); - return this; - } -} |
