Code/UI/NodePanel.cs
namespace Nodebox.UI;

public abstract class NodePanel : Panel, IGraphStyle {
    public Action<Node, PinRef> PinClicked { get; set; }
    public Action<Node, PinRef> PinDown { get; set; }
    public Action<Node, PinRef> PinUp { get; set; }
    public Node Node { get; set; }
    public abstract Panel GetPin(Flow flow, PinIndex pinIndex);


    protected override void OnClick(MousePanelEvent e) {
        base.OnMouseDown(e);

        if (e.Target is PinButton pinButton) {
            PinClicked?.Invoke(Node, pinButton.PinRef);
        }
    }

    protected override void OnMouseDown(MousePanelEvent e) {
        base.OnMouseDown(e);

        if (e.Target is PinButton pinButton) {
            PinDown?.Invoke(Node, pinButton.PinRef);
        }
    }

    protected override void OnMouseUp(MousePanelEvent e) {
        base.OnMouseDown(e);

        if (e.Target is PinButton pinButton) {
            PinUp?.Invoke(Node, pinButton.PinRef);
        }
    }

    protected override int BuildHash() => HashCode.Combine(
        this.GraphStyle,
        Node,
        Node.Generation
    );
}