Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,13 @@ public static JFXButton newToggleButton4(SVG icon) {
return button;
}

public static JFXButton newToggleButton4(SVG icon, int size) {
JFXButton button = new JFXButton();
button.getStyleClass().add("toggle-icon4");
button.setGraphic(icon.createIcon(size));
return button;
}

public static Label newSafeTruncatedLabel() {
Label label = new Label();
label.setTextOverrun(OverrunStyle.CENTER_WORD_ELLIPSIS);
Expand Down
4 changes: 1 addition & 3 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@ private static final class InstallerItemSkin extends SkinBase<InstallerItem> {
buttonsContainer.setAlignment(Pos.CENTER);
pane.getChildren().add(buttonsContainer);

JFXButton removeButton = new JFXButton();
removeButton.setGraphic(SVG.CLOSE.createIcon());
removeButton.getStyleClass().add("toggle-icon4");
JFXButton removeButton = FXUtils.newToggleButton4(SVG.CLOSE);
if (control.id.equals(MINECRAFT.getPatchId())) {
removeButton.setVisible(false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public AccountListItemSkin(AccountListItem skinnable) {
spinnerMove.setContent(btnMove);
right.getChildren().add(spinnerMove);

JFXButton btnRefresh = new JFXButton();
JFXButton btnRefresh = FXUtils.newToggleButton4(SVG.REFRESH);
SpinnerPane spinnerRefresh = new SpinnerPane();
spinnerRefresh.getStyleClass().setAll("small-spinner-pane");
if (skinnable.getAccount() instanceof MicrosoftAccount && Accounts.OAUTH_CALLBACK.getClientId().isEmpty()) {
Expand All @@ -144,13 +144,11 @@ public AccountListItemSkin(AccountListItem skinnable) {
})
.start();
});
btnRefresh.getStyleClass().add("toggle-icon4");
btnRefresh.setGraphic(SVG.REFRESH.createIcon());
FXUtils.installFastTooltip(btnRefresh, i18n("button.refresh"));
spinnerRefresh.setContent(btnRefresh);
right.getChildren().add(spinnerRefresh);

JFXButton btnUpload = new JFXButton();
JFXButton btnUpload = FXUtils.newToggleButton4(SVG.CHECKROOM);
SpinnerPane spinnerUpload = new SpinnerPane();
btnUpload.setOnAction(e -> {
Task<?> uploadTask = skinnable.uploadSkin();
Expand All @@ -161,29 +159,23 @@ public AccountListItemSkin(AccountListItem skinnable) {
.start();
}
});
btnUpload.getStyleClass().add("toggle-icon4");
btnUpload.setGraphic(SVG.CHECKROOM.createIcon());
FXUtils.installFastTooltip(btnUpload, i18n("account.skin.upload"));
btnUpload.disableProperty().bind(Bindings.not(skinnable.canUploadSkin()));
spinnerUpload.setContent(btnUpload);
spinnerUpload.getStyleClass().add("small-spinner-pane");
right.getChildren().add(spinnerUpload);

JFXButton btnCopyUUID = new JFXButton();
JFXButton btnCopyUUID = FXUtils.newToggleButton4(SVG.CONTENT_COPY);
SpinnerPane spinnerCopyUUID = new SpinnerPane();
spinnerCopyUUID.getStyleClass().add("small-spinner-pane");
btnCopyUUID.getStyleClass().add("toggle-icon4");
btnCopyUUID.setOnAction(e -> FXUtils.copyText(skinnable.getAccount().getUUID().toString()));
btnCopyUUID.setGraphic(SVG.CONTENT_COPY.createIcon());
FXUtils.installFastTooltip(btnCopyUUID, i18n("account.copy_uuid"));
spinnerCopyUUID.setContent(btnCopyUUID);
right.getChildren().add(spinnerCopyUUID);

JFXButton btnRemove = new JFXButton();
JFXButton btnRemove = FXUtils.newToggleButton4(SVG.DELETE);
btnRemove.setOnAction(e -> Controllers.confirm(i18n("button.remove.confirm"), i18n("button.remove"), skinnable::remove, null));
btnRemove.getStyleClass().add("toggle-icon4");
BorderPane.setAlignment(btnRemove, Pos.CENTER);
btnRemove.setGraphic(SVG.DELETE.createIcon());
FXUtils.installFastTooltip(btnRemove, i18n("button.delete"));
right.getChildren().add(btnRemove);
root.setRight(right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ public AccountDetailsInputPane(AccountFactory<?> factory, Runnable onAction) {
});
linksContainer.setMinWidth(USE_PREF_SIZE);

JFXButton btnAddServer = new JFXButton();
btnAddServer.setGraphic(SVG.ADD.createIcon(20));
btnAddServer.getStyleClass().add("toggle-icon4");
JFXButton btnAddServer = FXUtils.newToggleButton4(SVG.ADD, 20);
btnAddServer.setOnAction(e -> {
Controllers.dialog(new AddAuthlibInjectorServerPane());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.ui.construct;

import com.jfoenix.controls.JFXButton;
import javafx.beans.property.*;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
Expand Down Expand Up @@ -85,13 +84,11 @@ public void setRightGraphic(Node rightGraphic) {
}

public void setRightAction(SVG icon, Runnable action) {
var button = new JFXButton();
var button = FXUtils.newToggleButton4(icon, 14);
button.setOnAction(e -> {
action.run();
e.consume();
});
button.getStyleClass().add("toggle-icon4");
button.setGraphic(icon.createIcon(14));
setAlignment(button, Pos.CENTER);
setRightGraphic(button);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@ public ImagePickerItem() {
imageContainer = new ImageContainer(32);
imageContainer.setSmooth(false);

JFXButton selectButton = new JFXButton();
selectButton.setGraphic(SVG.EDIT.createIcon(20));
JFXButton selectButton = FXUtils.newToggleButton4(SVG.EDIT, 20);
selectButton.onActionProperty().bind(onSelectButtonClicked);
selectButton.getStyleClass().add("toggle-icon4");

JFXButton deleteButton = new JFXButton();
deleteButton.setGraphic(SVG.RESTORE.createIcon(20));
JFXButton deleteButton = FXUtils.newToggleButton4(SVG.RESTORE, 20);
deleteButton.onActionProperty().bind(onDeleteButtonClicked);
deleteButton.getStyleClass().add("toggle-icon4");

FXUtils.installFastTooltip(selectButton, i18n("button.edit"));
FXUtils.installFastTooltip(deleteButton, i18n("button.reset"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ private static final class JavaItemCell extends ListCell<JavaRuntime> {
HBox right = new HBox();
right.setAlignment(Pos.CENTER_RIGHT);
{
JFXButton revealButton = new JFXButton();
revealButton.setGraphic(SVG.FOLDER_OPEN.createIcon());
revealButton.getStyleClass().add("toggle-icon4");
JFXButton revealButton = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
revealButton.setOnAction(e -> {
JavaRuntime java = getItem();
if (java != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,20 @@ private static final class DisabledJavaItemSkin extends SkinBase<DisabledJavaIte
HBox right = new HBox();
right.setAlignment(Pos.CENTER_RIGHT);
{
JFXButton revealButton = new JFXButton();
revealButton.getStyleClass().add("toggle-icon4");
revealButton.setGraphic(SVG.FOLDER_OPEN.createIcon());
JFXButton revealButton = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
revealButton.setOnAction(e -> skinnable.onReveal());
FXUtils.installFastTooltip(revealButton, i18n("reveal.in_file_manager"));

if (skinnable.realPath == null) {
revealButton.setDisable(true);

JFXButton removeButton = new JFXButton();
removeButton.getStyleClass().add("toggle-icon4");
removeButton.setGraphic(SVG.DELETE.createIcon());
JFXButton removeButton = FXUtils.newToggleButton4(SVG.DELETE);
removeButton.setOnAction(e -> skinnable.onRemove());
FXUtils.installFastTooltip(removeButton, i18n("java.disabled.management.remove"));

right.getChildren().setAll(revealButton, removeButton);
} else {
JFXButton restoreButton = new JFXButton();
restoreButton.getStyleClass().add("toggle-icon4");
restoreButton.setGraphic(SVG.RESTORE.createIcon());
JFXButton restoreButton = FXUtils.newToggleButton4(SVG.RESTORE);
restoreButton.setOnAction(e -> skinnable.onRestore());
FXUtils.installFastTooltip(restoreButton, i18n("java.disabled.management.restore"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ public void changed(ObservableValue<? extends EnumBackgroundImage> observable, E
.fallbackTo(12.0)
.asPredicate(Validator.addTo(txtLogFontSize)));

JFXButton clearButton = new JFXButton();
clearButton.getStyleClass().add("toggle-icon4");
clearButton.setGraphic(SVG.RESTORE.createIcon());
JFXButton clearButton = FXUtils.newToggleButton4(SVG.RESTORE);
clearButton.setOnAction(e -> cboLogFont.setValue(null));

FXUtils.installFastTooltip(clearButton, i18n("button.reset"));
Expand Down Expand Up @@ -276,9 +274,7 @@ public void changed(ObservableValue<? extends EnumBackgroundImage> observable, E
cboFont.setValue(config().getLauncherFontFamily());
FXUtils.onChange(cboFont.valueProperty(), FontManager::setFontFamily);

JFXButton clearButton = new JFXButton();
clearButton.getStyleClass().add("toggle-icon4");
clearButton.setGraphic(SVG.RESTORE.createIcon());
JFXButton clearButton = FXUtils.newToggleButton4(SVG.RESTORE);
clearButton.setOnAction(e -> cboFont.setValue(null));

FXUtils.installFastTooltip(clearButton, i18n("button.reset"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,8 @@ public SettingsPage() {
}

{
JFXButton btnUpdate = new JFXButton();
JFXButton btnUpdate = FXUtils.newToggleButton4(SVG.UPDATE, 20);
btnUpdate.setOnAction(e -> onUpdate());
btnUpdate.getStyleClass().add("toggle-icon4");
btnUpdate.setGraphic(SVG.UPDATE.createIcon(20));
FXUtils.installFastTooltip(btnUpdate, i18n("update.tooltip"));

updateListener = any -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ public ProfileListItemSkin(ProfileListItem skinnable) {
HBox right = new HBox();
right.setAlignment(Pos.CENTER_RIGHT);

JFXButton btnRemove = new JFXButton();
JFXButton btnRemove = FXUtils.newToggleButton4(SVG.CLOSE, 14);
btnRemove.setOnAction(e -> skinnable.remove());
btnRemove.getStyleClass().add("toggle-icon4");
BorderPane.setAlignment(btnRemove, Pos.CENTER);
btnRemove.setGraphic(SVG.CLOSE.createIcon(14));
right.getChildren().add(btnRemove);
root.setRight(right);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,26 @@ public void fire() {

right.setAlignment(Pos.CENTER_RIGHT);

this.btnUpgrade = new JFXButton();
this.btnUpgrade = FXUtils.newToggleButton4(SVG.UPDATE);
btnUpgrade.setOnAction(e -> {
GameListItem item = this.getItem();
if (item != null)
item.update();
});
btnUpgrade.getStyleClass().add("toggle-icon4");
btnUpgrade.setGraphic(SVG.UPDATE.createIcon());
FXUtils.installFastTooltip(btnUpgrade, i18n("version.update"));
right.getChildren().add(btnUpgrade);

this.btnLaunch = new JFXButton();
this.btnLaunch = FXUtils.newToggleButton4(SVG.ROCKET_LAUNCH);
btnLaunch.setOnAction(e -> {
GameListItem item = this.getItem();
if (item != null)
item.testGame();
});
btnLaunch.getStyleClass().add("toggle-icon4");
BorderPane.setAlignment(btnLaunch, Pos.CENTER);
btnLaunch.setGraphic(SVG.ROCKET_LAUNCH.createIcon());
FXUtils.installFastTooltip(btnLaunch, i18n("version.launch.test"));
right.getChildren().add(btnLaunch);

this.btnManage = new JFXButton();
this.btnManage = FXUtils.newToggleButton4(SVG.MORE_VERT);
btnManage.setOnAction(e -> {
GameListItem item = this.getItem();
if (item == null)
Expand All @@ -139,9 +135,7 @@ public void fire() {
JFXPopup.PopupVPosition vPosition = determineOptimalPopupPosition(root, popup);
popup.show(root, vPosition, JFXPopup.PopupHPosition.RIGHT, 0, vPosition == JFXPopup.PopupVPosition.TOP ? root.getHeight() : -root.getHeight());
});
btnManage.getStyleClass().add("toggle-icon4");
BorderPane.setAlignment(btnManage, Pos.CENTER);
btnManage.setGraphic(SVG.MORE_VERT.createIcon());
FXUtils.installFastTooltip(btnManage, i18n("settings.game.management"));
right.getChildren().add(btnManage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ final class ModInfoListCell extends MDListCell<ModInfoObject> {
JFXCheckBox checkBox = new JFXCheckBox();
ImageContainer imageContainer = new ImageContainer(24);
TwoLineListItem content = new TwoLineListItem();
JFXButton restoreButton = new JFXButton();
JFXButton infoButton = new JFXButton();
JFXButton revealButton = new JFXButton();
JFXButton restoreButton = FXUtils.newToggleButton4(SVG.RESTORE);
JFXButton infoButton = FXUtils.newToggleButton4(SVG.INFO);
JFXButton revealButton = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
Comment thread
CiiLu marked this conversation as resolved.
Outdated
BooleanProperty booleanProperty;

Tooltip warningTooltip;
Expand All @@ -575,17 +575,8 @@ final class ModInfoListCell extends MDListCell<ModInfoObject> {

imageContainer.setImage(VersionIconType.COMMAND.getIcon());

restoreButton.getStyleClass().add("toggle-icon4");
restoreButton.setGraphic(SVG.RESTORE.createIcon());

FXUtils.installFastTooltip(restoreButton, i18n("mods.restore"));

revealButton.getStyleClass().add("toggle-icon4");
revealButton.setGraphic(SVG.FOLDER.createIcon());

infoButton.getStyleClass().add("toggle-icon4");
infoButton.setGraphic(SVG.INFO.createIcon());

container.getChildren().setAll(checkBox, imageContainer, content, restoreButton, revealButton, infoButton);

StackPane.setMargin(container, new Insets(8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ Image getIcon() {
private static final class ResourcepackListCell extends MDListCell<ResourcepackInfoObject> {
private final ImageContainer imageView = new ImageContainer(32);
private final TwoLineListItem content = new TwoLineListItem();
private final JFXButton btnReveal = new JFXButton();
private final JFXButton btnDelete = new JFXButton();
private final JFXButton btnReveal = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
private final JFXButton btnDelete = FXUtils.newToggleButton4(SVG.DELETE_FOREVER);
private final ResourcepackListPage page;

public ResourcepackListCell(JFXListView<ResourcepackInfoObject> listView, ResourcepackListPage page) {
Expand All @@ -202,12 +202,6 @@ public ResourcepackListCell(JFXListView<ResourcepackInfoObject> listView, Resour
HBox.setHgrow(content, Priority.ALWAYS);
root.setCenter(content);

btnReveal.getStyleClass().add("toggle-icon4");
btnReveal.setGraphic(SVG.FOLDER_OPEN.createIcon());

btnDelete.getStyleClass().add("toggle-icon4");
btnDelete.setGraphic(SVG.DELETE_FOREVER.createIcon());

HBox right = new HBox(8);
right.setAlignment(Pos.CENTER_RIGHT);
right.getChildren().setAll(btnReveal, btnDelete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,19 +575,15 @@ public Cell() {
this.right = new HBox(8);
right.setAlignment(Pos.CENTER_RIGHT);

JFXButton btnReveal = new JFXButton();
JFXButton btnReveal = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
FXUtils.installFastTooltip(btnReveal, i18n("reveal.in_file_manager"));
btnReveal.getStyleClass().add("toggle-icon4");
btnReveal.setGraphic(SVG.FOLDER_OPEN.createIcon());
btnReveal.setOnAction(event -> {
Item item = getItem();
if (item != null && !(item instanceof BackItem))
item.onReveal();
});

JFXButton btnDelete = new JFXButton();
btnDelete.getStyleClass().add("toggle-icon4");
btnDelete.setGraphic(SVG.DELETE_FOREVER.createIcon());
JFXButton btnDelete = FXUtils.newToggleButton4(SVG.DELETE_FOREVER);
btnDelete.setOnAction(event -> {
Item item = getItem();
if (item != null && !(item instanceof BackItem)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,14 @@ private static final class BackupInfoSkin extends SkinBase<BackupInfo> {
root.setRight(right);
right.setAlignment(Pos.CENTER_RIGHT);

JFXButton btnReveal = new JFXButton();
JFXButton btnReveal = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
right.getChildren().add(btnReveal);
FXUtils.installFastTooltip(btnReveal, i18n("reveal.in_file_manager"));
btnReveal.getStyleClass().add("toggle-icon4");
btnReveal.setGraphic(SVG.FOLDER_OPEN.createIcon());
btnReveal.setOnAction(event -> skinnable.onReveal());

JFXButton btnDelete = new JFXButton();
JFXButton btnDelete = FXUtils.newToggleButton4(SVG.DELETE);
right.getChildren().add(btnDelete);
FXUtils.installFastTooltip(btnDelete, i18n("world.backup.delete"));
btnDelete.getStyleClass().add("toggle-icon4");
btnDelete.setGraphic(SVG.DELETE.createIcon());
btnDelete.setOnAction(event -> Controllers.confirm(i18n("button.remove.confirm"), i18n("button.remove"), skinnable::onDelete, null));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ private void updateControls() {
iconImageView.setImage(world.getIcon() == null ? FXUtils.newBuiltinImage("/assets/img/unknown_server.png") : world.getIcon());
}

JFXButton editIconButton = new JFXButton();
JFXButton resetIconButton = new JFXButton();
JFXButton editIconButton = FXUtils.newToggleButton4(SVG.EDIT, 20);
JFXButton resetIconButton = FXUtils.newToggleButton4(SVG.RESTORE, 20);
{
editIconButton.setGraphic(SVG.EDIT.createIcon(20));
editIconButton.setDisable(isReadOnly);
editIconButton.setOnAction(event -> Controllers.confirm(
I18n.i18n("world.icon.change.tip"),
Expand All @@ -152,13 +151,10 @@ private void updateControls() {
null
));
FXUtils.installFastTooltip(editIconButton, i18n("button.edit"));
editIconButton.getStyleClass().add("toggle-icon4");

resetIconButton.setGraphic(SVG.RESTORE.createIcon(20));
resetIconButton.setDisable(isReadOnly);
resetIconButton.setOnAction(event -> this.clearWorldIcon());
FXUtils.installFastTooltip(resetIconButton, i18n("button.reset"));
resetIconButton.getStyleClass().add("toggle-icon4");
}

HBox hBox = new HBox(8);
Expand Down
Loading