Пример #1
0
        public void AddChild(GUIRect rect)
        {
            if (rect.Parent == null && rect != this)
            {
                rect.Parent = this;
                Childrens.Add(rect);

                UpdateThisGUIBranch();
            }
        }
Пример #2
0
        public void RemoveChild(GUIRect rect)
        {
            if (rect.Parent != this)
            {
                return;
            }

            rect.Parent = null;
            Childrens.Remove(rect);

            UpdateThisGUIBranch();
        }
Пример #3
0
        public virtual GUIRect GetIntersection()
        {
            GUIRect intersected =
                RaycastTarget && new RectangleF(Position.X - Pivot.X * Size.X, Position.Y - Pivot.Y * Size.Y, Size.X, Size.Y).
                IntersectsWith(new RectangleF(Input.MouseX, Input.MouseY, 1f, 1f)) ? this : null;

            for (int i = 0; i < Childrens.Count; i++)
            {
                intersected = Childrens[i].GetIntersection() ?? intersected;
            }

            return(intersected);
        }
Пример #4
0
        private static void Update(object sender, FrameEventArgs e)
        {
            for (int i = 0; i < canvases.Count; i++)
            {
                canvases[i].Update((float)e.Time);

                Over = canvases[i].GetIntersection() ?? Over;
            }

            Over?.OnMouseOver();

            if (Over != lastOver)
            {
                Over?.OnMouseEnter();
            }

            if (Over != lastOver)
            {
                lastOver?.OnMouseExit();
            }

            if (Input.GetMouseButtonDown(MouseButton.Left))
            {
                Drag = Over;
                Drag?.OnMouseDown();
            }

            Drag?.OnMousePress();

            if (Input.GetMouseButtonUp(MouseButton.Left))
            {
                Drag?.OnMouseUp();
                Drag = null;
            }

            lastOver = Over;
            Over     = null;
        }