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

Increase mouse-wheel vertical scrolling speed in ScrollPane #6424

Merged
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
72 changes: 72 additions & 0 deletions desktop/src/main/java/bisq/desktop/components/BisqScrollPane.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.components;

import bisq.common.util.Utilities;

import javafx.scene.Node;
import javafx.scene.control.ScrollPane;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;

/**
* Custom scroll pane that uses a workaround to fix slow vertical scrolling.
*/
public class BisqScrollPane extends ScrollPane {

private final double BASE_DELTA_Y_MULTIPLIER = 0.8;
private double deltaYMultiplier = BASE_DELTA_Y_MULTIPLIER;

public BisqScrollPane() {
super();
if (Utilities.isLinux() || Utilities.isWindows()) {
if (getContent() == null) {
contentProperty().addListener(new ChangeListener<>() {
@Override
public void changed(ObservableValue<? extends Node> o, Node oldVal, Node newVal) {
contentProperty().removeListener(this);
changeScrollingSpeed();
}
});
} else {
changeScrollingSpeed();
}
}
}

private void changeScrollingSpeed() {
getContent().setOnScroll(scrollEvent -> {
double deltaY = scrollEvent.getDeltaY() * deltaYMultiplier;
double fullHeight = getContent().getBoundsInLocal().getHeight();
double visibleHeight = getBoundsInLocal().getHeight();
double heightDiff = fullHeight - visibleHeight;
double diff = heightDiff > 1 ? heightDiff : 1;
setVvalue(getVvalue() - deltaY / diff);
});
}

/**
* Sets the vertical scroll amount's multiplier. Any value below BASE_DELTA_Y_MULTIPLIER
* will decrease the scrolling speed whereas any value above will accelerate it.
* @param deltaYMultiplier the value by which deltaY will be multiplied
*/
public void setDeltaYMultiplier(double deltaYMultiplier) {
this.deltaYMultiplier = deltaYMultiplier;
}
}
36 changes: 18 additions & 18 deletions desktop/src/main/java/bisq/desktop/main/account/AccountView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,41 @@
-->

<?import com.jfoenix.controls.JFXTabPane?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.layout.AnchorPane?>
<?import bisq.desktop.components.BisqScrollPane?>
<JFXTabPane fx:id="root" fx:controller="bisq.desktop.main.account.AccountView"
prefHeight="630.0" prefWidth="1000.0"
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml">
<Tab fx:id="fiatAccountsTab" closable="false">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</Tab>
<Tab fx:id="altcoinAccountsTab" closable="false">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</Tab>
<Tab fx:id="notificationTab" closable="false">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</Tab>
<Tab fx:id="passwordTab" closable="false"/>
<Tab fx:id="seedWordsTab" closable="false">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</Tab>
<Tab fx:id="walletInfoTab" closable="false">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</Tab>
<Tab fx:id="backupTab" closable="false"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import bisq.desktop.components.BisqScrollPane?>
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.BondingView"
xmlns:fx="http://javafx.com/fxml">

<VBox fx:id="leftVBox" prefWidth="240" spacing="5" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="15"
AnchorPane.topAnchor="15"/>

<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane fx:id="content" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</ScrollPane>
</BisqScrollPane>

</AnchorPane>

Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import bisq.desktop.components.BisqScrollPane?>
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.burnbsq.BurnBsqView"
xmlns:fx="http://javafx.com/fxml">

<VBox fx:id="leftVBox" prefWidth="240" spacing="5" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="15"
AnchorPane.topAnchor="15"/>

<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane fx:id="content" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</ScrollPane>
</BisqScrollPane>

</AnchorPane>

Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->


<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import bisq.desktop.components.BisqScrollPane?>
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.economy.EconomyView"
xmlns:fx="http://javafx.com/fxml">

<VBox fx:id="leftVBox" prefWidth="240" spacing="5" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="15"
AnchorPane.topAnchor="15"/>

<ScrollPane fitToWidth="true" fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<BisqScrollPane fitToWidth="true" fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane fx:id="content"/>
</ScrollPane>
</BisqScrollPane>

</AnchorPane>
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import bisq.desktop.components.BisqScrollPane?>
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.governance.GovernanceView"
xmlns:fx="http://javafx.com/fxml">

<VBox fx:id="leftVBox" prefWidth="240" spacing="5" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="15"
AnchorPane.topAnchor="15"/>

<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane fx:id="content" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</ScrollPane>
</BisqScrollPane>

</AnchorPane>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package bisq.desktop.main.dao.governance;

import bisq.desktop.Navigation;
import bisq.desktop.components.BisqScrollPane;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.TitledGroupBg;
Expand Down Expand Up @@ -69,7 +70,6 @@

import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.control.TextInputControl;
import javafx.scene.layout.AnchorPane;
Expand Down Expand Up @@ -670,8 +670,8 @@ public int incrementAndGetGridRow() {
}

@SuppressWarnings("Duplicates")
public ScrollPane getView() {
ScrollPane scrollPane = new ScrollPane();
public BisqScrollPane getView() {
BisqScrollPane scrollPane = new BisqScrollPane();
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import bisq.desktop.components.BisqScrollPane?>
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.monitor.MonitorView"
xmlns:fx="http://javafx.com/fxml">

<VBox fx:id="leftVBox" prefWidth="240" spacing="5" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="15"
AnchorPane.topAnchor="15"/>

<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane fx:id="content" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</ScrollPane>
</BisqScrollPane>

</AnchorPane>
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->


<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import bisq.desktop.components.BisqScrollPane?>
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.wallet.BsqWalletView"
xmlns:fx="http://javafx.com/fxml">

<VBox fx:id="leftVBox" prefWidth="240" spacing="5" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="15"
AnchorPane.topAnchor="15"/>

<ScrollPane fitToWidth="true" fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<BisqScrollPane fitToWidth="true" fitToHeight="true"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane fx:id="content"/>
</ScrollPane>
</BisqScrollPane>

</AnchorPane>
14 changes: 7 additions & 7 deletions desktop/src/main/java/bisq/desktop/main/market/MarketView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@
-->

<?import com.jfoenix.controls.JFXTabPane?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.layout.AnchorPane?>
<?import bisq.desktop.components.BisqScrollPane?>
<JFXTabPane fx:id="root" fx:controller="bisq.desktop.main.market.MarketView"
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml">

<Tab fx:id="offerBookTab" closable="false">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</Tab>
<Tab fx:id="spreadTab" closable="false"/>
<Tab fx:id="spreadTabPaymentMethod" closable="false"/>
<Tab fx:id="tradesTab" closable="false">
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<BisqScrollPane fitToWidth="true" hbarPolicy="NEVER"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</Tab>
</JFXTabPane>
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,7 @@ protected void removeSubscriptions() {
///////////////////////////////////////////////////////////////////////////////////////////

private void addScrollPane() {
scrollPane = new ScrollPane();
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);
AnchorPane.setLeftAnchor(scrollPane, 0d);
AnchorPane.setTopAnchor(scrollPane, 0d);
AnchorPane.setRightAnchor(scrollPane, 0d);
AnchorPane.setBottomAnchor(scrollPane, 0d);
scrollPane = GUIUtil.createScrollPane();
root.getChildren().add(scrollPane);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package bisq.desktop.main.overlays.windows;

import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.BisqScrollPane;
import bisq.desktop.components.InputTextField;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup;
Expand Down Expand Up @@ -97,7 +98,7 @@ public void show() {

createGridPane();

scrollPane = new ScrollPane();
scrollPane = new BisqScrollPane();
scrollPane.setContent(gridPane);
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);
Expand Down
Loading