mirror of
https://github.com/octopusYan/alist-gui.git
synced 2025-12-11 02:21:56 +08:00
feat: 主题颜色
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package cn.octopusyan.alistgui.manager;
|
||||
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -13,6 +14,16 @@ public class WindowsUtil {
|
||||
public static final Map<Pane, Double> paneXOffset = new HashMap<>();
|
||||
public static final Map<Pane, Double> paneYOffset = new HashMap<>();
|
||||
|
||||
public static void bindShadow(Pane pane) {
|
||||
pane.setStyle("""
|
||||
-fx-background-radius: 5;
|
||||
-fx-border-radius: 5;
|
||||
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 15, 0, 0, 0);
|
||||
-fx-background-insets: 20;
|
||||
-fx-padding: 20;
|
||||
""");
|
||||
}
|
||||
|
||||
public static void bindDragged(Pane pane) {
|
||||
Window stage = getStage(pane);
|
||||
pane.setOnMousePressed(event -> {
|
||||
@ -25,7 +36,7 @@ public class WindowsUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public static Window getStage(Pane pane) {
|
||||
return pane.getScene().getWindow();
|
||||
public static Stage getStage(Pane pane) {
|
||||
return (Stage) pane.getScene().getWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.octopusyan.alistgui.util.alert;
|
||||
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.manager.WindowsUtil;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
@ -8,6 +9,8 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.Window;
|
||||
|
||||
/**
|
||||
@ -24,17 +27,22 @@ public class ProgressBuilder extends BaseBuilder<ProgressBuilder, Dialog<Void>>
|
||||
public ProgressBuilder(Dialog<Void> dialog, Window mOwner) {
|
||||
super(dialog, mOwner);
|
||||
|
||||
DialogPane dialogPane = dialog.getDialogPane();
|
||||
dialogPane.getScene().setFill(Color.TRANSPARENT);
|
||||
WindowsUtil.bindDragged(dialogPane);
|
||||
WindowsUtil.bindShadow(dialogPane);
|
||||
WindowsUtil.getStage(dialogPane).initStyle(StageStyle.TRANSPARENT);
|
||||
var content = getContent();
|
||||
|
||||
DialogPane pane = dialog.getDialogPane();
|
||||
pane.setContent(content);
|
||||
pane.getButtonTypes().add(new ButtonType(
|
||||
dialogPane.setContent(content);
|
||||
dialogPane.getButtonTypes().add(new ButtonType(
|
||||
Context.getLanguageBinding("label.cancel").get(),
|
||||
ButtonType.CANCEL.getButtonData()
|
||||
));
|
||||
for (Node child : pane.getChildren()) {
|
||||
if (child instanceof ButtonBar bar) {
|
||||
pane.getChildren().remove(child);
|
||||
|
||||
for (Node child : dialogPane.getChildren()) {
|
||||
if (child instanceof ButtonBar) {
|
||||
dialogPane.getChildren().remove(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user