/*
 * AppButton.fx
 *
 * Created on Nov 30, 2009, 7:33:32 PM
 */
package mdot_gui;

import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.RadialGradient;
import javafx.scene.paint.Stop;
import CommonFunctions.debugPrinter;

/**
 * @author Jamie Lynn
 */
public class ApplicationButton extends GenericButton {

    var size = Constants.BUTTON_SIZE * Constants.BUTTON_SCALE;
    public var displayimage: Image;

    public override function create(): Node {
        Group {
            blocksMouse: true;
            content: [
                Rectangle {
                    width: size
                    height: size
                    arcWidth: size / 4
                    arcHeight: size / 4
                    fill: null
                    stroke: Color.MEDIUMBLUE
                    strokeWidth: 4
                },
                Rectangle {
                    width: size
                    height: size
                    arcWidth: size / 4
                    arcHeight: size / 4
                    fill: RadialGradient {
                        centerX: 0.5
                        centerY: 0.5
                        stops: [
                            Stop { offset: 0.0 color: Color.DARKBLUE },
                            Stop { offset: 0.8 color: Color.BLACK }
                        ]
                    }
                },
                ImageView {
                    x: (size - displayimage.width) / 2;
                    y: (size - displayimage.height) / 2;
                    image: bind displayimage
                }
            ]
            onMousePressed: function (ev: MouseEvent) {
                debugPrinter.printLine("Button: {index} clicked");

                //change the visibility of the scene corresponding with this button
                SceneManager.swapApplicationScenes(Applications.subscenelist[index], index);
                this.active = true;
            }
        }
    }

}
