Skip to content

Commit 2ff9737

Browse files
committed
update
1 parent 6d8add6 commit 2ff9737

1 file changed

Lines changed: 4 additions & 51 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ComponentListCell.java

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@
1919

2020
import javafx.animation.*;
2121
import javafx.application.Platform;
22-
import javafx.beans.property.BooleanProperty;
23-
import javafx.beans.property.SimpleBooleanProperty;
2422
import javafx.geometry.Insets;
2523
import javafx.geometry.Pos;
2624
import javafx.scene.Node;
2725
import javafx.scene.control.Label;
2826
import javafx.scene.input.MouseButton;
2927
import javafx.scene.input.MouseEvent;
3028
import javafx.scene.layout.*;
31-
import javafx.scene.shape.Rectangle;
3229
import javafx.util.Duration;
3330
import org.jackhuang.hmcl.theme.Themes;
3431
import org.jackhuang.hmcl.ui.FXUtils;
@@ -42,34 +39,14 @@
4239
final class ComponentListCell extends StackPane {
4340
private final Node content;
4441
private Animation expandAnimation;
45-
private Rectangle clipRect;
46-
private final BooleanProperty expanded = new SimpleBooleanProperty(this, "expanded", false);
42+
private boolean expanded = false;
4743

4844
ComponentListCell(Node content) {
4945
this.content = content;
5046

5147
updateLayout();
5248
}
5349

54-
private void updateClip(double newHeight) {
55-
if (clipRect != null)
56-
clipRect.setHeight(newHeight);
57-
}
58-
59-
@Override
60-
protected void layoutChildren() {
61-
super.layoutChildren();
62-
63-
if (clipRect == null)
64-
clipRect = new Rectangle(0, 0, getWidth(), getHeight());
65-
else {
66-
clipRect.setX(0);
67-
clipRect.setY(0);
68-
clipRect.setHeight(getHeight());
69-
clipRect.setWidth(getWidth());
70-
}
71-
}
72-
7350
private void updateLayout() {
7451
if (content instanceof ComponentList list) {
7552
content.getStyleClass().remove("options-list");
@@ -147,8 +124,8 @@ private void updateLayout() {
147124
expandAnimation.stop();
148125
}
149126

150-
boolean expanded = !isExpanded();
151-
setExpanded(expanded);
127+
boolean expanded = !this.expanded;
128+
this.expanded = expanded;
152129
if (expanded) {
153130
list.doLazyInit();
154131
list.layout();
@@ -157,14 +134,10 @@ private void updateLayout() {
157134
Platform.runLater(() -> {
158135
// FIXME: ComponentSubList without padding must have a 4 pixel padding for displaying a border radius.
159136
double newAnimatedHeight = (list.prefHeight(list.getWidth()) + (hasPadding ? 8 + 10 : 4)) * (expanded ? 1 : -1);
160-
double newHeight = expanded ? getHeight() + newAnimatedHeight : prefHeight(list.getWidth());
137+
// double newHeight = expanded ? getHeight() + newAnimatedHeight : prefHeight(list.getWidth());
161138
double contentHeight = expanded ? newAnimatedHeight : 0;
162139
double targetRotate = expanded ? -180 : 0;
163140

164-
if (expanded) {
165-
updateClip(newHeight);
166-
}
167-
168141
if (AnimationUtils.isAnimationEnabled()) {
169142
double currentRotate = expandIcon.getRotate();
170143
Duration duration = Motion.LONG2.multiply(Math.abs(currentRotate - targetRotate) / 180.0);
@@ -177,19 +150,11 @@ private void updateLayout() {
177150
new KeyValue(expandIcon.rotateProperty(), targetRotate, interpolator))
178151
);
179152

180-
if (!expanded) {
181-
expandAnimation.setOnFinished(e2 -> updateClip(newHeight));
182-
}
183-
184153
expandAnimation.play();
185154
} else {
186155
container.setMinHeight(contentHeight);
187156
container.setMaxHeight(contentHeight);
188157
expandIcon.setRotate(targetRotate);
189-
190-
if (!expanded) {
191-
updateClip(newHeight);
192-
}
193158
}
194159
});
195160
});
@@ -200,16 +165,4 @@ private void updateLayout() {
200165
getChildren().setAll(content);
201166
}
202167
}
203-
204-
public boolean isExpanded() {
205-
return expanded.get();
206-
}
207-
208-
public BooleanProperty expandedProperty() {
209-
return expanded;
210-
}
211-
212-
public void setExpanded(boolean expanded) {
213-
this.expanded.set(expanded);
214-
}
215168
}

0 commit comments

Comments
 (0)