diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-04-15 15:47:04 +0300 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-04-15 15:47:04 +0300 |
commit | ba1f9689d6a35fe0dc9f60ce4351030f52609d4f (patch) | |
tree | ce7dcd4e917c2266d4ba1026321e1a0719111dc1 /src/main/java | |
parent | fdf0ce3f5327dc2efcab8789fd4a41d5d8962ada (diff) | |
download | LibGui-ba1f9689d6a35fe0dc9f60ce4351030f52609d4f.tar.gz LibGui-ba1f9689d6a35fe0dc9f60ce4351030f52609d4f.tar.bz2 LibGui-ba1f9689d6a35fe0dc9f60ce4351030f52609d4f.zip |
Improve labeled slider docs
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java | 69 |
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 4541427..af5ab58 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); } } |