use of com.spinyowl.legui.component.Slider in project legui by SpinyOwl.
the class ExampleGui method createShadowWidget.
private Widget createShadowWidget() {
Widget shadowWidget = new Widget(20, 310, 200, 120);
shadowWidget.getTitleTextState().setText("Shadow test widget");
shadowWidget.setCloseable(false);
shadowWidget.setResizable(false);
shadowWidget.setAscendible(true);
shadowWidget.getStyle().setShadow(new Shadow());
shadowWidget.getStyle().getShadow().setColor(ColorConstants.red());
Slider hOffsetSlider = new Slider(110, 5 + 20 * 0, 80, 10);
shadowWidget.getContainer().add(hOffsetSlider);
hOffsetSlider.setValue(50f);
hOffsetSlider.addSliderChangeValueEventListener((e) -> shadowWidget.getStyle().getShadow().sethOffset(hOffsetSlider.getValue() - 50f));
Label hOffsetLabel = new Label(10, 2 + 20 * 0, 90, 14);
hOffsetLabel.getStyle().setFontSize(12f);
hOffsetLabel.getHoveredStyle().setFontSize(14f);
hOffsetLabel.getTextState().setText("HOffset: ");
shadowWidget.getContainer().add(hOffsetLabel);
Slider vOffsetSlider = new Slider(110, 2 + 20 * 1, 80, 14);
shadowWidget.getContainer().add(vOffsetSlider);
vOffsetSlider.setValue(50f);
vOffsetSlider.addSliderChangeValueEventListener((e) -> shadowWidget.getStyle().getShadow().setvOffset(vOffsetSlider.getValue() - 50f));
Label vOffsetLabel = new Label(10, 2 + 20 * 1, 90, 14);
vOffsetLabel.getTextState().setText("VOffset: ");
shadowWidget.getContainer().add(vOffsetLabel);
Slider blurSlider = new Slider(110, 2 + 20 * 2, 80, 14);
shadowWidget.getContainer().add(blurSlider);
blurSlider.addSliderChangeValueEventListener((e) -> shadowWidget.getStyle().getShadow().setBlur(blurSlider.getValue()));
Label blurLabel = new Label(10, 2 + 20 * 2, 90, 14);
blurLabel.getTextState().setText("Blur: ");
shadowWidget.getContainer().add(blurLabel);
Slider spreadSlider = new Slider(110, 2 + 20 * 3, 80, 14);
shadowWidget.getContainer().add(spreadSlider);
spreadSlider.setValue(50f);
spreadSlider.addSliderChangeValueEventListener((e) -> shadowWidget.getStyle().getShadow().setSpread(spreadSlider.getValue() - 50f));
Label spreadLabel = new Label(10, 2 + 20 * 3, 90, 14);
spreadLabel.getTextState().setText("Spread: ");
shadowWidget.getContainer().add(spreadLabel);
Slider transparencySlider = new Slider(110, 2 + 20 * 4, 80, 14);
shadowWidget.getContainer().add(transparencySlider);
transparencySlider.addSliderChangeValueEventListener((e) -> {
shadowWidget.getStyle().getBackground().getColor().w = 1 - transparencySlider.getValue() / 100f;
shadowWidget.getContainer().getStyle().getBackground().getColor().w = 1 - transparencySlider.getValue() / 100f;
});
Label transparencyLabel = new Label(10, 2 + 20 * 4, 90, 14);
transparencyLabel.getTextState().setText("W Transparency: ");
shadowWidget.getContainer().add(transparencyLabel);
return shadowWidget;
}
use of com.spinyowl.legui.component.Slider in project legui by SpinyOwl.
the class SliderMouseDragEventListener method process.
@Override
public void process(MouseDragEvent event) {
Slider slider = (Slider) event.getTargetComponent();
if (!Mouse.MouseButton.MOUSE_BUTTON_LEFT.isPressed()) {
return;
}
// calculate new value
float value = SliderHelper.determineSliderValue(slider, Mouse.getCursorPosition());
// set value & push event
float oldValue = slider.getValue();
slider.setValue(value);
EventProcessorProvider.getInstance().pushEvent(new SliderChangeValueEvent(slider, event.getContext(), event.getFrame(), oldValue, slider.getValue()));
}
use of com.spinyowl.legui.component.Slider in project legui by SpinyOwl.
the class SliderMouseClickEventListener method process.
@Override
public void process(MouseClickEvent event) {
if (!event.getButton().equals(Mouse.MouseButton.MOUSE_BUTTON_LEFT) || event.getAction() != MouseClickEvent.MouseClickAction.PRESS) {
return;
}
Slider slider = (Slider) event.getTargetComponent();
// calculate new value
float value = SliderHelper.determineSliderValue(slider, Mouse.getCursorPosition());
// set value & push event
float oldValue = slider.getValue();
slider.setValue(value);
EventProcessorProvider.getInstance().pushEvent(new SliderChangeValueEvent(slider, event.getContext(), event.getFrame(), oldValue, slider.getValue()));
}
use of com.spinyowl.legui.component.Slider in project legui by SpinyOwl.
the class SliderScrollEventListener method process.
@Override
public void process(ScrollEvent event) {
Slider slider = (Slider) event.getTargetComponent();
float oldValue = slider.getValue();
float newValue = oldValue;
// respect step size
if (slider.getStepSize() > 0f) {
newValue = newValue + slider.getStepSize() * (float) event.getYoffset();
} else {
newValue = newValue + (float) event.getYoffset();
}
// check for min/max values
if (newValue > slider.getMaxValue()) {
newValue = slider.getMaxValue();
}
if (newValue < slider.getMinValue()) {
newValue = slider.getMinValue();
}
// set value & push event
slider.setValue(newValue);
EventProcessorProvider.getInstance().pushEvent(new SliderChangeValueEvent(slider, event.getContext(), event.getFrame(), oldValue, newValue));
}
use of com.spinyowl.legui.component.Slider in project legui by SpinyOwl.
the class ExampleGui method createSecondSlider.
private Slider createSecondSlider() {
Slider slider2 = new Slider(220, 90, 20, 100, 50f);
slider2.setOrientation(Orientation.VERTICAL);
this.add(slider2);
return slider2;
}
Aggregations