forked from j62/ctbrec
Adjust mouse scroll speed to height of the scrollpane content
This commit is contained in:
parent
13eef32ffb
commit
e96bdc1c7e
|
@ -0,0 +1,31 @@
|
||||||
|
package ctbrec.ui.controls;
|
||||||
|
|
||||||
|
import javafx.scene.control.ScrollPane;
|
||||||
|
import javafx.scene.control.skin.ScrollPaneSkin;
|
||||||
|
import javafx.scene.input.ScrollEvent;
|
||||||
|
|
||||||
|
public class FasterVerticalScrollPaneSkin extends ScrollPaneSkin {
|
||||||
|
|
||||||
|
public FasterVerticalScrollPaneSkin(final ScrollPane scrollPane) {
|
||||||
|
super(scrollPane);
|
||||||
|
|
||||||
|
getSkinnable().addEventFilter(ScrollEvent.SCROLL, event -> {
|
||||||
|
double ratio = scrollPane.getViewportBounds().getHeight() / scrollPane.getContent().getBoundsInLocal().getHeight();
|
||||||
|
double baseUnitIncrement = 0.15;
|
||||||
|
double unitIncrement = baseUnitIncrement * ratio * 1.25;
|
||||||
|
getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
||||||
|
|
||||||
|
if (event.getDeltaX() < 0) {
|
||||||
|
getHorizontalScrollBar().increment();
|
||||||
|
} else if (event.getDeltaX() > 0) {
|
||||||
|
getHorizontalScrollBar().decrement();
|
||||||
|
}
|
||||||
|
if (event.getDeltaY() < 0) {
|
||||||
|
getVerticalScrollBar().increment();
|
||||||
|
} else if (event.getDeltaY() > 0) {
|
||||||
|
getVerticalScrollBar().decrement();
|
||||||
|
}
|
||||||
|
event.consume();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,7 @@ import ctbrec.ui.action.OpenRecordingsDir;
|
||||||
import ctbrec.ui.controls.SearchBox;
|
import ctbrec.ui.controls.SearchBox;
|
||||||
import ctbrec.ui.controls.SearchPopover;
|
import ctbrec.ui.controls.SearchPopover;
|
||||||
import ctbrec.ui.controls.SearchPopoverTreeList;
|
import ctbrec.ui.controls.SearchPopoverTreeList;
|
||||||
|
import ctbrec.ui.controls.FasterVerticalScrollPaneSkin;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
import javafx.animation.Interpolator;
|
import javafx.animation.Interpolator;
|
||||||
import javafx.animation.ParallelTransition;
|
import javafx.animation.ParallelTransition;
|
||||||
|
@ -196,6 +197,8 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
scrollPane.setContent(grid);
|
scrollPane.setContent(grid);
|
||||||
scrollPane.setFitToHeight(true);
|
scrollPane.setFitToHeight(true);
|
||||||
scrollPane.setFitToWidth(true);
|
scrollPane.setFitToWidth(true);
|
||||||
|
FasterVerticalScrollPaneSkin scrollPaneSkin = new FasterVerticalScrollPaneSkin(scrollPane);
|
||||||
|
scrollPane.setSkin(scrollPaneSkin);
|
||||||
BorderPane.setMargin(scrollPane, new Insets(5));
|
BorderPane.setMargin(scrollPane, new Insets(5));
|
||||||
|
|
||||||
pagination = new HBox(5);
|
pagination = new HBox(5);
|
||||||
|
|
Loading…
Reference in New Issue