예제 #1
0
        void OnValidateCommand(ValidateCommandEvent evt)
        {
            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            if ((evt.commandName == EventCommandNames.Copy && canCopySelection) ||
                (evt.commandName == EventCommandNames.Paste && canPaste) ||
                (evt.commandName == EventCommandNames.Duplicate && canDuplicateSelection) ||
                (evt.commandName == EventCommandNames.Cut && canCutSelection) ||
                ((evt.commandName == EventCommandNames.Delete || evt.commandName == EventCommandNames.SoftDelete) && canDeleteSelection))
            {
                evt.StopPropagation();
                if (evt.imguiEvent != null)
                {
                    evt.imguiEvent.Use();
                }
            }
            else if (evt.commandName == EventCommandNames.FrameSelected)
            {
                evt.StopPropagation();
                if (evt.imguiEvent != null)
                {
                    evt.imguiEvent.Use();
                }
            }
        }
예제 #2
0
 private void OnMouseDown(MouseDownEvent e)
 {
     if (this.m_Active)
     {
         e.StopImmediatePropagation();
     }
     else if (!MouseCaptureController.IsMouseCaptureTaken())
     {
         GraphElement graphElement = base.parent as GraphElement;
         if (graphElement != null)
         {
             if (graphElement.IsResizable())
             {
                 if (e.button == (int)this.activateButton)
                 {
                     this.m_Start    = this.ChangeCoordinatesTo(base.parent, e.localMousePosition);
                     this.m_StartPos = base.parent.layout;
                     if (base.parent.style.positionType != PositionType.Manual)
                     {
                         Debug.LogWarning("Attempting to resize an object with a non manual position");
                     }
                     this.m_Active = true;
                     this.TakeMouseCapture();
                     e.StopPropagation();
                 }
             }
         }
     }
 }
예제 #3
0
        private void OnWheel(WheelEvent evt)
        {
            GraphView graphView = base.target as GraphView;

            if (graphView != null)
            {
                if (!MouseCaptureController.IsMouseCaptureTaken())
                {
                    Vector3 vector  = graphView.viewTransform.position;
                    Vector3 scale   = graphView.viewTransform.scale;
                    Vector2 vector2 = base.target.ChangeCoordinatesTo(graphView.contentViewContainer, evt.localMousePosition);
                    float   x       = vector2.x + graphView.contentViewContainer.layout.x;
                    float   y       = vector2.y + graphView.contentViewContainer.layout.y;
                    vector += Vector3.Scale(new Vector3(x, y, 0f), scale);
                    float num = ContentZoomer.CalculateNewZoom(scale.y, -evt.delta.y, this.scaleStep, this.referenceScale, this.minScale, this.maxScale);
                    scale.x = num;
                    scale.y = num;
                    scale.z = 1f;
                    vector -= Vector3.Scale(new Vector3(x, y, 0f), scale);
                    if (graphView.elementPanel != null && this.keepPixelCacheOnZoom)
                    {
                        graphView.elementPanel.keepPixelCacheOnWorldBoundChange = true;
                        if (this.m_OnTimerTicker == null)
                        {
                            this.m_OnTimerTicker = graphView.schedule.Execute(new Action <TimerState>(this.OnTimer));
                        }
                        this.m_OnTimerTicker.ExecuteLater(500L);
                        this.delayRepaintScheduled = true;
                    }
                    graphView.UpdateViewTransform(vector, scale);
                    evt.StopPropagation();
                }
            }
        }
예제 #4
0
        void OnWheel(WheelEvent evt)
        {
            var graphView = target as GraphView;

            if (graphView == null)
            {
                return;
            }

            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            Vector3 position = graphView.viewTransform.position;
            Vector3 scale    = graphView.viewTransform.scale;

            // TODO: augment the data to have the position as well, so we don't have to read in data from the target.
            // 0-1 ranged center relative to size
            Vector2 zoomCenter = target.ChangeCoordinatesTo(graphView.contentViewContainer, evt.localMousePosition);
            float   x          = zoomCenter.x + graphView.contentViewContainer.layout.x;
            float   y          = zoomCenter.y + graphView.contentViewContainer.layout.y;

            position += Vector3.Scale(new Vector3(x, y, 0), scale);

            // Apply the new zoom.
            float zoom = CalculateNewZoom(scale.y, -evt.delta.y, scaleStep, referenceScale, minScale, maxScale);

            scale.x = zoom;
            scale.y = zoom;
            scale.z = 1;

            position -= Vector3.Scale(new Vector3(x, y, 0), scale);

            // Delay updating of the pixel cache so the scrolling appears smooth.
            if (graphView.elementPanel != null && keepPixelCacheOnZoom)
            {
                graphView.elementPanel.keepPixelCacheOnWorldBoundChange = true;

                if (m_OnTimerTicker == null)
                {
                    m_OnTimerTicker = graphView.schedule.Execute(OnTimer);
                }

                m_OnTimerTicker.ExecuteLater(500);

                delayRepaintScheduled = true;
            }

            graphView.UpdateViewTransform(position, scale);

            evt.StopPropagation();
        }
예제 #5
0
        void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            var ce = parent as GraphElement;

            if (ce == null)
            {
                return;
            }

            if (!((StoryNode)ce).expanded)
            {
                return;
            }
//            if (!ce.IsResizable())
//                return;

            if (e.button == (int)ActivateButton)
            {
                m_Start    = this.ChangeCoordinatesTo(parent, e.localMousePosition);
                m_StartPos = parent.layout;
                // Warn user if target uses a relative CSS position type
//                if (parent.style.positionType != PositionType.Manual)
//                {
//                    if (parent.style.positionType == PositionType.Absolute)
//                    {
//                        if (!(parent.style.flexDirection == FlexDirection.Column || parent.style.flexDirection == FlexDirection.Row))
//                        {
//                            Debug.LogWarning("Attempting to resize an object with an absolute position but no layout direction (row or column)");
//                        }
//                    }
//                    else
//                    {
//                        Debug.LogWarning("Attempting to resize an object with a non manual position");
//                    }
//                }

                m_Active = true;
                this.TakeMouseCapture();
                e.StopPropagation();
            }
        }
예제 #6
0
        void OnExecuteCommand(ExecuteCommandEvent evt)
        {
            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            if (evt.commandName == EventCommandNames.Copy)
            {
                CopySelectionCallback();
                evt.StopPropagation();
            }
            else if (evt.commandName == EventCommandNames.Paste)
            {
                PasteCallback();
                evt.StopPropagation();
            }
            else if (evt.commandName == EventCommandNames.Duplicate)
            {
                DuplicateSelectionCallback();
                evt.StopPropagation();
            }
            else if (evt.commandName == EventCommandNames.Cut)
            {
                CutSelectionCallback();
                evt.StopPropagation();
            }
            else if (evt.commandName == EventCommandNames.Delete)
            {
                DeleteSelectionCallback(AskUser.DontAskUser);
                evt.StopPropagation();
            }
            else if (evt.commandName == EventCommandNames.SoftDelete)
            {
                DeleteSelectionCallback(AskUser.AskUser);
                evt.StopPropagation();
            }
            else if (evt.commandName == EventCommandNames.FrameSelected)
            {
                FrameSelection();
                evt.StopPropagation();
            }

            if (evt.isPropagationStopped && evt.imguiEvent != null)
            {
                evt.imguiEvent.Use();
            }
        }
예제 #7
0
        void OnKeyDownShortcut(KeyDownEvent evt)
        {
            if (!isReframable)
            {
                return;
            }

            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            EventPropagation result = EventPropagation.Continue;

            switch (evt.character)
            {
            case 'a':
                result = FrameAll();
                break;

            case 'o':
                result = FrameOrigin();
                break;

            case '[':
                result = FramePrev();
                break;

            case ']':
                result = FrameNext();
                break;

            case ' ':
                result = OnInsertNodeKeyDown(evt);
                break;
            }

            if (result == EventPropagation.Stop)
            {
                evt.StopPropagation();
                if (evt.imguiEvent != null)
                {
                    evt.imguiEvent.Use();
                }
            }
        }
예제 #8
0
 private void OnKeyDown(KeyDownEvent evt)
 {
     if (!MouseCaptureController.IsMouseCaptureTaken())
     {
         if (this.m_Dictionary.ContainsKey(evt.imguiEvent))
         {
             EventPropagation eventPropagation = this.m_Dictionary[evt.imguiEvent]();
             if (eventPropagation == EventPropagation.Stop)
             {
                 evt.StopPropagation();
                 if (evt.imguiEvent != null)
                 {
                     evt.imguiEvent.Use();
                 }
             }
         }
     }
 }
예제 #9
0
 protected void OnMouseDown(MouseDownEvent e)
 {
     if (this.m_Active)
     {
         e.StopImmediatePropagation();
     }
     else if (!MouseCaptureController.IsMouseCaptureTaken())
     {
         this.m_Active           = false;
         this.m_Dragging         = false;
         this.m_AddedByMouseDown = false;
         if (base.target != null)
         {
             this.selectionContainer = base.target.GetFirstAncestorOfType <ISelection>();
             if (this.selectionContainer != null)
             {
                 this.selectedElement = base.target.GetFirstOfType <GraphElement>();
                 if (this.selectedElement != null)
                 {
                     if (!this.selectionContainer.selection.Contains(this.selectedElement))
                     {
                         if (!e.ctrlKey)
                         {
                             this.selectionContainer.ClearSelection();
                         }
                         this.selectionContainer.AddToSelection(this.selectedElement);
                         this.m_AddedByMouseDown = true;
                     }
                     if (e.button == (int)this.activateButton)
                     {
                         if (this.selectedElement.IsDroppable())
                         {
                             this.m_DragAndDropDelay.Init(e.localMousePosition);
                             this.m_Active = true;
                             base.target.TakeMouseCapture();
                             e.StopPropagation();
                         }
                     }
                 }
             }
         }
     }
 }
예제 #10
0
        void OnKeyDown(KeyDownEvent evt)
        {
            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            if (m_Dictionary.ContainsKey(evt.imguiEvent))
            {
                EventPropagation result = m_Dictionary[evt.imguiEvent]();
                if (result == EventPropagation.Stop)
                {
                    evt.StopPropagation();
                    if (evt.imguiEvent != null)
                    {
                        evt.imguiEvent.Use();
                    }
                }
            }
        }
예제 #11
0
        void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            var ce = parent as GraphElement;

            if (ce == null)
            {
                return;
            }

            if (!ce.IsResizable())
            {
                return;
            }

            if (e.button == (int)activateButton)
            {
                m_Start    = this.ChangeCoordinatesTo(parent, e.localMousePosition);
                m_StartPos = parent.layout;
                // Warn user if target uses a relative CSS position type
                if (parent.style.positionType != PositionType.Manual)
                {
                    Debug.LogWarning("Attempting to resize an object with a non manual position");
                }

                m_Active = true;
                this.TakeMouseCapture();
                e.StopPropagation();
            }
        }
예제 #12
0
        protected void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            if (MouseCaptureController.IsMouseCaptureTaken())
            {
                return;
            }

            m_Active           = false;
            m_Dragging         = false;
            m_AddedByMouseDown = false;

            if (target == null)
            {
                return;
            }

            selectionContainer = target.GetFirstAncestorOfType <ISelection>();

            if (selectionContainer == null)
            {
                return;
            }

            selectedElement = target.GetFirstOfType <GraphElement>();

            if (selectedElement == null)
            {
                return;
            }

            // Since we didn't drag after all, update selection with current element only
            if (!selectionContainer.selection.Contains(selectedElement))
            {
                if (!e.ctrlKey)
                {
                    selectionContainer.ClearSelection();
                }
                selectionContainer.AddToSelection(selectedElement);
                m_AddedByMouseDown = true;
            }

            if (e.button == (int)activateButton)
            {
                // avoid starting a manipulation on a non movable object

                if (!selectedElement.IsDroppable())
                {
                    return;
                }

                // Reset drag and drop
                m_DragAndDropDelay.Init(e.localMousePosition);

                m_Active = true;
                target.TakeMouseCapture();
                e.StopPropagation();
            }
        }