Search in sources :

Example 1 with Slider

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;
}
Also used : Slider(com.spinyowl.legui.component.Slider) Widget(com.spinyowl.legui.component.Widget) Label(com.spinyowl.legui.component.Label) Shadow(com.spinyowl.legui.style.shadow.Shadow)

Example 2 with Slider

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()));
}
Also used : Slider(com.spinyowl.legui.component.Slider) SliderChangeValueEvent(com.spinyowl.legui.component.event.slider.SliderChangeValueEvent)

Example 3 with Slider

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()));
}
Also used : Slider(com.spinyowl.legui.component.Slider) SliderChangeValueEvent(com.spinyowl.legui.component.event.slider.SliderChangeValueEvent)

Example 4 with Slider

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));
}
Also used : Slider(com.spinyowl.legui.component.Slider) SliderChangeValueEvent(com.spinyowl.legui.component.event.slider.SliderChangeValueEvent)

Example 5 with Slider

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;
}
Also used : Slider(com.spinyowl.legui.component.Slider)

Aggregations

Slider (com.spinyowl.legui.component.Slider)6 SliderChangeValueEvent (com.spinyowl.legui.component.event.slider.SliderChangeValueEvent)4 Label (com.spinyowl.legui.component.Label)2 Widget (com.spinyowl.legui.component.Widget)2 Animation (com.spinyowl.legui.animation.Animation)1 Button (com.spinyowl.legui.component.Button)1 CheckBox (com.spinyowl.legui.component.CheckBox)1 Component (com.spinyowl.legui.component.Component)1 Dialog (com.spinyowl.legui.component.Dialog)1 ImageView (com.spinyowl.legui.component.ImageView)1 Panel (com.spinyowl.legui.component.Panel)1 PasswordInput (com.spinyowl.legui.component.PasswordInput)1 ProgressBar (com.spinyowl.legui.component.ProgressBar)1 RadioButton (com.spinyowl.legui.component.RadioButton)1 RadioButtonGroup (com.spinyowl.legui.component.RadioButtonGroup)1 ScrollBar (com.spinyowl.legui.component.ScrollBar)1 ScrollablePanel (com.spinyowl.legui.component.ScrollablePanel)1 SelectBox (com.spinyowl.legui.component.SelectBox)1 SplitPanel (com.spinyowl.legui.component.SplitPanel)1 TextArea (com.spinyowl.legui.component.TextArea)1