1919
2020import javafx .animation .*;
2121import javafx .application .Platform ;
22- import javafx .beans .property .BooleanProperty ;
23- import javafx .beans .property .SimpleBooleanProperty ;
2422import javafx .geometry .Insets ;
2523import javafx .geometry .Pos ;
2624import javafx .scene .Node ;
2725import javafx .scene .control .Label ;
2826import javafx .scene .input .MouseButton ;
2927import javafx .scene .input .MouseEvent ;
3028import javafx .scene .layout .*;
31- import javafx .scene .shape .Rectangle ;
3229import javafx .util .Duration ;
3330import org .jackhuang .hmcl .theme .Themes ;
3431import org .jackhuang .hmcl .ui .FXUtils ;
4239final 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