Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/Decorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.css.PseudoClass;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Rectangle2D;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
Expand All @@ -36,6 +38,7 @@
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;
Expand All @@ -46,6 +49,8 @@
import org.jackhuang.hmcl.util.platform.OperatingSystem;

public class Decorator extends Control {
private static final PseudoClass MAXIMIZED = PseudoClass.getPseudoClass("maximized");
private static final PseudoClass FULLSCREEN = PseudoClass.getPseudoClass("fullscreen");
private final ListProperty<Node> drawer = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ListProperty<Node> content = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ListProperty<Node> container = new SimpleListProperty<>(FXCollections.observableArrayList());
Expand Down Expand Up @@ -78,6 +83,19 @@ public Decorator(Stage primaryStage) {

primaryStage.initStyle(StageStyle.UNDECORATED);

primaryStage.maximizedProperty().addListener((obs, oldVal, newVal) -> {
pseudoClassStateChanged(MAXIMIZED, newVal);
if (newVal) {
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
primaryStage.setX(visualBounds.getMinX());
primaryStage.setY(visualBounds.getMinY());
primaryStage.setWidth(visualBounds.getWidth());
primaryStage.setHeight(visualBounds.getHeight());
}
});

primaryStage.fullScreenProperty().addListener((obs, oldVal, newVal) -> pseudoClassStateChanged(FULLSCREEN, newVal));

if (AnimationUtils.playWindowAnimation()) {
FXUtils.onChange(primaryStage.iconifiedProperty(), iconified -> {
if (playRestoreMinimizeAnimation && !iconified) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.SkinBase;
import javafx.scene.effect.BlurType;
import javafx.scene.effect.DropShadow;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
Expand Down Expand Up @@ -82,7 +80,6 @@ public DecoratorSkin(Decorator control) {

StackPane shadowContainer = new StackPane();
shadowContainer.getStyleClass().add("body");
shadowContainer.setEffect(new DropShadow(BlurType.ONE_PASS_BOX, Color.rgb(0, 0, 0, 0.4), 10, 0.3, 0.0, 0.0));

parent = new StackPane();
Rectangle clip = new Rectangle();
Expand Down
23 changes: 17 additions & 6 deletions HMCL/src/main/resources/assets/css/root.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

.root {
.root .window {
-fx-background-color: transparent;
-fx-padding: 8;
}

.root:maximized .window,
.root:fullscreen .window {
-fx-padding: 0;
}

.root .window > .body {
-fx-effect: dropshadow(one-pass-box, rgba(0,0,0,0.4), 10, 0.3, 0, 0);
}

.root:maximized .window > .body,
.root:fullscreen .window > .body{
-fx-effect: null;
}

.svg {
Expand Down Expand Up @@ -1667,11 +1683,6 @@
-fx-font-size: 14;
}

.window {
-fx-background-color: transparent;
-fx-padding: 8;
}

.debug-border {
-fx-border-color: red;
-fx-border-width: 1;
Expand Down