diff --git a/HMCL/src/main/java/com/jfoenix/controls/JFXComboBox.java b/HMCL/src/main/java/com/jfoenix/controls/JFXComboBox.java index 8c9b634cfb3..59006dd62ca 100644 --- a/HMCL/src/main/java/com/jfoenix/controls/JFXComboBox.java +++ b/HMCL/src/main/java/com/jfoenix/controls/JFXComboBox.java @@ -70,7 +70,7 @@ public JFXComboBox(ObservableList items) { private void initialize() { getStyleClass().add(DEFAULT_STYLE_CLASS); - this.setCellFactory(listView -> new JFXListCell() { + this.setCellFactory(listView -> new JFXListCell<>() { @Override public void updateItem(T item, boolean empty) { super.updateItem(item, empty); @@ -80,7 +80,7 @@ public void updateItem(T item, boolean empty) { // had to refactor the code out of the skin class to allow // customization of the button cell - this.setButtonCell(new ListCell() { + this.setButtonCell(new ListCell<>() { { // fixed clearing the combo box value is causing // java prompt text to be shown because the button cell is not updated diff --git a/HMCL/src/main/java/com/jfoenix/controls/JFXListCell.java b/HMCL/src/main/java/com/jfoenix/controls/JFXListCell.java index 13b1eadaecf..25883328eb6 100644 --- a/HMCL/src/main/java/com/jfoenix/controls/JFXListCell.java +++ b/HMCL/src/main/java/com/jfoenix/controls/JFXListCell.java @@ -199,6 +199,7 @@ protected void makeChildrenTransparent() { */ @Override protected void updateItem(T item, boolean empty) { + cellRippler.releaseRippleImmediately(); super.updateItem(item, empty); if (empty) { setText(null); diff --git a/HMCL/src/main/java/com/jfoenix/controls/JFXRippler.java b/HMCL/src/main/java/com/jfoenix/controls/JFXRippler.java index 61d2d8f7bd0..e534277b4a6 100644 --- a/HMCL/src/main/java/com/jfoenix/controls/JFXRippler.java +++ b/HMCL/src/main/java/com/jfoenix/controls/JFXRippler.java @@ -278,6 +278,10 @@ protected void releaseRipple() { rippler.releaseRipple(); } + public void releaseRippleImmediately() { + rippler.releaseRippleImmediately(); + } + /** * creates Ripple effect in the center of the control * @@ -405,6 +409,22 @@ private void releaseRipple() { } } + private void releaseRippleImmediately() { + Ripple ripple = ripplesQueue.poll(); + if (ripple != null) { + getChildren().remove(ripple); + if (generating.getAndSet(false)) { + if (overlayRect != null) { + overlayRect.inAnimation.stop(); + if (!forceOverlay) { + overlayRect.outAnimation.stop(); + overlayRect.setOpacity(0D); + } + } + } + } + } + void cacheRippleClip(boolean cached) { cacheRipplerClip = cached; } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java index d006a67656a..1a5f7ae5573 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java @@ -1391,7 +1391,7 @@ public T fromString(String string) { } public static Callback, ListCell> jfxListCellFactory(Function graphicBuilder) { - return view -> new JFXListCell() { + return view -> new JFXListCell<>() { @Override public void updateItem(T item, boolean empty) { super.updateItem(item, empty); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FontComboBox.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FontComboBox.java index 64ffda3317e..75cd2e449fc 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FontComboBox.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FontComboBox.java @@ -39,7 +39,7 @@ public FontComboBox() { styleProperty().bind(Bindings.concat("-fx-font-family: \"", valueProperty(), "\"")); - setCellFactory(listView -> new JFXListCell() { + setCellFactory(listView -> new JFXListCell<>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MDListCell.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MDListCell.java index bf62346f034..ba236c974e2 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MDListCell.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MDListCell.java @@ -30,6 +30,7 @@ public abstract class MDListCell extends ListCell { private final StackPane container = new StackPane(); private final StackPane root = new StackPane(); + private final RipplerContainer ripplerContainer = new RipplerContainer(container); public MDListCell(JFXListView listView) { @@ -37,7 +38,6 @@ public MDListCell(JFXListView listView) { setGraphic(null); root.getStyleClass().add("md-list-cell"); - RipplerContainer ripplerContainer = new RipplerContainer(container); root.getChildren().setAll(ripplerContainer); Region clippedContainer = (Region) listView.lookup(".clipped-container"); @@ -56,12 +56,13 @@ protected void updateItem(T item, boolean empty) { T oldItem = getItem(); boolean oldEmpty = isEmpty(); + ripplerContainer.releaseRippleImmediately(); super.updateItem(item, empty); if (oldItem == item && oldEmpty == empty) return; updateControl(item, empty); - if (empty) { + if (empty || item == null) { setGraphic(null); } else { setGraphic(root); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/RipplerContainer.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/RipplerContainer.java index 4c6fae21bee..063a236423c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/RipplerContainer.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/RipplerContainer.java @@ -205,6 +205,10 @@ public void setRipplerFill(Paint ripplerFill) { ripplerFillProperty().set(ripplerFill); } + public void releaseRippleImmediately() { + buttonRippler.releaseRippleImmediately(); + } + @Override public List> getCssMetaData() { return getClassCssMetaData(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java index 09a062e73ae..69a79bb7fc9 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java @@ -158,6 +158,7 @@ private static class RemoteVersionListCell extends ListCell { private final TwoLineListItem twoLineListItem = new TwoLineListItem(); private final ImageView imageView = new ImageView(); private final StackPane pane = new StackPane(); + private final RipplerContainer ripplerContainer; RemoteVersionListCell(VersionsPage control) { this.control = control; @@ -188,7 +189,7 @@ private static class RemoteVersionListCell extends ListCell { pane.getStyleClass().add("md-list-cell"); StackPane.setMargin(hbox, new Insets(10, 16, 10, 16)); - pane.getChildren().setAll(new RipplerContainer(hbox)); + pane.getChildren().setAll(ripplerContainer = new RipplerContainer(hbox)); FXUtils.onClicked(this, this::onAction); } @@ -214,6 +215,7 @@ private void onOpenWiki() { public void updateItem(RemoteVersion remoteVersion, boolean empty) { RemoteVersion oldRemoteVersion = getItem(); + ripplerContainer.releaseRippleImmediately(); super.updateItem(remoteVersion, empty); if (empty) { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/DownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/DownloadListPage.java index f39535a4c38..f9ad6b1a11f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/DownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/DownloadListPage.java @@ -581,6 +581,7 @@ protected ModDownloadListPageSkin(DownloadListPage control) { @Override protected void updateItem(RemoteAddon item, boolean empty) { + this.graphic.releaseRippleImmediately(); super.updateItem(item, empty); if (empty || item == null) { setGraphic(null); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListCell.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListCell.java index 7a7d9ecc5d6..54b881667a0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListCell.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListCell.java @@ -40,7 +40,7 @@ public final class GameListCell extends ListCell { - private final Region graphic; + private final RipplerContainer graphic; private final ImageContainer imageView; private final TwoLineListItem content; @@ -162,6 +162,7 @@ public void fire() { @Override public void updateItem(GameListItem item, boolean empty) { + this.graphic.releaseRippleImmediately(); super.updateItem(item, empty); this.imageView.imageProperty().unbind(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListPopupMenu.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListPopupMenu.java index b95dd77da72..81c54b96477 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListPopupMenu.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameListPopupMenu.java @@ -100,6 +100,7 @@ public ObservableList getItems() { private static final class Cell extends ListCell { private final Region graphic; + private final RipplerContainer ripplerContainer; private final ImageContainer imageView; private final TwoLineListItem content; @@ -128,7 +129,7 @@ public Cell(ListView listView) { container.setLeft(imageView); container.setCenter(content); - RipplerContainer ripplerContainer = new RipplerContainer(container); + this.ripplerContainer = new RipplerContainer(container); StackPane rootPane = new StackPane(); rootPane.getStyleClass().add("advanced-list-item"); @@ -149,6 +150,7 @@ public Cell(ListView listView) { @Override protected void updateItem(GameItem item, boolean empty) { + this.ripplerContainer.releaseRippleImmediately(); super.updateItem(item, empty); this.imageView.imageProperty().unbind(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/SchematicsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/SchematicsPage.java index b7e21447c37..3f6eb22328e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/SchematicsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/SchematicsPage.java @@ -598,6 +598,7 @@ public Cell() { @Override protected void updateItem(Item item, boolean empty) { + graphics.releaseRippleImmediately(); super.updateItem(item, empty); iconImageView.setImage(null); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/WorldListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/WorldListPage.java index fe02c80c66c..aa5134042e4 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/WorldListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/WorldListPage.java @@ -326,6 +326,7 @@ protected void updateItem(World world, boolean empty) { World oldWorld = getItem(); boolean oldEmpty = isEmpty(); + this.graphic.releaseRippleImmediately(); super.updateItem(world, empty); if (oldWorld == world && oldEmpty == empty) return; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java index b3eeb858956..c615ad82010 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java @@ -227,7 +227,7 @@ protected ListCell createListCell(JFXListView listView } private static final class JavaItemCell extends ListCell { - private final Node graphic; + private final RipplerContainer graphic; private final Label label = new Label(); private final TwoLineListItem content; @@ -298,6 +298,8 @@ private static final class JavaItemCell extends ListCell { @Override protected void updateItem(JavaRuntime item, boolean empty) { JavaRuntime oldItem = getItem(); + + this.graphic.releaseRippleImmediately(); super.updateItem(item, empty); if (empty || item == null) { setGraphic(null); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/ThemePackManagementPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/ThemePackManagementPage.java index c9354736704..3be7b6c6dc6 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/ThemePackManagementPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/ThemePackManagementPage.java @@ -632,7 +632,7 @@ private static final class ThemePackItemCell extends ListCell