Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新 JFoenix #3415

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update
  • Loading branch information
Glavo committed Nov 1, 2024
commit d82282f5a103f55e3e3931177b0e9e2e5e64cab2
129 changes: 69 additions & 60 deletions HMCL/src/main/java/com/jfoenix/controls/JFXDialogLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,75 +19,98 @@

package com.jfoenix.controls;

import com.jfoenix.assets.JFoenixResources;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;

import java.util.List;

/**
* Default dialog layout according to material design guidelines.
*
* @author Shadi Shaheen
* @version 1.0
* @since 2016-03-09
*/
public class JFXDialogLayout extends VBox {
// Old
public class JFXDialogLayout extends StackPane {
private final StackPane heading = new StackPane();
private final StackPane body = new StackPane();
private final FlowPane actions = new FlowPane();
private final FlowPane actions = new FlowPane() {
protected double computeMinWidth(double height) {
if (this.getContentBias() == Orientation.HORIZONTAL) {
double maxPref = 0.0;
List<Node> children = this.getChildren();
int i = 0;

for (int size = children.size(); i < size; ++i) {
Node child = children.get(i);
if (child.isManaged()) {
maxPref = Math.max(maxPref, child.minWidth(-1.0));
}
}

Insets insets = this.getInsets();
return insets.getLeft() + this.snapSize(maxPref) + insets.getRight();
} else {
return this.computePrefWidth(height);
}
}

protected double computeMinHeight(double width) {
if (this.getContentBias() == Orientation.VERTICAL) {
double maxPref = 0.0;
List<Node> children = this.getChildren();
int i = 0;

for (int size = children.size(); i < size; ++i) {
Node child = children.get(i);
if (child.isManaged()) {
maxPref = Math.max(maxPref, child.minHeight(-1.0));
}
}

Insets insets = this.getInsets();
return insets.getTop() + this.snapSize(maxPref) + insets.getBottom();
} else {
return this.computePrefHeight(width);
}
}
};
private static final String DEFAULT_STYLE_CLASS = "jfx-dialog-layout";

/**
* creates empty dialog layout
*/
public JFXDialogLayout() {
initialize();
heading.getStyleClass().addAll("jfx-layout-heading", "title");
body.getStyleClass().add("jfx-layout-body");
VBox.setVgrow(body, Priority.ALWAYS);
actions.getStyleClass().add("jfx-layout-actions");
getChildren().setAll(heading, body, actions);
this.initialize();
VBox layout = new VBox();
layout.getChildren().add(this.heading);
this.heading.getStyleClass().add("jfx-layout-heading");
this.heading.getStyleClass().add("title");
layout.getChildren().add(this.body);
this.body.getStyleClass().add("jfx-layout-body");
this.body.prefHeightProperty().bind(this.prefHeightProperty());
this.body.prefWidthProperty().bind(this.prefWidthProperty());
layout.getChildren().add(this.actions);
this.actions.getStyleClass().add("jfx-layout-actions");
this.getChildren().add(layout);
}

/***************************************************************************
* *
* Setters / Getters *
* *
**************************************************************************/

public ObservableList<Node> getHeading() {
return heading.getChildren();
return this.heading.getChildren();
}

/**
* set header node
*/
public void setHeading(Node... titleContent) {
this.heading.getChildren().setAll(titleContent);
}

public ObservableList<Node> getBody() {
return body.getChildren();
return this.body.getChildren();
}

/**
* set body node
*/
public void setBody(Node... body) {
this.body.getChildren().setAll(body);
}

public ObservableList<Node> getActions() {
return actions.getChildren();
return this.actions.getChildren();
}

/**
* set actions of the dialog (Accept, Cancel,...)
*/
public void setActions(Node... actions) {
this.actions.getChildren().setAll(actions);
}
Expand All @@ -96,28 +119,14 @@ public void setActions(List<? extends Node> actions) {
this.actions.getChildren().setAll(actions);
}

/***************************************************************************
* *
* Stylesheet Handling *
* *
**************************************************************************/
/**
* Initialize the style class to 'jfx-dialog-layout'.
* <p>
* This is the selector class from which CSS can be used to style
* this control.
*/
private static final String DEFAULT_STYLE_CLASS = "jfx-dialog-layout";

/**
* {@inheritDoc}
*/
@Override
public String getUserAgentStylesheet() {
return JFoenixResources.load("css/controls/jfx-dialog-layout.css").toExternalForm();
}

private void initialize() {
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
this.getStyleClass().add("jfx-dialog-layout");
this.setPadding(new Insets(24.0, 24.0, 16.0, 24.0));
this.setStyle("-fx-text-fill: rgba(0, 0, 0, 0.87);");
this.heading.setStyle("-fx-font-weight: BOLD;-fx-alignment: center-left;");
this.heading.setPadding(new Insets(5.0, 0.0, 5.0, 0.0));
this.body.setStyle("-fx-pref-width: 400px;-fx-wrap-text: true;");
this.actions.setStyle("-fx-alignment: center-right ;");
this.actions.setPadding(new Insets(10.0, 0.0, 0.0, 0.0));
}
}
18 changes: 9 additions & 9 deletions HMCL/src/main/resources/assets/css/root.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
}

.title-label {
-fx-font-size: 16.0px;
-fx-padding: 14.0px;
-fx-font-size: 16px;
-fx-padding: 14px;
-fx-text-fill: rgba(0.0, 0.0, 0.0, 0.87);
}

Expand Down Expand Up @@ -421,16 +421,16 @@
.dialog-trigger {
-fx-background-color: WHITE;
-jfx-button-type: RAISED;
-fx-font-size: 14.0px;
-fx-font-size: 14px;
}

.jfx-dialog-layout {
-fx-padding: 24.0px 24.0px 16.0px 24.0px;
-fx-padding: 24px 24px 16px 24px;
-fx-text-fill: rgba(0.0, 0.0, 0.0, 0.87);
}

.jfx-layout-heading {
-fx-font-size: 20.0px;
-fx-font-size: 20px;
-fx-alignment: center-left;
-fx-padding: 5.0 0.0 5.0 0.0;
}
Expand All @@ -442,7 +442,7 @@

.jfx-layout-actions {
-fx-pref-width: 400;
-fx-padding: 10.0px 0.0 0.0 0.0;
-fx-padding: 10px 0.0 0.0 0.0;
-fx-alignment: center-right;
}

Expand Down Expand Up @@ -476,7 +476,7 @@
}

.popup-list-view {
-fx-pref-width: 150.0px;
-fx-pref-width: 150px;
}

.jfx-snackbar-content {
Expand Down Expand Up @@ -634,7 +634,7 @@
}

.jfx-radio-button .radio {
-fx-stroke-width: 2.0px;
-fx-stroke-width: 2px;
-fx-fill: transparent;
}

Expand Down Expand Up @@ -974,7 +974,7 @@
}

.toggle-label {
-fx-font-size: 14.0px;
-fx-font-size: 14px;
}

.toggle-icon1 .icon {
Expand Down

This file was deleted.