Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose orientation property for NumberSlider #799

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
@Description(
group = "edu.wpi.first.shuffleboard",
name = "Base",
version = "1.3.6",
version = "1.3.7",
summary = "Defines all the WPILib data types and stock widgets"
)
@SuppressWarnings("PMD.CouplingBetweenObjects")
Expand Down
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
Loading