Skip to content
Open
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
4 changes: 2 additions & 2 deletions HMCL/src/main/java/com/jfoenix/controls/JFXComboBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public JFXComboBox(ObservableList<T> items) {

private void initialize() {
getStyleClass().add(DEFAULT_STYLE_CLASS);
this.setCellFactory(listView -> new JFXListCell<T>() {
this.setCellFactory(listView -> new JFXListCell<>() {
@Override
public void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
Expand All @@ -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<T>() {
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
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/java/com/jfoenix/controls/JFXListCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions HMCL/src/main/java/com/jfoenix/controls/JFXRippler.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ protected void releaseRipple() {
rippler.releaseRipple();
}

public void releaseRippleImmediately() {
rippler.releaseRippleImmediately();
}

/**
* creates Ripple effect in the center of the control
*
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ public T fromString(String string) {
}

public static <T> Callback<ListView<T>, ListCell<T>> jfxListCellFactory(Function<T, Node> graphicBuilder) {
return view -> new JFXListCell<T>() {
return view -> new JFXListCell<>() {
@Override
public void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public FontComboBox() {

styleProperty().bind(Bindings.concat("-fx-font-family: \"", valueProperty(), "\""));

setCellFactory(listView -> new JFXListCell<String>() {
setCellFactory(listView -> new JFXListCell<>() {
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public abstract class MDListCell<T> extends ListCell<T> {

private final StackPane container = new StackPane();
private final StackPane root = new StackPane();
private final RipplerContainer ripplerContainer = new RipplerContainer(container);

public MDListCell(JFXListView<T> listView) {

setText(null);
setGraphic(null);

root.getStyleClass().add("md-list-cell");
RipplerContainer ripplerContainer = new RipplerContainer(container);
root.getChildren().setAll(ripplerContainer);

Region clippedContainer = (Region) listView.lookup(".clipped-container");
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public void setRipplerFill(Paint ripplerFill) {
ripplerFillProperty().set(ripplerFill);
}

public void releaseRippleImmediately() {
buttonRippler.releaseRippleImmediately();
}

@Override
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
return getClassCssMetaData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ private static class RemoteVersionListCell extends ListCell<RemoteVersion> {
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;
Expand Down Expand Up @@ -188,7 +189,7 @@ private static class RemoteVersionListCell extends ListCell<RemoteVersion> {

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);
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

public final class GameListCell extends ListCell<GameListItem> {

private final Region graphic;
private final RipplerContainer graphic;

private final ImageContainer imageView;
private final TwoLineListItem content;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public ObservableList<GameItem> getItems() {
private static final class Cell extends ListCell<GameItem> {

private final Region graphic;
private final RipplerContainer ripplerContainer;

private final ImageContainer imageView;
private final TwoLineListItem content;
Expand Down Expand Up @@ -128,7 +129,7 @@ public Cell(ListView<GameItem> 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");
Expand All @@ -149,6 +150,7 @@ public Cell(ListView<GameItem> listView) {

@Override
protected void updateItem(GameItem item, boolean empty) {
this.ripplerContainer.releaseRippleImmediately();
super.updateItem(item, empty);

this.imageView.imageProperty().unbind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ public Cell() {

@Override
protected void updateItem(Item item, boolean empty) {
graphics.releaseRippleImmediately();
super.updateItem(item, empty);

iconImageView.setImage(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected ListCell<JavaRuntime> createListCell(JFXListView<JavaRuntime> listView
}

private static final class JavaItemCell extends ListCell<JavaRuntime> {
private final Node graphic;
private final RipplerContainer graphic;
private final Label label = new Label();
private final TwoLineListItem content;

Expand Down Expand Up @@ -298,6 +298,8 @@ private static final class JavaItemCell extends ListCell<JavaRuntime> {
@Override
protected void updateItem(JavaRuntime item, boolean empty) {
JavaRuntime oldItem = getItem();

this.graphic.releaseRippleImmediately();
super.updateItem(item, empty);
if (empty || item == null) {
setGraphic(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ private static final class ThemePackItemCell extends ListCell<ThemePackManager.@
private final ThemePackManagementPage page;

/// Root graphic reused by this cell.
private final Region graphic;
private final RipplerContainer graphic;

/// The text content shown for the current theme pack.
private final TwoLineListItem content = new TwoLineListItem();
Expand Down Expand Up @@ -715,6 +715,7 @@ private ThemePackItemCell(ThemePackManagementPage page) {
protected void updateItem(ThemePackManager.@Nullable InstalledThemePack themePack, boolean empty) {
var currentItem = getItem();

this.graphic.releaseRippleImmediately();
super.updateItem(themePack, empty);

if (Objects.equals(getItem(), currentItem)) return;
Expand Down