Open
Conversation
Contributor
|
恭喜你,你成功的 reverse 了 #5716 之前调粗是为了防止被吞圆角,比如
这里你调细就会出问题 不幸的是,我没有在 m3 中找到任何滚动条的描述 当然,也有一种解决办法是让它不要顶到头上 另外如果你执意要这么改的话建议改成 4,因为原来就是 4( |
Member
|
/gemini review |
Member
|
我感觉改之后又有点太细了(可能是习惯了新的样式),我感觉还是粗一点容易操控。 |
There was a problem hiding this comment.
Code Review
This pull request adjusts the scroll bar's appearance by reducing its thickness from 8 to 4.5 and introducing a layout offset. The changes affect both the Java skin implementation and the CSS styling. Feedback suggests improving code maintainability by replacing hardcoded values with constants or variables and refactoring redundant binding logic for the track and thumb components to reduce duplication.
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FloatScrollBarSkin.java
Show resolved
Hide resolved
Comment on lines
150
to
170
| if (scrollBar.getOrientation() == Orientation.HORIZONTAL) { | ||
| thumb.relocate(0, -8); | ||
| thumb.widthProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(scrollBar.widthProperty()))); | ||
| thumb.setHeight(8); | ||
| thumb.xProperty().bind(Bindings.subtract(scrollBar.widthProperty(), thumb.widthProperty()).multiply(position)); | ||
| thumb.relocate(0, -4.5); | ||
| thumb.setHeight(4.5); | ||
|
|
||
| NumberBinding trackWidth = Bindings.subtract(scrollBar.widthProperty(), offset * 2); | ||
| thumb.widthProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(trackWidth))); | ||
| thumb.xProperty().bind( | ||
| Bindings.add(offset, | ||
| Bindings.subtract(trackWidth, thumb.widthProperty()).multiply(position)) | ||
| ); | ||
| } else { | ||
| thumb.relocate(-8, 0); | ||
| thumb.setWidth(8); | ||
| thumb.heightProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(scrollBar.heightProperty()))); | ||
| thumb.yProperty().bind(Bindings.subtract(scrollBar.heightProperty(), thumb.heightProperty()).multiply(position)); | ||
| thumb.relocate(-4.5, 0); | ||
| thumb.setWidth(4.5); | ||
|
|
||
| NumberBinding trackHeight = Bindings.subtract(scrollBar.heightProperty(), offset * 2); | ||
| thumb.heightProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(trackHeight))); | ||
| thumb.yProperty().bind( | ||
| Bindings.add(offset, | ||
| Bindings.subtract(trackHeight, thumb.heightProperty()).multiply(position)) | ||
| ); | ||
| } |
There was a problem hiding this comment.
使用前面定义的 thickness、isHorizontal 和 trackLength 变量来简化滑块(thumb)的配置,避免重复的逻辑判断和绑定计算。
if (isHorizontal) {
thumb.relocate(0, -thickness);
thumb.setHeight(thickness);
thumb.widthProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(trackLength)));
thumb.xProperty().bind(
Bindings.add(offset,
Bindings.subtract(trackLength, thumb.widthProperty()).multiply(position))
);
} else {
thumb.relocate(-thickness, 0);
thumb.setWidth(thickness);
thumb.heightProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(trackLength)));
thumb.yProperty().bind(
Bindings.add(offset,
Bindings.subtract(trackLength, thumb.heightProperty()).multiply(position))
);
}
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FloatScrollBarSkin.java
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

感觉有点过于圆+粗了