forked from j62/ctbrec
1
0
Fork 0

Fix initialization of the range slider

This commit is contained in:
0xboobface 2020-06-30 19:40:08 +02:00
parent 90300473bc
commit 3382c7ff54
3 changed files with 27 additions and 5 deletions

View File

@ -25,7 +25,12 @@ public class RangeSliderBehavior<T extends Number> extends BehaviorBase<RangeSli
* The mouse position on track with 0.0 being beginning of track and 1.0 being the end
*/
public void lowThumbDragged(double position) {
rangeSlider.setLow(getNewPosition(position));
T newPosition = getNewPosition(position);
T high = rangeSlider.getRange().getTicks().get(rangeSlider.getHigh().intValue());
if (newPosition.doubleValue() >= high.doubleValue()) {
newPosition = rangeSlider.getRange().getTicks().get(rangeSlider.getLow().intValue());
}
rangeSlider.setLow(newPosition);
}
/**
@ -33,7 +38,12 @@ public class RangeSliderBehavior<T extends Number> extends BehaviorBase<RangeSli
* The mouse position on track with 0.0 being beginning of track and 1.0 being the end
*/
public void highThumbDragged(double position) {
rangeSlider.setHigh(getNewPosition(position));
T newPosition = getNewPosition(position);
T low = rangeSlider.getRange().getTicks().get(rangeSlider.getLow().intValue());
if (newPosition.doubleValue() <= low.doubleValue()) {
newPosition = rangeSlider.getRange().getTicks().get(rangeSlider.getHigh().intValue());
}
rangeSlider.setHigh(newPosition);
}
/**

View File

@ -359,8 +359,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
resolutionRange.prefWidthProperty().bind(directoryStructure.widthProperty());
resolutionRange.setShowTickMarks(true);
resolutionRange.setShowTickLabels(true);
resolutionRange.setLow(labels.indexOf(Config.getInstance().getSettings().minimumResolution));
resolutionRange.setHigh(labels.indexOf(Config.getInstance().getSettings().maximumResolution));
int lowValue = getRangeSliderValue(values, labels, Config.getInstance().getSettings().minimumResolution);
resolutionRange.setLow(lowValue >= 0 ? lowValue : values.get(0));
int highValue = getRangeSliderValue(values, labels, Config.getInstance().getSettings().maximumResolution);
resolutionRange.setHigh(highValue >= 0 ? highValue : values.get(values.size() - 1));
layout.add(resolutionRange, 1, row++);
GridPane.setMargin(l, new Insets(0, 0, 0, 0));
GridPane.setColumnSpan(resolutionRange, 3);
@ -546,6 +548,16 @@ public class SettingsTab extends Tab implements TabSelectionListener {
return locations;
}
private int getRangeSliderValue(List<Integer> values, List<Integer> labels, int value) {
for (int i = 0; i < labels.size(); i++) {
int label = labels.get(i).intValue();
if(label == value) {
return values.get(i);
}
}
return -1;
}
private Node createIgnoreListPanel() {
GridPane layout = createGridLayout();
Button editIgnoreList = new Button("Edit");

View File

@ -70,7 +70,7 @@ public class Settings {
public boolean livePreviews = false;
public boolean localRecording = true;
public int minimumResolution = 0;
public int maximumResolution = 8160;
public int maximumResolution = 8640;
public int maximumResolutionPlayer = 0;
public String mediaPlayer = "/usr/bin/mpv";
public String mediaPlayerParams = "";