blob: 4a3f36bb276e3dcf90a4abb59c17720157246b84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package dev.isxander.yacl3.gui.controllers.slider;
import dev.isxander.yacl3.api.Controller;
import dev.isxander.yacl3.api.utils.Dimension;
import dev.isxander.yacl3.gui.AbstractWidget;
import dev.isxander.yacl3.gui.YACLScreen;
/**
* Simple custom slider implementation that shifts the current value across when shown.
* <p>
* For simplicity, {@link SliderControllerElement} works in doubles so each
* {@link ISliderController} must cast to double. This is to get around re-writing the element for every type.
*/
public interface ISliderController<T extends Number> extends Controller<T> {
/**
* Gets the minimum value for the slider
*/
double min();
/**
* Gets the maximum value for the slider
*/
double max();
/**
* Gets the interval (or step size) for the slider.
*/
double interval();
/**
* Gets the range of the slider.
*/
default double range() {
return max() - min();
}
/**
* Sets the {@link dev.isxander.yacl3.api.Option}'s pending value
*/
void setPendingValue(double value);
/**
* Gets the {@link dev.isxander.yacl3.api.Option}'s pending value
*/
double pendingValue();
/**
* {@inheritDoc}
*/
@Override
default AbstractWidget provideWidget(YACLScreen screen, Dimension<Integer> widgetDimension) {
return new SliderControllerElement(this, screen, widgetDimension, min(), max(), interval());
}
}
|