优化 TransitionPane (#3680)
* update * update * update * update * update * update * update * update * update * Fix checkstyle
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui.animation;
|
package org.jackhuang.hmcl.ui.animation;
|
||||||
|
|
||||||
import javafx.animation.KeyFrame;
|
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
@@ -66,26 +65,25 @@ public class TransitionPane extends StackPane implements AnimationHandler {
|
|||||||
updateContent(newView);
|
updateContent(newView);
|
||||||
|
|
||||||
if (previousNode == EMPTY_PANE) {
|
if (previousNode == EMPTY_PANE) {
|
||||||
setMouseTransparent(false);
|
|
||||||
getChildren().setAll(newView);
|
getChildren().setAll(newView);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnimationUtils.isAnimationEnabled()) {
|
if (AnimationUtils.isAnimationEnabled() && transition != ContainerAnimations.NONE) {
|
||||||
|
setMouseTransparent(true);
|
||||||
transition.init(this);
|
transition.init(this);
|
||||||
|
|
||||||
// runLater or "init" will not work
|
// runLater or "init" will not work
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
Timeline newAnimation = new Timeline();
|
Timeline newAnimation = new Timeline();
|
||||||
newAnimation.getKeyFrames().addAll(transition.animate(this));
|
newAnimation.getKeyFrames().setAll(transition.animate(this));
|
||||||
newAnimation.getKeyFrames().add(new KeyFrame(duration, e -> {
|
newAnimation.setOnFinished(e -> {
|
||||||
setMouseTransparent(false);
|
setMouseTransparent(false);
|
||||||
getChildren().remove(previousNode);
|
getChildren().remove(previousNode);
|
||||||
}));
|
});
|
||||||
FXUtils.playAnimation(this, "transition_pane", newAnimation);
|
FXUtils.playAnimation(this, "transition_pane", newAnimation);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setMouseTransparent(false);
|
|
||||||
getChildren().remove(previousNode);
|
getChildren().remove(previousNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,8 +99,6 @@ public class TransitionPane extends StackPane implements AnimationHandler {
|
|||||||
if (previousNode == newView)
|
if (previousNode == newView)
|
||||||
previousNode = EMPTY_PANE;
|
previousNode = EMPTY_PANE;
|
||||||
|
|
||||||
setMouseTransparent(true);
|
|
||||||
|
|
||||||
currentNode = newView;
|
currentNode = newView;
|
||||||
|
|
||||||
getChildren().setAll(previousNode, currentNode);
|
getChildren().setAll(previousNode, currentNode);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DecoratorAnimationProducer implements AnimationProducer {
|
public final class DecoratorAnimationProducer implements AnimationProducer {
|
||||||
@Override
|
@Override
|
||||||
public void init(AnimationHandler handler) {
|
public void init(AnimationHandler handler) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ public class LauncherSettingsPage extends DecoratorAnimatedPage implements Decor
|
|||||||
tab = new TabHeader(gameTab, javaManagementTab, settingsTab, personalizationTab, downloadTab, helpTab, feedbackTab, aboutTab);
|
tab = new TabHeader(gameTab, javaManagementTab, settingsTab, personalizationTab, downloadTab, helpTab, feedbackTab, aboutTab);
|
||||||
|
|
||||||
tab.select(gameTab);
|
tab.select(gameTab);
|
||||||
gameTab.initializeIfNeeded();
|
|
||||||
gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null);
|
gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null);
|
||||||
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
transitionPane.setContent(gameTab.getNode(), ContainerAnimations.NONE);
|
||||||
|
FXUtils.onChange(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
||||||
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE);
|
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
|
|||||||
|
|
||||||
private String preferredVersionName = null;
|
private String preferredVersionName = null;
|
||||||
|
|
||||||
{
|
public VersionPage() {
|
||||||
versionSettingsTab.setNodeSupplier(loadVersionFor(() -> new VersionSettingsPage(false)));
|
versionSettingsTab.setNodeSupplier(loadVersionFor(() -> new VersionSettingsPage(false)));
|
||||||
installerListTab.setNodeSupplier(loadVersionFor(InstallerListPage::new));
|
installerListTab.setNodeSupplier(loadVersionFor(InstallerListPage::new));
|
||||||
modListTab.setNodeSupplier(loadVersionFor(ModListPage::new));
|
modListTab.setNodeSupplier(loadVersionFor(ModListPage::new));
|
||||||
@@ -77,7 +77,8 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
|
|||||||
addEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onNavigated);
|
addEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onNavigated);
|
||||||
|
|
||||||
tab.select(versionSettingsTab);
|
tab.select(versionSettingsTab);
|
||||||
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
transitionPane.setContent(versionSettingsTab.getNode(), ContainerAnimations.NONE);
|
||||||
|
FXUtils.onChange(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
||||||
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE);
|
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user