mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
add fine adjustment control for fee rate slider using mouse scroll
This commit is contained in:
parent
8baa8e2e96
commit
c407a41475
1 changed files with 12 additions and 0 deletions
|
@ -13,6 +13,8 @@ import java.util.stream.Collectors;
|
||||||
import static com.sparrowwallet.sparrow.AppServices.*;
|
import static com.sparrowwallet.sparrow.AppServices.*;
|
||||||
|
|
||||||
public class FeeRangeSlider extends Slider {
|
public class FeeRangeSlider extends Slider {
|
||||||
|
private static final double FEE_RATE_SCROLL_INCREMENT = 0.01;
|
||||||
|
|
||||||
public FeeRangeSlider() {
|
public FeeRangeSlider() {
|
||||||
super(0, FEE_RATES_RANGE.size() - 1, 0);
|
super(0, FEE_RATES_RANGE.size() - 1, 0);
|
||||||
setMajorTickUnit(1);
|
setMajorTickUnit(1);
|
||||||
|
@ -45,6 +47,16 @@ public class FeeRangeSlider extends Slider {
|
||||||
updateMaxFeeRange(newValue.doubleValue());
|
updateMaxFeeRange(newValue.doubleValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setOnScroll(event -> {
|
||||||
|
double newFeeRate = getFeeRate() + (event.getDeltaY() > 0 ? FEE_RATE_SCROLL_INCREMENT : -FEE_RATE_SCROLL_INCREMENT);
|
||||||
|
if(newFeeRate < LONG_FEE_RATES_RANGE.get(0)) {
|
||||||
|
newFeeRate = LONG_FEE_RATES_RANGE.get(0);
|
||||||
|
} else if(newFeeRate > LONG_FEE_RATES_RANGE.get(LONG_FEE_RATES_RANGE.size() - 1)) {
|
||||||
|
newFeeRate = LONG_FEE_RATES_RANGE.get(LONG_FEE_RATES_RANGE.size() - 1);
|
||||||
|
}
|
||||||
|
setFeeRate(newFeeRate);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getFeeRate() {
|
public double getFeeRate() {
|
||||||
|
|
Loading…
Reference in a new issue