Exemplo n.º 1
0
        private static void UpdateHoveredControl(GUIControl control, int x, int y)
        {
            //
            // We use this global variable to represent our hovered control
            // That way, if the new hovered control gets deleted in one of the
            // Hover callbacks, we won't be left with a hanging pointer.
            // This isn't ideal - but it's minimal.
            //
            m_NewHoveredControl = control;

            // Nothing to change..
            if (HoveredControl == m_NewHoveredControl)
                return;

            // We changed - tell the old hovered control that it's no longer hovered.
            if (HoveredControl != null && HoveredControl != m_NewHoveredControl)
                HoveredControl.DragAndDrop_HoverLeave(CurrentPackage);

            // If we're hovering where the control came from, just forget it.
            // By changing it to null here we're not going to show any error cursors
            // it will just do nothing if you drop it.
            if (m_NewHoveredControl == SourceControl)
                m_NewHoveredControl = null;

            // Check to see if the new potential control can accept this type of package.
            // If not, ignore it and show an error cursor.
            while (m_NewHoveredControl != null && !m_NewHoveredControl.DragAndDrop_CanAcceptPackage(CurrentPackage))
            {
                // We can't drop on this control, so lets try to drop
                // onto its parent..
                m_NewHoveredControl = m_NewHoveredControl.ParentControl;

                // Its parents are dead. We can't drop it here.
                // Show the NO WAY cursor.
                if (m_NewHoveredControl == null)
                {
                    Platform.Neutral.SetCursor(Cursors.No);
                }
            }

            // Become out new hovered control
            HoveredControl = m_NewHoveredControl;

            // If we exist, tell us that we've started hovering.
            if (HoveredControl != null)
            {
                HoveredControl.DragAndDrop_HoverEnter(CurrentPackage, x, y);
            }

            m_NewHoveredControl = null;
        }