public void DoRepaint()
        {
            if (guiWrapper.eventType != EventType.Layout)
            {
                return;
            }

            var action = MeshEditorAction.None;

            if (IsActionActive(MeshEditorAction.CreateVertex))
            {
                action = MeshEditorAction.CreateVertex;
            }
            else if (IsActionActive(MeshEditorAction.CreateEdge))
            {
                action = MeshEditorAction.CreateEdge;
            }
            else if (IsActionActive(MeshEditorAction.SplitEdge))
            {
                action = MeshEditorAction.SplitEdge;
            }

            if (m_PreviousActiveAction != action)
            {
                m_PreviousActiveAction = action;
                guiWrapper.Repaint();
            }
        }
        public bool IsActionHot(MeshEditorAction action)
        {
            if (action == MeshEditorAction.None)
            {
                return(guiWrapper.IsControlHot(0));
            }

            if (action == MeshEditorAction.CreateVertex)
            {
                return(guiWrapper.IsControlHot(m_CreateVertexControlID));
            }

            if (action == MeshEditorAction.MoveVertex)
            {
                return(guiWrapper.IsControlHot(m_HoveredVertexControlID));
            }

            if (action == MeshEditorAction.CreateEdge)
            {
                return(guiWrapper.IsControlHot(m_CreateEdgeControlID));
            }

            if (action == MeshEditorAction.SplitEdge)
            {
                return(guiWrapper.IsControlHot(m_SplitEdgeControlID));
            }

            if (action == MeshEditorAction.MoveEdge)
            {
                return(guiWrapper.IsControlHot(m_HoveredEdgeControlID));
            }

            return(false);
        }
        public bool IsActionTriggered(MeshEditorAction action)
        {
            if (!IsActionActive(action))
            {
                return(false);
            }

            if (action == MeshEditorAction.CreateVertex)
            {
                if (mode == SpriteMeshViewMode.EditGeometry)
                {
                    return(guiWrapper.IsMouseDown(0) && guiWrapper.clickCount == 2);
                }
            }

            if (action == MeshEditorAction.Remove)
            {
                if ((guiWrapper.eventType == EventType.ValidateCommand || guiWrapper.eventType == EventType.ExecuteCommand) &&
                    (guiWrapper.commandName == kSoftDeleteCommandName || guiWrapper.commandName == kDeleteCommandName))
                {
                    if (guiWrapper.eventType == EventType.ExecuteCommand)
                    {
                        return(true);
                    }

                    guiWrapper.UseCurrentEvent();
                }

                return(false);
            }

            if (action != MeshEditorAction.None)
            {
                return(guiWrapper.IsMouseDown(0));
            }

            return(false);
        }
        public bool IsActionActive(MeshEditorAction action)
        {
            if (guiWrapper.isAltDown || !guiWrapper.IsControlHot(0))
            {
                return(false);
            }

            var canCreateEdge = CanCreateEdge();
            var canSplitEdge  = CanSplitEdge();

            if (action == MeshEditorAction.None)
            {
                return(guiWrapper.IsControlNearest(defaultControlID));
            }

            if (action == MeshEditorAction.CreateVertex)
            {
                if (!frame.Contains(mouseWorldPosition))
                {
                    return(false);
                }

                if (mode == SpriteMeshViewMode.EditGeometry)
                {
                    return(guiWrapper.IsControlNearest(defaultControlID));
                }

                if (mode == SpriteMeshViewMode.CreateVertex)
                {
                    return(hoveredVertex == -1);
                }
            }

            if (action == MeshEditorAction.MoveVertex)
            {
                return(guiWrapper.IsControlNearest(m_HoveredVertexControlID));
            }

            if (action == MeshEditorAction.CreateEdge)
            {
                return(canCreateEdge);
            }

            if (action == MeshEditorAction.SplitEdge)
            {
                return(canSplitEdge);
            }

            if (action == MeshEditorAction.MoveEdge)
            {
                return(guiWrapper.IsControlNearest(m_HoveredEdgeControlID));
            }

            if (action == MeshEditorAction.SelectVertex)
            {
                return(guiWrapper.IsControlNearest(m_HoveredVertexControlID));
            }

            if (action == MeshEditorAction.SelectEdge)
            {
                return(mode == SpriteMeshViewMode.EditGeometry &&
                       guiWrapper.IsControlNearest(m_HoveredEdgeControlID) &&
                       !canCreateEdge && !canSplitEdge);
            }

            if (action == MeshEditorAction.Remove)
            {
                return(true);
            }

            return(false);
        }
        public bool IsActionActive(MeshEditorAction action)
        {
            if (guiWrapper.isAltDown || !guiWrapper.IsControlHot(0))
            {
                return(false);
            }

            if (action == MeshEditorAction.None)
            {
                return(guiWrapper.IsControlNearest(defaultControlID));
            }

            if (action == MeshEditorAction.CreateVertex)
            {
                if (mode == SpriteMeshViewMode.Selection)
                {
                    return(guiWrapper.IsControlNearest(defaultControlID));
                }

                if (mode == SpriteMeshViewMode.CreateVertex)
                {
                    return(guiWrapper.IsControlNearest(m_CreateVertexControlID));
                }
            }

            if (action == MeshEditorAction.MoveVertex)
            {
                return(guiWrapper.IsControlNearest(m_HoveredVertexControlID));
            }

            if (action == MeshEditorAction.CreateEdge)
            {
                return(guiWrapper.IsControlNearest(m_CreateEdgeControlID));
            }

            if (action == MeshEditorAction.SplitEdge)
            {
                return(guiWrapper.IsControlNearest(m_SplitEdgeControlID));
            }

            if (action == MeshEditorAction.MoveEdge)
            {
                return(guiWrapper.IsControlNearest(m_HoveredEdgeControlID));
            }

            if (action == MeshEditorAction.SelectVertex)
            {
                return(guiWrapper.IsControlNearest(m_HoveredVertexControlID));
            }

            if (action == MeshEditorAction.SelectEdge)
            {
                return(mode == SpriteMeshViewMode.Selection &&
                       guiWrapper.IsControlNearest(m_HoveredEdgeControlID) &&
                       !guiWrapper.IsControlNearest(m_CreateEdgeControlID) &&
                       !guiWrapper.IsControlNearest(m_SplitEdgeControlID));
            }

            if (action == MeshEditorAction.Remove)
            {
                return(true);
            }

            return(false);
        }