mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-09 20:06:39 -04:00
Fix compilation error along with openjfx
This commit is contained in:
parent
a3dc7798e7
commit
d0dd23fa14
@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.ui.construct;
|
package org.jackhuang.hmcl.ui.construct;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXRippler;
|
import com.jfoenix.controls.JFXRippler;
|
||||||
import javafx.animation.Transition;
|
|
||||||
import javafx.beans.DefaultProperty;
|
import javafx.beans.DefaultProperty;
|
||||||
import javafx.beans.InvalidationListener;
|
import javafx.beans.InvalidationListener;
|
||||||
import javafx.beans.NamedArg;
|
import javafx.beans.NamedArg;
|
||||||
@ -64,68 +63,28 @@ public class RipplerContainer extends StackPane {
|
|||||||
mask.resize(buttonContainer.getWidth() - buttonContainer.snappedRightInset() - buttonContainer.snappedLeftInset(), buttonContainer.getHeight() - buttonContainer.snappedBottomInset() - buttonContainer.snappedTopInset());
|
mask.resize(buttonContainer.getWidth() - buttonContainer.snappedRightInset() - buttonContainer.snappedLeftInset(), buttonContainer.getHeight() - buttonContainer.snappedBottomInset() - buttonContainer.snappedTopInset());
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initListeners() {
|
|
||||||
this.ripplerPane.setOnMousePressed(event -> {
|
|
||||||
if (releaseManualRippler != null)
|
|
||||||
releaseManualRippler.run();
|
|
||||||
releaseManualRippler = null;
|
|
||||||
createRipple(event.getX(), event.getY());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private Transition clickedAnimation;
|
|
||||||
private final CornerRadii defaultRadii = new CornerRadii(3);
|
private final CornerRadii defaultRadii = new CornerRadii(3);
|
||||||
private Runnable releaseManualRippler;
|
|
||||||
|
|
||||||
public RipplerContainer(@NamedArg("container") Node container) {
|
public RipplerContainer(@NamedArg("container") Node container) {
|
||||||
setContainer(container);
|
setContainer(container);
|
||||||
|
|
||||||
getStyleClass().add(DEFAULT_STYLE_CLASS);
|
getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||||
buttonContainer.getChildren().add(buttonRippler);
|
buttonContainer.getChildren().add(buttonRippler);
|
||||||
setOnMousePressed(event -> {
|
|
||||||
if (clickedAnimation != null) {
|
|
||||||
clickedAnimation.setRate(1);
|
|
||||||
clickedAnimation.play();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setOnMouseReleased(event -> {
|
|
||||||
if (clickedAnimation != null) {
|
|
||||||
clickedAnimation.setRate(-1);
|
|
||||||
clickedAnimation.play();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
focusedProperty().addListener((a, b, newValue) -> {
|
focusedProperty().addListener((a, b, newValue) -> {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
if (!isPressed())
|
if (!isPressed())
|
||||||
buttonRippler.showOverlay();
|
buttonRippler.setOverlayVisible(true);
|
||||||
} else {
|
} else {
|
||||||
buttonRippler.hideOverlay();
|
buttonRippler.setOverlayVisible(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pressedProperty().addListener(o -> buttonRippler.hideOverlay());
|
pressedProperty().addListener(o -> buttonRippler.setOverlayVisible(false));
|
||||||
setPickOnBounds(false);
|
setPickOnBounds(false);
|
||||||
|
|
||||||
buttonContainer.setPickOnBounds(false);
|
buttonContainer.setPickOnBounds(false);
|
||||||
buttonContainer.shapeProperty().bind(shapeProperty());
|
buttonRippler.ripplerFillProperty().bind(ripplerFillProperty());
|
||||||
buttonContainer.borderProperty().bind(borderProperty());
|
|
||||||
buttonContainer.backgroundProperty().bind(Bindings.createObjectBinding(() -> {
|
|
||||||
if (getBackground() == null || isJavaDefaultBackground(getBackground()) || isJavaDefaultClickedBackground(getBackground()))
|
|
||||||
setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, defaultRadii, null)));
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new Background(new BackgroundFill(getBackground() != null ? getBackground().getFills().get(0).getFill() : Color.TRANSPARENT,
|
|
||||||
getBackground() != null ? getBackground().getFills().get(0).getRadii() : defaultRadii, Insets.EMPTY));
|
|
||||||
} catch (Exception e) {
|
|
||||||
return getBackground();
|
|
||||||
}
|
|
||||||
}, backgroundProperty()));
|
|
||||||
|
|
||||||
ripplerFillProperty().addListener((a, b, newValue) -> buttonRippler.setRipplerFill(newValue));
|
|
||||||
if (getBackground() == null || isJavaDefaultBackground(getBackground()))
|
|
||||||
setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, defaultRadii, null)));
|
|
||||||
|
|
||||||
containerProperty().addListener(o -> updateChildren());
|
containerProperty().addListener(o -> updateChildren());
|
||||||
updateChildren();
|
updateChildren();
|
||||||
@ -153,24 +112,6 @@ public class RipplerContainer extends StackPane {
|
|||||||
getChildren().get(i).setPickOnBounds(false);
|
getChildren().get(i).setPickOnBounds(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isJavaDefaultBackground(Background background) {
|
|
||||||
try {
|
|
||||||
String firstFill = background.getFills().get(0).getFill().toString();
|
|
||||||
return "0xffffffba".equals(firstFill) || "0xffffffbf".equals(firstFill) || "0xffffffbd".equals(firstFill);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isJavaDefaultClickedBackground(Background background) {
|
|
||||||
try {
|
|
||||||
String firstFill = background.getFills().get(0).getFill().toString();
|
|
||||||
return "0x039ed3ff".equals(firstFill);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node getContainer() {
|
public Node getContainer() {
|
||||||
return container.get();
|
return container.get();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user