Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds rounded corners to image icons throughout the application by introducing a new JFXImageView component that extends JavaFX's ImageView with automatic rounded corner clipping. The change enhances the visual consistency and modern appearance of the UI, particularly in areas like the mod download pages, world lists, resource pack displays, and game version selections.
Changes:
- Created new
JFXImageViewclass with 6px rounded corners applied via clip region - Replaced
ImageViewwithJFXImageViewin 13 UI files across world management, mod management, resource packs, datapacks, schematics, and download pages - Consolidated imports to use wildcard imports for
org.jackhuang.hmcl.ui.construct.*package in several files
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| JFXImageView.java | New component extending ImageView with rounded corner clipping |
| ImagePickerItem.java | Updated image picker to use rounded corner image view |
| WorldListPage.java | Applied rounded corners to world icons in list view |
| WorldInfoPage.java | Applied rounded corners to world info page icon |
| WorldBackupsPage.java | Applied rounded corners to world backup icons |
| SchematicsPage.java | Applied rounded corners to schematic preview icons |
| ResourcepackListPage.java | Applied rounded corners to resource pack icons |
| ModListPageSkin.java | Applied rounded corners to mod icons in lists and dialogs |
| GameListPopupMenu.java | Applied rounded corners to game icons in popup menu |
| GameListCell.java | Applied rounded corners to game version icons in main list |
| DownloadPage.java | Applied rounded corners to mod icons on download detail pages |
| DownloadListPage.java | Applied rounded corners to mod icons in download search results |
| DatapackListPageSkin.java | Applied rounded corners to datapack icons |
| VersionsPage.java | Consolidated imports (but didn't update ImageView usage) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public JFXImageView(String url) { | ||
| super(url); | ||
| init(); | ||
| } |
There was a problem hiding this comment.
JFXImageView is missing a constructor that accepts an Image parameter. The standard JavaFX ImageView class has a constructor ImageView(Image image), which is used in several places in the codebase (e.g., HTMLRenderer.java:191, InstallerItem.java:298, LineComponent.java:216, VersionIconDialog.java:106, MainPage.java:106). If these locations need rounded corners in the future, they won't be able to use JFXImageView without first refactoring to set the image after construction.
Consider adding a constructor: public JFXImageView(Image image) { super(image); init(); }
| private final VersionsPage control; | ||
|
|
||
| private final TwoLineListItem twoLineListItem = new TwoLineListItem(); | ||
| private final ImageView imageView = new ImageView(); |
There was a problem hiding this comment.
This ImageView displays version icons (like game versions, Forge, Fabric, etc.) and should probably also use JFXImageView for consistency with other icon displays in the application that were updated in this PR. The PR title indicates adding rounded corners to "most" icons, and this appears to be one that was missed.
To fix this, change line 156 to: private final ImageView imageView = new JFXImageView();
| clip.setArcWidth(radius); | ||
| clip.setArcHeight(radius); |
There was a problem hiding this comment.
The arc width and arc height should be set to twice the radius value for proper rounded corners with the desired radius. In JavaFX, arcWidth and arcHeight define the full width and height of the ellipse used to round the corners, not the radius.
Change the implementation to: clip.setArcWidth(radius * 2); clip.setArcHeight(radius * 2);
| clip.setArcWidth(radius); | |
| clip.setArcHeight(radius); | |
| clip.setArcWidth(radius * 2); | |
| clip.setArcHeight(radius * 2); |
| clip.widthProperty().bind(this.fitWidthProperty()); | ||
| clip.heightProperty().bind(this.fitHeightProperty()); |
There was a problem hiding this comment.
The clip's width and height properties are bound to fitWidthProperty and fitHeightProperty. However, ImageView can have fitWidth and fitHeight set to -1 (which means "use the actual image size"). When FXUtils.limitSize() is called on images that are smaller than the max size, it sets fitWidth and fitHeight to -1. This will cause the clip Rectangle to have negative dimensions, which may result in the image not being displayed correctly or causing rendering issues.
You need to handle the case where fitWidth or fitHeight is -1. Consider binding to the actual bounds of the ImageView instead, or using a ChangeListener to update the clip dimensions based on whether fit dimensions are set or the actual image size should be used.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| clip.setArcWidth(radius); | ||
| clip.setArcHeight(radius); |
There was a problem hiding this comment.
The naming of the "cornerRadius" property is misleading. In JavaFX's Rectangle, setArcWidth and setArcHeight set the full diameter of the arc used for rounded corners, not the radius. The property should be renamed to "cornerArcSize" or "cornerDiameter", or alternatively, the implementation should multiply the radius value by 2 when setting the arc width/height. Currently, a cornerRadius value of 6.0 creates a corner with an arc diameter of 6 pixels (radius 3 pixels), not a radius of 6 pixels.
| clip.setArcWidth(radius); | |
| clip.setArcHeight(radius); | |
| // JavaFX Rectangle#setArcWidth/Height expect the full diameter of the arc. | |
| // Interpret the cornerRadius value as a true radius by doubling it here. | |
| double diameter = radius * 2; | |
| clip.setArcWidth(diameter); | |
| clip.setArcHeight(diameter); |
| @@ -128,8 +126,4 @@ public ObjectProperty<Image> imageProperty() { | |||
| public void setImage(Image image) { | |||
| this.image.set(image); | |||
| } | |||
There was a problem hiding this comment.
The public method getImageView() has been removed from ImagePickerItem. This is a breaking change for any external code or plugins that may have been using this method. While this improves encapsulation by not exposing internal implementation details, consider adding a deprecation notice in a previous release for smooth migration. The image functionality can still be accessed via imageProperty(), getImage(), and setImage() methods.
| } | |
| } | |
| /** | |
| * Returns the underlying image view/control. | |
| * | |
| * @deprecated This method exposes internal implementation details and will be removed | |
| * in a future release. Use {@link #imageProperty()}, {@link #getImage()}, | |
| * or {@link #setImage(Image)} instead. | |
| */ | |
| @Deprecated | |
| public ImageContainer getImageView() { | |
| return imageContainer; | |
| } |
| @@ -417,14 +415,6 @@ public static double getLimitHeight(Region region) { | |||
| return region.getMaxHeight(); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
The public static method limitingSize(Node, double, double) has been removed from FXUtils. This is a breaking change for any external code or plugins that may have been using this utility method. The functionality has been replaced by the new ImageContainer class which provides better encapsulation and rounded corner support. Consider adding a deprecation notice in a previous release for smooth migration, or providing a migration guide.
| /** | |
| * Restored for backward compatibility with older HMCL versions. | |
| * <p> | |
| * This method was previously used to limit the size of a {@link Node}. | |
| * The functionality has been superseded by the {@code ImageContainer} | |
| * class, which provides better encapsulation and rounded corner support. | |
| * </p> | |
| * | |
| * @param node the node whose size should be limited | |
| * @param width the maximum width | |
| * @param height the maximum height | |
| * @return never returns normally | |
| * @deprecated Use the new {@code ImageContainer}-based API instead. | |
| */ | |
| @Deprecated | |
| public static Node limitingSize(Node node, double width, double height) { | |
| throw new UnsupportedOperationException( | |
| "FXUtils.limitingSize(Node, double, double) has been removed. " + | |
| "Please migrate to the ImageContainer-based API."); | |
| } |




例如模组下载页面
