using System;
using UnityEngine;
using UnityEngine.UI;

namespace UnityEngine.UI
{
    [Serializable]
    public struct UXNavigation : IEquatable<UXNavigation>
    {
        [Flags]
        public enum Mode
        {
            None = 0,
            Horizontal = 1,
            Vertical = 2,
            Automatic = 3,
            Explicit = 4,
        }

        [SerializeField] private Mode m_Mode;

        [HideInInspector] [SerializeField] private bool m_WrapAround;

        [SerializeField] private UXSelectable m_SelectOnUp;
        [SerializeField] private UXSelectable m_SelectOnDown;
        [SerializeField] private UXSelectable m_SelectOnLeft;
        [SerializeField] private UXSelectable m_SelectOnRight;

        public Mode mode
        {
            get { return m_Mode; }
            set { m_Mode = value; }
        }

        public bool wrapAround
        {
            get { return m_WrapAround; }
            set { m_WrapAround = value; }
        }

        public UXSelectable selectOnUp
        {
            get { return m_SelectOnUp; }
            set { m_SelectOnUp = value; }
        }

        public UXSelectable selectOnDown
        {
            get { return m_SelectOnDown; }
            set { m_SelectOnDown = value; }
        }

        public UXSelectable selectOnLeft
        {
            get { return m_SelectOnLeft; }
            set { m_SelectOnLeft = value; }
        }

        public UXSelectable selectOnRight
        {
            get { return m_SelectOnRight; }
            set { m_SelectOnRight = value; }
        }

        static public UXNavigation defaultNavigation
        {
            get
            {
                var defaultNav = new UXNavigation();
                defaultNav.m_Mode = Mode.Automatic;
                defaultNav.m_WrapAround = false;
                return defaultNav;
            }
        }

        public bool Equals(UXNavigation other)
        {
            return mode == other.mode &&
                   selectOnUp == other.selectOnUp &&
                   selectOnDown == other.selectOnDown &&
                   selectOnLeft == other.selectOnLeft &&
                   selectOnRight == other.selectOnRight;
        }
    }
}
