fix: incorrect position of title when drag in a modpack file.

This commit is contained in:
huanghongxun 2021-10-17 03:24:05 +08:00
parent 821020e7b6
commit dcfe724803
4 changed files with 38 additions and 27 deletions

View File

@ -179,6 +179,8 @@ task proguard(type: proguard.gradle.ProGuardTask) {
dontwarn 'com.nqzero.**'
dontwarn 'org.slf4j.**'
dontwarn 'org.jackhuang.hmcl.util.Pack200Utils'
dontwarn 'com.sun.javafx.**'
dontwarn 'com.jfoenix.**'
adaptclassstrings
@ -188,15 +190,35 @@ task proguard(type: proguard.gradle.ProGuardTask) {
keepattributes 'SourceFile,LineNumberTable'
var javaHome = System.getProperty('java.home')
// Automatically handle the Java version of this build.
// if (System.getProperty('java.version').startsWith('1.')) {
// // Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
libraryjars "${System.getProperty('java.home')}/lib/ext/jfxrt.jar"
// } else {
// // As of Java 9, the runtime classes are packaged in modular jmod files.
// libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
// }
if (System.getProperty('java.version').startsWith('1.')) {
// Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars "${javaHome}/lib/rt.jar"
libraryjars "${javaHome}/lib/ext/jfxrt.jar"
} else {
System.out.println(configurations.compileClasspath.collect())
// As of Java 9, the runtime classes are packaged in modular jmod files.
libraryjars "${javaHome}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/java.desktop.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/java.logging.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/java.management.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/java.sql.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/java.xml.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/jdk.management.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/jdk.unsupported.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
if (new File("${javaHome}/jmods/javafx.base.jmod").exists()) {
libraryjars "${javaHome}/jmods/javafx.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/javafx.controls.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/javafx.graphics.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/javafx.media.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/javafx.fxml.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${javaHome}/jmods/javafx.web.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
}
}
}
def createExecutable(String suffix, String header) {

View File

@ -333,7 +333,7 @@ public final class FXUtils {
public static void playAnimation(Node node, String animationKey, Timeline timeline) {
animationKey = "FXUTILS.ANIMATION." + animationKey;
Object oldTimeline = node.getProperties().get(animationKey);
if (oldTimeline instanceof Timeline) ((Timeline) oldTimeline).stop();
// if (oldTimeline instanceof Timeline) ((Timeline) oldTimeline).stop();
if (timeline != null) timeline.play();
node.getProperties().put(animationKey, timeline);
}

View File

@ -63,6 +63,12 @@ public class TransitionPane extends StackPane implements AnimationHandler {
updateContent(newView);
if (previousNode == EMPTY_PANE) {
setMouseTransparent(false);
getChildren().setAll(newView);
return;
}
transition.init(this);
// runLater or "init" will not work

View File

@ -37,7 +37,6 @@ import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Duration;
import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.SVG;
@ -56,7 +55,6 @@ public class DecoratorSkin extends SkinBase<Decorator> {
private final StackPane titleContainer;
private final Stage primaryStage;
private final TransitionPane navBarPane;
private final StackPane leftPane;
private double xOffset, yOffset, newX, newY, initX, initY;
private boolean titleBarTransparent = true;
@ -109,15 +107,6 @@ public class DecoratorSkin extends SkinBase<Decorator> {
StackPane container = new StackPane();
FXUtils.setOverflowHidden(container);
// animation layer at bottom
HBox drawerPane = new HBox();
{
leftPane = new StackPane();
leftPane.setPrefWidth(0);
leftPane.getStyleClass().add("jfx-decorator-drawer");
drawerPane.getChildren().setAll(leftPane);
}
// content layer at middle
{
StackPane contentPlaceHolder = new StackPane();
@ -159,16 +148,12 @@ public class DecoratorSkin extends SkinBase<Decorator> {
container.setBackground(null);
titleContainer.getStyleClass().remove("background");
titleContainer.getStyleClass().add("gray-background");
container.getChildren().remove(drawerPane);
wrapper.getChildren().add(0, drawerPane);
} else {
container.backgroundProperty().bind(skinnable.contentBackgroundProperty());
wrapper.backgroundProperty().unbind();
wrapper.setBackground(null);
titleContainer.getStyleClass().add("background");
titleContainer.getStyleClass().remove("gray-background");
wrapper.getChildren().remove(drawerPane);
container.getChildren().add(0, drawerPane);
}
});
@ -180,6 +165,7 @@ public class DecoratorSkin extends SkinBase<Decorator> {
Rectangle buttonsContainerPlaceHolder = new Rectangle();
{
navBarPane = new TransitionPane();
navBarPane.setId("decoratorTitleTransitionPane");
FXUtils.onChangeAndOperate(skinnable.stateProperty(), s -> {
if (s == null) return;
Node node = createNavBar(skinnable, s.getLeftPaneWidth(), s.isBackable(), skinnable.canCloseProperty().get(), skinnable.showCloseAsHomeProperty().get(), s.isRefreshable(), s.getTitle(), s.getTitleNode());
@ -197,9 +183,6 @@ public class DecoratorSkin extends SkinBase<Decorator> {
} else {
navBarPane.getChildren().setAll(node);
}
FXUtils.playAnimation(leftPane, "animation",
s.isAnimate() ? Duration.millis(160) : null, leftPane.prefWidthProperty(), null, s.getLeftPaneWidth(), FXUtils.SINE);
});
titleBar.setCenter(navBarPane);
titleBar.setRight(buttonsContainerPlaceHolder);