package be.iminds.ilabt.jfed.ui.javafx;

import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;

/**
 * User: twalcari
 * Date: 9/10/2014
 * Time: 15:59
 */
public class ImageButton extends Button {

    private final String STYLE_NORMAL = "-fx-background-color: transparent; -fx-padding: 5, 5, 5, 5;";
    private final String STYLE_PRESSED = "-fx-background-color: transparent; -fx-padding: 6 4 4 6;";

    {
        setOnMousePressed(event -> setStyle(STYLE_PRESSED));

        setOnMouseReleased(event -> setStyle(STYLE_NORMAL));
        setStyle(STYLE_NORMAL);
        setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
        setGraphicTextGap(0);
    }

    public ImageButton(Node graphic){
           setGraphic(graphic);
    }
}