From 7b74533353b3699efb1a5eb4a0c631cd1fcb6d7d Mon Sep 17 00:00:00 2001 From: xirren Date: Sun, 1 Mar 2026 13:05:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8F=8A=E6=97=B6=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BD=8D=E7=BD=AE=E5=B0=BA=E5=AF=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jackhuang/hmcl/ui/Controllers.java | 79 ++++++++++++++----- 1 file changed, 60 insertions(+), 19 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index 4993bb7019..bd69e688cb 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -23,6 +23,7 @@ import javafx.animation.KeyFrame; import javafx.animation.KeyValue; import javafx.animation.Timeline; +import javafx.animation.PauseTransition; import javafx.beans.InvalidationListener; import javafx.beans.WeakInvalidationListener; import javafx.beans.property.DoubleProperty; @@ -239,29 +240,42 @@ public static void initialize(Stage stage) { Controllers.stage = stage; + final Duration DEBOUNCE_DELAY = Duration.millis(600); + final PauseTransition debounceX = new PauseTransition(DEBOUNCE_DELAY); + final PauseTransition debounceY = new PauseTransition(DEBOUNCE_DELAY); + final PauseTransition debounceWidth = new PauseTransition(DEBOUNCE_DELAY); + final PauseTransition debounceHeight = new PauseTransition(DEBOUNCE_DELAY); + stageSizeChangeListener = o -> { ReadOnlyDoubleProperty sourceProperty = (ReadOnlyDoubleProperty) o; DoubleProperty targetProperty; + PauseTransition debounce; + switch (sourceProperty.getName()) { - case "x": { - targetProperty = stageX; - break; - } - case "y": { - targetProperty = stageY; - break; - } - case "width": { - targetProperty = stageWidth; - break; - } - case "height": { - targetProperty = stageHeight; - break; - } - default: { - targetProperty = null; - } + case "x": { + targetProperty = stageX; + debounce = debounceX; + break; + } + case "y": { + targetProperty = stageY; + debounce = debounceY; + break; + } + case "width": { + targetProperty = stageWidth; + debounce = debounceWidth; + break; + } + case "height": { + targetProperty = stageHeight; + debounce = debounceHeight; + break; + } + default: { + targetProperty = null; + debounce = null; + } } if (targetProperty != null @@ -272,6 +286,33 @@ public static void initialize(Stage stage) { !Controllers.stage.isFullScreen() && !Controllers.stage.isMaximized()) ) { targetProperty.set(sourceProperty.get()); + + final String name = sourceProperty.getName(); + final double value = sourceProperty.get(); + + if (debounce != null) { + debounce.setOnFinished(event -> { + switch (name) { + case "x": { + config().setX(value / SCREEN.getBounds().getWidth()); + break; + } + case "y": { + config().setY(value / SCREEN.getBounds().getHeight()); + break; + } + case "width": { + config().setWidth(value); + break; + } + case "height": { + config().setHeight(value); + break; + } + } + }); + debounce.playFromStart(); + } } }; From ac3a2fede2db96d9530378122a992f36e1340856 Mon Sep 17 00:00:00 2001 From: xirren Date: Sun, 1 Mar 2026 13:10:55 +0800 Subject: [PATCH 2/3] update --- .../org/jackhuang/hmcl/ui/Controllers.java | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index bd69e688cb..4a1ef221fe 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -252,30 +252,30 @@ public static void initialize(Stage stage) { PauseTransition debounce; switch (sourceProperty.getName()) { - case "x": { - targetProperty = stageX; - debounce = debounceX; - break; - } - case "y": { - targetProperty = stageY; - debounce = debounceY; - break; - } - case "width": { - targetProperty = stageWidth; - debounce = debounceWidth; - break; - } - case "height": { - targetProperty = stageHeight; - debounce = debounceHeight; - break; - } - default: { - targetProperty = null; - debounce = null; - } + case "x": { + targetProperty = stageX; + debounce = debounceX; + break; + } + case "y": { + targetProperty = stageY; + debounce = debounceY; + break; + } + case "width": { + targetProperty = stageWidth; + debounce = debounceWidth; + break; + } + case "height": { + targetProperty = stageHeight; + debounce = debounceHeight; + break; + } + default: { + targetProperty = null; + debounce = null; + } } if (targetProperty != null @@ -292,24 +292,24 @@ public static void initialize(Stage stage) { if (debounce != null) { debounce.setOnFinished(event -> { - switch (name) { - case "x": { - config().setX(value / SCREEN.getBounds().getWidth()); - break; - } - case "y": { - config().setY(value / SCREEN.getBounds().getHeight()); - break; - } - case "width": { - config().setWidth(value); - break; - } - case "height": { - config().setHeight(value); - break; - } - } + switch (name) { + case "x": { + config().setX(value / SCREEN.getBounds().getWidth()); + break; + } + case "y": { + config().setY(value / SCREEN.getBounds().getHeight()); + break; + } + case "width": { + config().setWidth(value); + break; + } + case "height": { + config().setHeight(value); + break; + } + } }); debounce.playFromStart(); } From 0a39b1a06c227f49a45defe2443075073480a52d Mon Sep 17 00:00:00 2001 From: xirren Date: Sun, 1 Mar 2026 18:14:06 +0800 Subject: [PATCH 3/3] update --- .../org/jackhuang/hmcl/ui/Controllers.java | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index 4a1ef221fe..ea884783d1 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -252,30 +252,30 @@ public static void initialize(Stage stage) { PauseTransition debounce; switch (sourceProperty.getName()) { - case "x": { - targetProperty = stageX; - debounce = debounceX; - break; - } - case "y": { - targetProperty = stageY; - debounce = debounceY; - break; - } - case "width": { - targetProperty = stageWidth; - debounce = debounceWidth; - break; - } - case "height": { - targetProperty = stageHeight; - debounce = debounceHeight; - break; - } - default: { - targetProperty = null; - debounce = null; - } + case "x": { + targetProperty = stageX; + debounce = debounceX; + break; + } + case "y": { + targetProperty = stageY; + debounce = debounceY; + break; + } + case "width": { + targetProperty = stageWidth; + debounce = debounceWidth; + break; + } + case "height": { + targetProperty = stageHeight; + debounce = debounceHeight; + break; + } + default: { + targetProperty = null; + debounce = null; + } } if (targetProperty != null @@ -292,24 +292,24 @@ public static void initialize(Stage stage) { if (debounce != null) { debounce.setOnFinished(event -> { - switch (name) { - case "x": { - config().setX(value / SCREEN.getBounds().getWidth()); - break; - } - case "y": { - config().setY(value / SCREEN.getBounds().getHeight()); - break; - } - case "width": { - config().setWidth(value); - break; - } - case "height": { - config().setHeight(value); - break; - } - } + switch (name) { + case "x": { + config().setX(value / SCREEN.getBounds().getWidth()); + break; + } + case "y": { + config().setY(value / SCREEN.getBounds().getHeight()); + break; + } + case "width": { + config().setWidth(value); + break; + } + case "height": { + config().setHeight(value); + break; + } + } }); debounce.playFromStart(); }