Skip to content

Commit cae8f65

Browse files
authored
更新界面动画效果 (#4780)
1 parent 6f1f117 commit cae8f65

28 files changed

Lines changed: 1797 additions & 705 deletions

HMCL/src/main/java/com/jfoenix/controls/JFXDialog.java

Lines changed: 562 additions & 0 deletions
Large diffs are not rendered by default.

HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.jackhuang.hmcl.task.TaskExecutor;
5050
import org.jackhuang.hmcl.ui.account.AccountListPage;
5151
import org.jackhuang.hmcl.ui.animation.AnimationUtils;
52+
import org.jackhuang.hmcl.ui.animation.Motion;
5253
import org.jackhuang.hmcl.ui.construct.*;
5354
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
5455
import org.jackhuang.hmcl.ui.decorator.DecoratorController;
@@ -328,16 +329,16 @@ public static void initialize(Stage stage) {
328329
if (AnimationUtils.playWindowAnimation()) {
329330
Timeline timeline = new Timeline(
330331
new KeyFrame(Duration.millis(0),
331-
new KeyValue(decorator.getDecorator().opacityProperty(), 0, FXUtils.EASE),
332-
new KeyValue(decorator.getDecorator().scaleXProperty(), 0.8, FXUtils.EASE),
333-
new KeyValue(decorator.getDecorator().scaleYProperty(), 0.8, FXUtils.EASE),
334-
new KeyValue(decorator.getDecorator().scaleZProperty(), 0.8, FXUtils.EASE)
332+
new KeyValue(decorator.getDecorator().opacityProperty(), 0, Motion.EASE),
333+
new KeyValue(decorator.getDecorator().scaleXProperty(), 0.8, Motion.EASE),
334+
new KeyValue(decorator.getDecorator().scaleYProperty(), 0.8, Motion.EASE),
335+
new KeyValue(decorator.getDecorator().scaleZProperty(), 0.8, Motion.EASE)
335336
),
336337
new KeyFrame(Duration.millis(600),
337-
new KeyValue(decorator.getDecorator().opacityProperty(), 1, FXUtils.EASE),
338-
new KeyValue(decorator.getDecorator().scaleXProperty(), 1, FXUtils.EASE),
339-
new KeyValue(decorator.getDecorator().scaleYProperty(), 1, FXUtils.EASE),
340-
new KeyValue(decorator.getDecorator().scaleZProperty(), 1, FXUtils.EASE)
338+
new KeyValue(decorator.getDecorator().opacityProperty(), 1, Motion.EASE),
339+
new KeyValue(decorator.getDecorator().scaleXProperty(), 1, Motion.EASE),
340+
new KeyValue(decorator.getDecorator().scaleYProperty(), 1, Motion.EASE),
341+
new KeyValue(decorator.getDecorator().scaleZProperty(), 1, Motion.EASE)
341342
)
342343
);
343344
timeline.play();

HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -437,28 +437,12 @@ public static void installSlowTooltip(Node node, String tooltip) {
437437
installSlowTooltip(node, new Tooltip(tooltip));
438438
}
439439

440-
public static void playAnimation(Node node, String animationKey, Timeline timeline) {
441-
animationKey = "FXUTILS.ANIMATION." + animationKey;
442-
Object oldTimeline = node.getProperties().get(animationKey);
443-
// if (oldTimeline instanceof Timeline) ((Timeline) oldTimeline).stop();
444-
if (timeline != null) timeline.play();
445-
node.getProperties().put(animationKey, timeline);
446-
}
447-
448-
public static <T> Animation playAnimation(Node node, String animationKey, Duration duration, WritableValue<T> property, T from, T to, Interpolator interpolator) {
449-
if (from == null) from = property.getValue();
450-
if (duration == null || Objects.equals(duration, Duration.ZERO) || Objects.equals(from, to)) {
451-
playAnimation(node, animationKey, null);
452-
property.setValue(to);
453-
return null;
454-
} else {
455-
Timeline timeline = new Timeline(
456-
new KeyFrame(Duration.ZERO, new KeyValue(property, from, interpolator)),
457-
new KeyFrame(duration, new KeyValue(property, to, interpolator))
458-
);
459-
playAnimation(node, animationKey, timeline);
460-
return timeline;
461-
}
440+
public static void playAnimation(Node node, String animationKey, Animation animation) {
441+
animationKey = "hmcl.animations." + animationKey;
442+
if (node.getProperties().get(animationKey) instanceof Animation oldAnimation)
443+
oldAnimation.stop();
444+
animation.play();
445+
node.getProperties().put(animationKey, animation);
462446
}
463447

464448
public static void openFolder(Path file) {
@@ -1349,8 +1333,6 @@ public String toString() {
13491333
}
13501334
};
13511335

1352-
public static final Interpolator EASE = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
1353-
13541336
public static void onEscPressed(Node node, Runnable action) {
13551337
node.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
13561338
if (e.getCode() == KeyCode.ESCAPE) {

HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/AnimationHandler.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/AnimationProducer.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)