aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-04-15 15:47:04 +0300
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-04-26 00:41:53 +0300
commit67e660cfb277f184cb55b7234740cba1b2f462d0 (patch)
tree03855ffd5740f677fc58401f55ee5793661c8175 /src/main
parent993de8f9a6392fc69c92e33216d1da4fb8983c30 (diff)
downloadLibGui-67e660cfb277f184cb55b7234740cba1b2f462d0.tar.gz
LibGui-67e660cfb277f184cb55b7234740cba1b2f462d0.tar.bz2
LibGui-67e660cfb277f184cb55b7234740cba1b2f462d0.zip
Improve labeled slider docs
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
index 5b7e812..d9ab1b0 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
@@ -25,19 +25,47 @@ public class WLabeledSlider extends WAbstractSlider {
@Nullable private LabelUpdater labelUpdater = null;
private Alignment labelAlignment = Alignment.CENTER;
+ /**
+ * Constructs a horizontal slider with no default label.
+ *
+ * @param min the minimum value
+ * @param max the maximum value
+ */
public WLabeledSlider(int min, int max) {
this(min, max, Axis.HORIZONTAL);
}
+ /**
+ * Constructs a slider with no default label.
+ *
+ * @param min the minimum value
+ * @param max the maximum value
+ * @param axis the slider axis
+ */
public WLabeledSlider(int min, int max, Axis axis) {
super(min, max, axis);
}
+ /**
+ * Constructs a slider.
+ *
+ * @param min the minimum value
+ * @param max the maximum value
+ * @param axis the slider axis
+ * @param label the slider label (can be null)
+ */
public WLabeledSlider(int min, int max, Axis axis, @Nullable Text label) {
this(min, max, axis);
this.label = label;
}
+ /**
+ * Constructs a horizontal slider.
+ *
+ * @param min the minimum value
+ * @param max the maximum value
+ * @param label the slider label (can be null)
+ */
public WLabeledSlider(int min, int max, @Nullable Text label) {
this(min, max);
this.label = label;
@@ -52,11 +80,21 @@ public class WLabeledSlider extends WAbstractSlider {
}
}
+ /**
+ * Gets the current label of this slider.
+ *
+ * @return the label
+ */
@Nullable
public Text getLabel() {
return label;
}
+ /**
+ * Sets the label of this slider.
+ *
+ * @param label the new label
+ */
public void setLabel(@Nullable Text label) {
this.label = label;
}
@@ -69,19 +107,39 @@ public class WLabeledSlider extends WAbstractSlider {
}
}
+ /**
+ * Gets the text alignment of this slider's label.
+ *
+ * @return the alignment
+ */
public Alignment getLabelAlignment() {
return labelAlignment;
}
+ /**
+ * Sets the text alignment of this slider's label.
+ *
+ * @param labelAlignment the new alignment
+ */
public void setLabelAlignment(Alignment labelAlignment) {
this.labelAlignment = labelAlignment;
}
+ /**
+ * Gets the {@link LabelUpdater} of this slider.
+ *
+ * @return the label updater
+ */
@Nullable
public LabelUpdater getLabelUpdater() {
return labelUpdater;
}
+ /**
+ * Sets the {@link LabelUpdater} of this slider.
+ *
+ * @param labelUpdater the new label updater
+ */
public void setLabelUpdater(@Nullable LabelUpdater labelUpdater) {
this.labelUpdater = labelUpdater;
}
@@ -150,8 +208,19 @@ public class WLabeledSlider extends WAbstractSlider {
ScreenDrawing.texturedRect(x + halfWidth, y, halfWidth, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonEndLeft, buttonTop, 200 * px, buttonTop + buttonHeight, 0xFFFFFFFF);
}
+ /**
+ * A label updater updates the label of a slider based on the current value.
+ *
+ * <p>Useful for situations when you want to have display values on the slider.
+ */
@FunctionalInterface
public interface LabelUpdater {
+ /**
+ * Gets the updated label for the new slider value.
+ *
+ * @param value the slider value
+ * @return the label
+ */
Text updateLabel(int value);
}
}