Improve tooltip UX
This commit is contained in:
@@ -234,8 +234,20 @@ public final class FXUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installTooltip(Node node, String tooltip) {
|
public static void installFastTooltip(Node node, Tooltip tooltip) {
|
||||||
installTooltip(node, 0, 5000, 0, new Tooltip(tooltip));
|
installTooltip(node, 50, 5000, 0, tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void installFastTooltip(Node node, String tooltip) {
|
||||||
|
installFastTooltip(node, new Tooltip(tooltip));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void installSlowTooltip(Node node, Tooltip tooltip) {
|
||||||
|
installTooltip(node, 500, 5000, 0, tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void installSlowTooltip(Node node, String tooltip) {
|
||||||
|
installSlowTooltip(node, new Tooltip(tooltip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installTooltip(Node node, double openDelay, double visibleDelay, double closeDelay, Tooltip tooltip) {
|
public static void installTooltip(Node node, double openDelay, double visibleDelay, double closeDelay, Tooltip tooltip) {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public final class SettingsPage extends SettingsView implements DecoratorPage {
|
|||||||
config().commonDirectoryProperty(), config().commonDirTypeProperty()));
|
config().commonDirectoryProperty(), config().commonDirTypeProperty()));
|
||||||
|
|
||||||
// ==== Update ====
|
// ==== Update ====
|
||||||
FXUtils.installTooltip(btnUpdate, i18n("update.tooltip"));
|
FXUtils.installFastTooltip(btnUpdate, i18n("update.tooltip"));
|
||||||
updateListener = any -> {
|
updateListener = any -> {
|
||||||
btnUpdate.setVisible(UpdateChecker.isOutdated());
|
btnUpdate.setVisible(UpdateChecker.isOutdated());
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,12 @@ import com.jfoenix.concurrency.JFXUtilities;
|
|||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXRadioButton;
|
import com.jfoenix.controls.JFXRadioButton;
|
||||||
import com.jfoenix.effects.JFXDepthManager;
|
import com.jfoenix.effects.JFXDepthManager;
|
||||||
|
|
||||||
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.SkinBase;
|
import javafx.scene.control.SkinBase;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
@@ -36,6 +39,7 @@ import org.jackhuang.hmcl.ui.SVG;
|
|||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorAccount;
|
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorAccount;
|
||||||
|
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
||||||
|
|
||||||
public class AccountListItemSkin extends SkinBase<AccountListItem> {
|
public class AccountListItemSkin extends SkinBase<AccountListItem> {
|
||||||
|
|
||||||
@@ -69,7 +73,10 @@ public class AccountListItemSkin extends SkinBase<AccountListItem> {
|
|||||||
subtitle.getStyleClass().add("subtitle");
|
subtitle.getStyleClass().add("subtitle");
|
||||||
subtitle.textProperty().bind(skinnable.subtitleProperty());
|
subtitle.textProperty().bind(skinnable.subtitleProperty());
|
||||||
if (skinnable.getAccount() instanceof AuthlibInjectorAccount) {
|
if (skinnable.getAccount() instanceof AuthlibInjectorAccount) {
|
||||||
FXUtils.installTooltip(subtitle, ((AuthlibInjectorAccount) skinnable.getAccount()).getServer().toString());
|
Tooltip tooltip = new Tooltip();
|
||||||
|
AuthlibInjectorServer server = ((AuthlibInjectorAccount) skinnable.getAccount()).getServer();
|
||||||
|
tooltip.textProperty().bind(Bindings.createStringBinding(server::toString, server));
|
||||||
|
FXUtils.installSlowTooltip(subtitle, tooltip);
|
||||||
}
|
}
|
||||||
VBox item = new VBox(title, subtitle);
|
VBox item = new VBox(title, subtitle);
|
||||||
item.getStyleClass().add("two-line-list-item");
|
item.getStyleClass().add("two-line-list-item");
|
||||||
@@ -84,7 +91,7 @@ public class AccountListItemSkin extends SkinBase<AccountListItem> {
|
|||||||
btnRefresh.setOnMouseClicked(e -> skinnable.refresh());
|
btnRefresh.setOnMouseClicked(e -> skinnable.refresh());
|
||||||
btnRefresh.getStyleClass().add("toggle-icon4");
|
btnRefresh.getStyleClass().add("toggle-icon4");
|
||||||
btnRefresh.setGraphic(SVG.refresh(Theme.blackFillBinding(), -1, -1));
|
btnRefresh.setGraphic(SVG.refresh(Theme.blackFillBinding(), -1, -1));
|
||||||
JFXUtilities.runInFX(() -> FXUtils.installTooltip(btnRefresh, i18n("button.refresh")));
|
JFXUtilities.runInFX(() -> FXUtils.installFastTooltip(btnRefresh, i18n("button.refresh")));
|
||||||
right.getChildren().add(btnRefresh);
|
right.getChildren().add(btnRefresh);
|
||||||
|
|
||||||
JFXButton btnRemove = new JFXButton();
|
JFXButton btnRemove = new JFXButton();
|
||||||
@@ -92,7 +99,7 @@ public class AccountListItemSkin extends SkinBase<AccountListItem> {
|
|||||||
btnRemove.getStyleClass().add("toggle-icon4");
|
btnRemove.getStyleClass().add("toggle-icon4");
|
||||||
BorderPane.setAlignment(btnRemove, Pos.CENTER);
|
BorderPane.setAlignment(btnRemove, Pos.CENTER);
|
||||||
btnRemove.setGraphic(SVG.delete(Theme.blackFillBinding(), -1, -1));
|
btnRemove.setGraphic(SVG.delete(Theme.blackFillBinding(), -1, -1));
|
||||||
JFXUtilities.runInFX(() -> FXUtils.installTooltip(btnRemove, i18n("button.delete")));
|
JFXUtilities.runInFX(() -> FXUtils.installFastTooltip(btnRemove, i18n("button.delete")));
|
||||||
right.getChildren().add(btnRemove);
|
right.getChildren().add(btnRemove);
|
||||||
root.setRight(right);
|
root.setRight(right);
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class FileItem extends BorderPane {
|
|||||||
right.setGraphic(SVG.pencil(Theme.blackFillBinding(), 15, 15));
|
right.setGraphic(SVG.pencil(Theme.blackFillBinding(), 15, 15));
|
||||||
right.getStyleClass().add("toggle-icon4");
|
right.getStyleClass().add("toggle-icon4");
|
||||||
right.setOnMouseClicked(e -> onExplore());
|
right.setOnMouseClicked(e -> onExplore());
|
||||||
FXUtils.installTooltip(right, i18n("button.edit"));
|
FXUtils.installFastTooltip(right, i18n("button.edit"));
|
||||||
setRight(right);
|
setRight(right);
|
||||||
|
|
||||||
Tooltip tip = new Tooltip();
|
Tooltip tip = new Tooltip();
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class IconedMenuItem extends IconedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IconedMenuItem addTooltip(String tooltip) {
|
public IconedMenuItem addTooltip(String tooltip) {
|
||||||
FXUtils.installTooltip(this, tooltip);
|
FXUtils.installFastTooltip(this, tooltip);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public final class ImagePickerItem extends BorderPane {
|
|||||||
deleteButton.onMouseClickedProperty().bind(onDeleteButtonClicked);
|
deleteButton.onMouseClickedProperty().bind(onDeleteButtonClicked);
|
||||||
deleteButton.getStyleClass().add("toggle-icon4");
|
deleteButton.getStyleClass().add("toggle-icon4");
|
||||||
|
|
||||||
FXUtils.installTooltip(selectButton, i18n("button.edit"));
|
FXUtils.installFastTooltip(selectButton, i18n("button.edit"));
|
||||||
|
|
||||||
HBox hBox = new HBox();
|
HBox hBox = new HBox();
|
||||||
hBox.getChildren().setAll(imageView, selectButton, deleteButton);
|
hBox.getChildren().setAll(imageView, selectButton, deleteButton);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class DatapackListItem extends BorderPane {
|
|||||||
setCenter(modItem);
|
setCenter(modItem);
|
||||||
|
|
||||||
JFXButton btnRemove = new JFXButton();
|
JFXButton btnRemove = new JFXButton();
|
||||||
FXUtils.installTooltip(btnRemove, i18n("datapack.remove"));
|
FXUtils.installFastTooltip(btnRemove, i18n("datapack.remove"));
|
||||||
btnRemove.setOnMouseClicked(e -> deleteCallback.accept(this));
|
btnRemove.setOnMouseClicked(e -> deleteCallback.accept(this));
|
||||||
btnRemove.getStyleClass().add("toggle-icon4");
|
btnRemove.getStyleClass().add("toggle-icon4");
|
||||||
BorderPane.setAlignment(btnRemove, Pos.CENTER);
|
BorderPane.setAlignment(btnRemove, Pos.CENTER);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class GameListItemSkin extends SkinBase<GameListItem> {
|
|||||||
btnUpgrade.setOnMouseClicked(e -> skinnable.update());
|
btnUpgrade.setOnMouseClicked(e -> skinnable.update());
|
||||||
btnUpgrade.getStyleClass().add("toggle-icon4");
|
btnUpgrade.getStyleClass().add("toggle-icon4");
|
||||||
btnUpgrade.setGraphic(SVG.update(Theme.blackFillBinding(), -1, -1));
|
btnUpgrade.setGraphic(SVG.update(Theme.blackFillBinding(), -1, -1));
|
||||||
JFXUtilities.runInFX(() -> FXUtils.installTooltip(btnUpgrade, i18n("version.update")));
|
JFXUtilities.runInFX(() -> FXUtils.installFastTooltip(btnUpgrade, i18n("version.update")));
|
||||||
right.getChildren().add(btnUpgrade);
|
right.getChildren().add(btnUpgrade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public final class ModItem extends BorderPane {
|
|||||||
|
|
||||||
JFXButton btnRemove = new JFXButton();
|
JFXButton btnRemove = new JFXButton();
|
||||||
JFXUtilities.runInFX(() -> {
|
JFXUtilities.runInFX(() -> {
|
||||||
FXUtils.installTooltip(btnRemove, i18n("mods.remove"));
|
FXUtils.installFastTooltip(btnRemove, i18n("mods.remove"));
|
||||||
});
|
});
|
||||||
btnRemove.setOnMouseClicked(e -> deleteCallback.accept(this));
|
btnRemove.setOnMouseClicked(e -> deleteCallback.accept(this));
|
||||||
btnRemove.getStyleClass().add("toggle-icon4");
|
btnRemove.getStyleClass().add("toggle-icon4");
|
||||||
|
|||||||
@@ -99,13 +99,13 @@ public final class VersionPage extends StackPane implements DecoratorPage {
|
|||||||
new IconedMenuItem(null, i18n("version.manage.clean"), FXUtils.withJFXPopupClosing(() -> Versions.cleanVersion(profile, version), managementPopup)).addTooltip(i18n("version.manage.clean.tooltip"))
|
new IconedMenuItem(null, i18n("version.manage.clean"), FXUtils.withJFXPopupClosing(() -> Versions.cleanVersion(profile, version), managementPopup)).addTooltip(i18n("version.manage.clean.tooltip"))
|
||||||
);
|
);
|
||||||
|
|
||||||
FXUtils.installTooltip(btnDelete, i18n("version.manage.remove"));
|
FXUtils.installFastTooltip(btnDelete, i18n("version.manage.remove"));
|
||||||
FXUtils.installTooltip(btnBrowseMenu, i18n("settings.game.exploration"));
|
FXUtils.installFastTooltip(btnBrowseMenu, i18n("settings.game.exploration"));
|
||||||
FXUtils.installTooltip(btnManagementMenu, i18n("settings.game.management"));
|
FXUtils.installFastTooltip(btnManagementMenu, i18n("settings.game.management"));
|
||||||
FXUtils.installTooltip(btnExport, i18n("modpack.export"));
|
FXUtils.installFastTooltip(btnExport, i18n("modpack.export"));
|
||||||
|
|
||||||
btnTestGame.setGraphic(SVG.launch(Theme.whiteFillBinding(), 20, 20));
|
btnTestGame.setGraphic(SVG.launch(Theme.whiteFillBinding(), 20, 20));
|
||||||
FXUtils.installTooltip(btnTestGame, i18n("version.launch.test"));
|
FXUtils.installFastTooltip(btnTestGame, i18n("version.launch.test"));
|
||||||
|
|
||||||
setEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onNavigated);
|
setEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onNavigated);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user