package fr.monkhanny.dorfromantik.gui;

import fr.monkhanny.dorfromantik.Options;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ButtonHoverAnimator {

    private final JButton button;
    private final Color originalColor;
    private static Font originalFont;
    private Timer animationTimer;
    private float currentScale = 1.0f;

    public ButtonHoverAnimator(JButton button) {
        this.button = button;
        this.originalColor = button.getForeground();
        this.originalFont = button.getFont();
    }

    public void startAnimation(boolean entering) {
        if (animationTimer != null && animationTimer.isRunning()) {
            animationTimer.stop();
        }

        // Create a new ActionListener instance
        animationTimer = new Timer(Options.ANIMATION_DELAY, new ButtonHoverAnimationListener(entering, button, originalColor, originalFont));
        animationTimer.start();
    }

    public static void updateOriginalFont(float newFontSize) {
        originalFont = originalFont.deriveFont(newFontSize);
    }

}
