Skip to content

Commit

Permalink
Expose orientation property for NumberSlider (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
isubsmith authored Sep 19, 2024
1 parent 10c3f60 commit cb7048a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import java.util.List;

import org.fxmisc.easybind.EasyBind;
import javafx.beans.property.Property;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;

import javafx.fxml.FXML;
import javafx.scene.control.Slider;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.geometry.Orientation;

@Description(
name = "Number Slider",
Expand All @@ -33,6 +36,8 @@ public class NumberSliderWidget extends SimpleAnnotatedWidget<Number> {
private Label text;

private final BooleanProperty showText = new SimpleBooleanProperty(this, "showText", true);
private final Property<Orientation> orientation =
new SimpleObjectProperty<>(this, "orientation", Orientation.HORIZONTAL);

@FXML
private void initialize() {
Expand All @@ -43,6 +48,7 @@ private void initialize() {
.divide(4));
slider.valueProperty().bindBidirectional(dataProperty());
text.textProperty().bind(EasyBind.map(dataOrDefault, n -> String.format("%.2f", n.doubleValue())));
slider.orientationProperty().bind(orientation);
}

@Override
Expand All @@ -59,7 +65,8 @@ public List<Group> getSettings() {
Setting.of("Block increment", slider.blockIncrementProperty(), Double.class)
),
Group.of("Visuals",
Setting.of("Display value", showText, Boolean.class)
Setting.of("Display value", showText, Boolean.class),
Setting.of("Orientation", orientation, Orientation.class)
)
);
}
Expand Down

0 comments on commit cb7048a

Please sign in to comment.