4646import javafx .scene .shape .Rectangle ;
4747import javafx .scene .shape .Shape ;
4848import javafx .util .Duration ;
49- import org .jackhuang .hmcl .theme .Themes ;
5049import org .jackhuang .hmcl .ui .animation .AnimationUtils ;
5150import org .jackhuang .hmcl .ui .animation .Motion ;
5251
@@ -143,9 +142,6 @@ public JFXRippler(Node control, RipplerMask mask, RipplerPos pos) {
143142 }
144143
145144 boolean isEntered = event .getEventType () == MouseEvent .MOUSE_ENTERED ;
146- Color onSurface = Themes .getColorScheme ().getOnSurface ();
147- hoverOverlay .setFill (Color .color (onSurface .getRed (), onSurface .getGreen (), onSurface .getBlue (), 0.04 ));
148-
149145 coverAnimation = new Timeline (new KeyFrame (Motion .SHORT4 ,
150146 new KeyValue (hoverOverlay .opacityProperty (), isEntered ? 1 : 0 , isEntered ? Motion .EASE_IN : Motion .EASE_OUT )));
151147 coverAnimation .play ();
@@ -161,8 +157,6 @@ public JFXRippler(Node control, RipplerMask mask, RipplerPos pos) {
161157
162158 private void interpolateBackground (double frac ) {
163159 if (hoverOverlay == null ) return ;
164- Color onSurface = Themes .getColorScheme ().getOnSurface ();
165- hoverOverlay .setFill (Color .color (onSurface .getRed (), onSurface .getGreen (), onSurface .getBlue (), 0.04 ));
166160 hoverOverlay .setOpacity (frac );
167161 }
168162
@@ -177,6 +171,16 @@ protected final void createRippleUI() {
177171 hoverOverlay .setCache (true );
178172 hoverOverlay .setCacheHint (CacheHint .SPEED );
179173 hoverOverlay .setOpacity (0 );
174+
175+ hoverOverlay .fillProperty ().bind (Bindings .createObjectBinding (() -> {
176+ Paint currentFill = getRipplerFill ();
177+ if (currentFill instanceof Color fill ) {
178+ return Color .color (fill .getRed (), fill .getGreen (), fill .getBlue (), 0.15 );
179+ } else {
180+ return currentFill ;
181+ }
182+ }, ripplerFillProperty ()));
183+
180184 ripplerPane .getChildren ().addAll (hoverOverlay , rippler );
181185 getChildren ().add (ripplerPane );
182186 }
0 commit comments