Skip to content

优化 Tooltip#5815

Open
CiiLu wants to merge 3 commits intoHMCL-dev:mainfrom
CiiLu:tt
Open

优化 Tooltip#5815
CiiLu wants to merge 3 commits intoHMCL-dev:mainfrom
CiiLu:tt

Conversation

@CiiLu
Copy link
Contributor

@CiiLu CiiLu commented Mar 21, 2026

resolves #4909

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses #4909 by moving HMCL’s tooltip behavior/styling away from JavaFX’s built-in Tooltip (which can change font metrics when the OS theme flips in “follow system” mode) to a custom tooltip implementation with explicit CSS styling.

Changes:

  • Introduces JFXTooltip (Popup-based) and updates FXUtils.install*Tooltip helpers to use it.
  • Migrates multiple UI pages/cells from javafx.scene.control.Tooltip to JFXTooltip (including uninstall logic updates).
  • Updates root.css tooltip styling to target .jfx-tooltip and tweaks one sidebar tooltip to use the “slow” delay.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
HMCL/src/main/resources/assets/css/root.css Replaces .tooltip styling with .jfx-tooltip and adds explicit tooltip sizing/visuals.
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListPage.java Switches cell tooltip from JavaFX Tooltip to JFXTooltip.
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/SchematicsPage.java Migrates tooltip usage to JFXTooltip and updates uninstall behavior.
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java Uses JFXTooltip for warning tooltips and updates uninstall calls.
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/RootPage.java Changes one tooltip install call from fast to slow delay.
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java Migrates launch-button tooltip logic to JFXTooltip.
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java Migrates remove-button tooltip to JFXTooltip and cleans imports.
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/JFXTooltip.java Adds the new tooltip implementation (Popup + fade transitions + delays).
HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListPage.java Migrates item tooltip to JFXTooltip.
HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java Migrates subtitle tooltip to JFXTooltip.
HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountAdvancedListItem.java Migrates item tooltip field to JFXTooltip.
HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java Reworks tooltip helper APIs to install/uninstall JFXTooltip instead of JavaFX Tooltip.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1856 to +1861
.jfx-tooltip {
-fx-text-fill: -monet-inverse-on-surface;
-fx-background-color: -monet-inverse-surface;
-fx-background-insets: 0;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.5) , 10, 0.0 , 0 , 3 );
-fx-font-size: 12px;
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root.css no longer styles the standard JavaFX .tooltip selector (it was replaced by .jfx-tooltip). However, the codebase still creates/installs JavaFX Tooltip in the embedded JFoenix classes (e.g. com/jfoenix/controls/JFXListCell, com/jfoenix/skins/JFXColorPalette, com/jfoenix/skins/JFXTabPaneSkin). Those tooltips will fall back to the default JavaFX styling and may regress appearance/behavior compared to before. Consider keeping the old .tooltip rules (or applying the same rules to both .tooltip and .jfx-tooltip).

Copilot uses AI. Check for mistakes.
Comment on lines +107 to +112
public void install(Node targetNode) {
if (attachedNode != null) {
uninstall();
}
this.attachedNode = targetNode;

Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install(Node) always calls uninstall() whenever attachedNode != null, even if the tooltip is being (re)installed onto the same node. In list cell updateItem paths (e.g. where FXUtils.installSlowTooltip(left, tooltip) is called repeatedly), this causes unnecessary handler churn and transition resets. Consider making install idempotent for the same targetNode (early-return if attachedNode == targetNode) and/or avoid re-registering handlers unless the target node actually changes.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 在主题模式为「跟随系统设置」时,更改系统的亮暗色后,一些 tooltip 的字号会出现变化

2 participants