alt: some UI details

This commit is contained in:
huanghongxun 2020-03-30 16:15:27 +08:00
parent 511b555255
commit f38d3b0026
6 changed files with 23 additions and 6 deletions

View File

@ -80,12 +80,15 @@ public class Theme {
}
public String[] getStylesheets() {
Color textFill = getForegroundColor();
String css;
try {
File temp = File.createTempFile("hmcl", ".css");
FileUtils.writeText(temp, IOUtils.readFullyAsString(ResourceNotFoundError.getResourceAsStream("/assets/css/custom.css"))
.replace("%base-color%", color)
.replace("%base-rippler-color%", String.format("rgba(%d, %d, %d, 0.3)", (int)Math.ceil(paint.getRed() * 256), (int)Math.ceil(paint.getGreen() * 256), (int)Math.ceil(paint.getBlue() * 256)))
.replace("%disabled-font-color%", String.format("rgba(%d, %d, %d, 0.7)", (int)Math.ceil(textFill.getRed() * 256), (int)Math.ceil(textFill.getGreen() * 256), (int)Math.ceil(textFill.getBlue() * 256)))
.replace("%font-color%", getColorDisplayName(getForegroundColor())));
css = temp.toURI().toString();
} catch (IOException | NullPointerException e) {

View File

@ -47,6 +47,7 @@ class DatapackListPageSkin extends SkinBase<DatapackListPage> {
super(skinnable);
BorderPane root = new BorderPane();
root.getStyleClass().add("content-background");
JFXListView<DatapackInfoObject> listView = new JFXListView<>();
{

View File

@ -17,6 +17,7 @@
*/
package org.jackhuang.hmcl.ui.versions;
import javafx.scene.control.Tooltip;
import org.jackhuang.hmcl.setting.Profiles;
import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.ui.FXUtils;
@ -27,18 +28,24 @@ import static org.jackhuang.hmcl.ui.FXUtils.newImage;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
public class GameAdvancedListItem extends AdvancedListItem {
private final Tooltip tooltip;
public GameAdvancedListItem() {
tooltip = new Tooltip();
FXUtils.installFastTooltip(this, tooltip);
FXUtils.onChangeAndOperate(Profiles.selectedVersionProperty(), version -> {
if (version != null && Profiles.getSelectedProfile() != null &&
Profiles.getSelectedProfile().getRepository().hasVersion(version)) {
setTitle(version);
setSubtitle(null);
setImage(Profiles.getSelectedProfile().getRepository().getVersionIconImage(version));
tooltip.setText(version);
} else {
setTitle(i18n("version.empty"));
setSubtitle(i18n("version.empty.add"));
setImage(newImage("/assets/img/grass.png"));
tooltip.setText("");
}
});

View File

@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui.versions;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPopup;
import com.jfoenix.effects.JFXDepthManager;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.SkinBase;
import javafx.scene.image.ImageView;
@ -56,6 +57,8 @@ public class WorldListItemSkin extends SkinBase<WorldListItem> {
imageViewContainer.getChildren().setAll(imageView);
TwoLineListItem item = new TwoLineListItem();
item.titleProperty().bind(skinnable.titleProperty());
item.subtitleProperty().bind(skinnable.subtitleProperty());
BorderPane.setAlignment(item, Pos.CENTER);
center.getChildren().setAll(imageView, item);
root.setCenter(center);
@ -81,10 +84,9 @@ public class WorldListItemSkin extends SkinBase<WorldListItem> {
right.getChildren().add(btnManage);
root.setRight(right);
root.setStyle("-fx-background-color: white; -fx-padding: 8 8 8 0;");
root.getStyleClass().add("card");
root.setPadding(new Insets(8, 8, 8, 0));
JFXDepthManager.setDepth(root, 1);
item.titleProperty().bind(skinnable.titleProperty());
item.subtitleProperty().bind(skinnable.subtitleProperty());
getChildren().setAll(root);
}

View File

@ -20,5 +20,6 @@
-fx-base-darker-color: derive(-fx-base-color, -10%);
-fx-base-check-color: derive(-fx-base-color, 30%);
-fx-base-rippler-color: %base-rippler-color%;
-fx-base-disabled-text-fill: %disabled-font-color%;
-fx-base-text-fill: %font-color%;
}

View File

@ -181,7 +181,6 @@
}
.tab-label {
-fx-font-family: "Roboto";
-fx-font-size: 16;
}
@ -1058,11 +1057,15 @@
-fx-font-size: 14;
}
.jfx-decorator-tab .tab-label {
-fx-text-fill: -fx-base-text-fill;
.jfx-decorator-tab .tab-container .tab-label {
-fx-text-fill: -fx-base-disabled-text-fill;
-fx-font-size: 14;
}
.jfx-decorator-tab .tab-container:selected .tab-label {
-fx-text-fill: -fx-base-text-fill;
}
.resize-border {
-fx-border-color: -fx-base-color;
-fx-border-width: 0 2 2 2;