예제 #1
0
파일: Anchor.cs 프로젝트: fbizuneh/Igor
 public Anchor(string NewLabelText, string NewLabelDescription, AnchorType InType, EntityBox <EntityType> InOwner)
 {
     LabelText        = NewLabelText;
     LabelDescription = NewLabelDescription;
     Type             = InType;
     Owner            = InOwner;
 }
예제 #2
0
        public virtual void HandleContextClick()
        {
            EntityBox <EntityType> HoveredBox = MouseOverBox();

            if (HoveredBox == null)
            {
                if (HandleContextMenu())
                {
                    Event.current.Use();
                }
            }
            else if (GroupSelectedBoxes.Count == 0)
            {
                GenericMenu GenericContextMenu = new GenericMenu();

                if (HoveredBox.HandleContextMenu(GenericContextMenu))
                {
                    GenericContextMenu.ShowAsContext();

                    Event.current.Use();
                }
            }
            else
            {
                if (HandleGroupSelectContextMenu())
                {
                    Event.current.Use();
                }
            }
        }
예제 #3
0
파일: EntityBox.cs 프로젝트: fbizuneh/Igor
        public virtual void BuildConnectionsFromSourceData()
        {
            List <EntityLink <EntityType> > InputEvents = GetInputEvents();

            foreach (EntityLink <EntityType> CurrentLink in InputEvents)
            {
                Anchor <EntityType> LocalAnchor = GetAnchor("Input" + CurrentLink.Name);

                if (LocalAnchor != null)
                {
                    foreach (EntityLink <EntityType> CurrentRemoteLink in CurrentLink.LinkedEntities)
                    {
                        if (CurrentRemoteLink.GetOwner() != null && CurrentRemoteLink.GetOwner().OutputEvents.Contains(CurrentRemoteLink))
                        {
                            EntityBox <EntityType> RemoteBox = Owner.GetEntityBoxForEntity(CurrentRemoteLink.GetOwner());

                            if (RemoteBox != null)
                            {
                                Anchor <EntityType> RemoteAnchor = RemoteBox.GetAnchor("Output" + CurrentRemoteLink.Name);

                                if (RemoteAnchor != null)
                                {
                                    Owner.ConnectInputToOutput(LocalAnchor, RemoteAnchor);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        public virtual void BreakAllConnectionsForBox(EntityBox <EntityType> BoxToDisconnect)
        {
            List <Anchor <EntityType> > FullAnchorList = BoxToDisconnect.GetAllAnchors();

            foreach (Anchor <EntityType> CurrentAnchor in FullAnchorList)
            {
                BreakAllConnectionsForAnchor(CurrentAnchor);
            }
        }
예제 #5
0
        public virtual void RemoveBox(EntityBox <EntityType> BoxToRemove)
        {
            BreakAllConnectionsForBox(BoxToRemove);

            Boxes.Remove(BoxToRemove);

            if (SelectedBox == BoxToRemove)
            {
                SelectedBox            = null;
                Selection.activeObject = null;
            }
        }
예제 #6
0
        protected virtual void CheckAndResolveBoxCollision(EntityBox <EntityType> BoxA, EntityBox <EntityType> BoxB)
        {
            Rect BoxABounds       = BoxA.GetBoxBounds();
            Rect BiggerBoxABounds = new Rect(BoxABounds.x - MinimumSafeDistance, BoxABounds.y - MinimumSafeDistance,
                                             BoxABounds.width + (2 * MinimumSafeDistance), BoxABounds.height + (2 * MinimumSafeDistance));
            Rect BoxBBounds       = BoxB.GetBoxBounds();
            Rect BiggerBoxBBounds = new Rect(BoxBBounds.x - MinimumSafeDistance, BoxBBounds.y - MinimumSafeDistance,
                                             BoxBBounds.width + (2 * MinimumSafeDistance), BoxBBounds.height + (2 * MinimumSafeDistance));

            if (VisualScriptingDrawing.RectOverlapsRect(BiggerBoxABounds, BiggerBoxBBounds))
            {
                Rect CurrentRelativeRect = BiggerBoxABounds;
                bool bNewSpotFound       = false;
                Rect NewBoxBBounds       = BiggerBoxBBounds;

                while (!bNewSpotFound)
                {
                    bool bFoundConflict = false;
                    NewBoxBBounds = new Rect(CurrentRelativeRect.x + CurrentRelativeRect.width + 1,
                                             CurrentRelativeRect.y,
                                             BiggerBoxBBounds.width,
                                             BiggerBoxBBounds.height);

                    for (int CurrentBox = 0; CurrentBox < Boxes.Count; ++CurrentBox)
                    {
                        if (Boxes[CurrentBox] != BoxB)
                        {
                            if (VisualScriptingDrawing.RectOverlapsRect(NewBoxBBounds, Boxes[CurrentBox].GetBoxBounds()))
                            {
                                bFoundConflict = true;

                                Rect NewBoxBounds = Boxes[CurrentBox].GetBoxBounds();
                                CurrentRelativeRect = new Rect(NewBoxBounds.x - MinimumSafeDistance, NewBoxBounds.y - MinimumSafeDistance,
                                                               NewBoxBounds.width + (2 * MinimumSafeDistance), NewBoxBounds.height + (2 * MinimumSafeDistance));
                            }
                        }
                    }

                    if (!bFoundConflict)
                    {
                        bNewSpotFound = true;
                    }
                }

                BoxB.MoveBoxTo(new Vector2(NewBoxBBounds.x + MinimumSafeDistance, NewBoxBBounds.y + MinimumSafeDistance));
            }
        }
예제 #7
0
파일: EntityBox.cs 프로젝트: fbizuneh/Igor
        public virtual void OnDisconnectedAnchors(Anchor <EntityType> LocalAnchor, Anchor <EntityType> RemoteAnchor)
        {
            EntityBox <EntityType> RemoteBox = RemoteAnchor.Owner;
            string LocalAnchorName           = "";
            string RemoteAnchorName          = "";

            if (Inputs.Contains(LocalAnchor))
            {
                LocalAnchorName = "Input";
            }
            else
            {
                LocalAnchorName = "Output";
            }

            LocalAnchorName += LocalAnchor.GetLabelText();

            if (RemoteBox.Inputs.Contains(RemoteAnchor))
            {
                RemoteAnchorName = "Input";
            }
            else
            {
                RemoteAnchorName = "Output";
            }

            RemoteAnchorName += RemoteAnchor.GetLabelText();

            EntityLink <EntityType> LocalLink  = GetLinkByName(LocalAnchorName);
            EntityLink <EntityType> RemoteLink = RemoteBox.GetLinkByName(RemoteAnchorName);

            if (LocalLink != null && RemoteLink != null)
            {
                LocalLink.BreakLink(RemoteLink);
            }
        }
예제 #8
0
 public virtual void CleanDirtyBox(EntityBox <EntityType> DirtyBox)
 {
     DirtyBox.UpdateBoxBounds();
     ArrangeBoxes();
     DirtyBox.CleanedUp();
 }
예제 #9
0
 public virtual void AddBox(EntityBox <EntityType> NewBox)
 {
     Boxes.Add(NewBox);
 }
예제 #10
0
        public virtual void UpdateWindow()
        {
            if (Boxes == null)
            {
                Close();

                return;
            }

            InputState.Update(this, ScrollPosition);

            bInDragSelect = false;

            bool bUpdateDragArea = false;

            if (Event.current.type == EventType.ContextClick)
            {
                HandleContextClick();
            }
            else if (Event.current.type == EventType.MouseDown)
            {
                if (InputState.IsMouseButtonDown(InputState.MouseButton.Mouse_Middle))
                {
                    SelectedBox            = null;
                    Selection.activeObject = null;
                    bInDragSelect          = true;

                    DragSelectStartPosition = InputState.GetLocalMousePosition(this, Vector2.zero);
                }
                else
                {
                    EntityBox <EntityType> NewSelectedBox = MouseOverBox();

                    if (NewSelectedBox == null)
                    {
                        Selection.activeObject = null;
                        GroupSelectedBoxes.Clear();
                    }
                    else if (NewSelectedBox != SelectedBox)
                    {
                        if (GroupSelectedBoxes.Count == 0 || !GroupSelectedBoxes.Contains(NewSelectedBox))
                        {
                            GroupSelectedBoxes.Clear();
                            NewSelectedBox.GainedFocus();
                        }
                    }

                    SelectedBox = NewSelectedBox;
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                bool bShouldCheckDrag = true;

                if (InputState.IsMouseButtonDown(InputState.MouseButton.Mouse_Middle) && !InputState.IsMouseButtonDown(InputState.MouseButton.Mouse_Left))
                {
                    bShouldCheckDrag = false;

                    if (InputState.IsModifierDown(InputState.ModifierKeys.Key_Control))
                    {
                        bShouldCheckDrag = true;
                        bInDragSelect    = true;

                        bUpdateDragArea = true;
                    }
                    else
                    {
                        ScrollPosition -= Event.current.delta;
                    }
                }
                else
                {
                    bInDragSelect = false;

                    bShouldCheckDrag = DragLink != null || GroupSelectedBoxes.Count > 0;
                }

                if (bShouldCheckDrag)
                {
                    Vector2 CurrentMousePosition = InputState.GetLocalMousePosition(this, Vector2.zero);

                    CurrentMousePosition -= ScrollPosition;

                    if (CurrentMousePosition.x < position.width * EdgeAreaToStartMovement)
                    {
                        CurrentMoveDirection = MoveDirection.Move_Left;
                    }
                    else if (CurrentMousePosition.x > position.width * (1.0f - EdgeAreaToStartMovement))
                    {
                        CurrentMoveDirection = MoveDirection.Move_Right;
                    }
                    else if (CurrentMousePosition.y < position.height * EdgeAreaToStartMovement)
                    {
                        CurrentMoveDirection = MoveDirection.Move_Up;
                    }
                    else if (CurrentMousePosition.y > position.height * (1.0f - EdgeAreaToStartMovement))
                    {
                        CurrentMoveDirection = MoveDirection.Move_Down;
                    }
                    else
                    {
                        CurrentMoveDirection = MoveDirection.Move_Stopped;
                    }
                }
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                if (!InputState.IsMouseButtonDown(InputState.MouseButton.Mouse_Middle))
                {
                    LastDragArea         = new Rect(0.0f, 0.0f, 0.0f, 0.0f);
                    bInDragSelect        = false;
                    CurrentMoveDirection = MoveDirection.Move_Stopped;
                }
            }
            else if (!InputState.IsMouseButtonDown(InputState.MouseButton.Mouse_Left) &&
                     !InputState.WasLastMouseUpHandled(this, InputState.MouseButton.Mouse_Left))
            {
                EntityBox <EntityType> NewSelectedBox = MouseOverBox();

                if (NewSelectedBox != null)
                {
                    InputState.HandledMouseUp(InputState.MouseButton.Mouse_Left);

                    if (InputState.WasLastClickDoubleClick(InputState.MouseButton.Mouse_Left))
                    {
                        InputState.HandledDoubleClick(InputState.MouseButton.Mouse_Left);

                        if (GroupSelectedBoxes.Count == 0 || !GroupSelectedBoxes.Contains(NewSelectedBox))
                        {
                            GroupSelectedBoxes.Clear();
                            NewSelectedBox.HandleDoubleClick();
                        }
                    }
                }
            }

            LastScrollDelta = new Vector2(0.0f, 0.0f);

            switch (CurrentMoveDirection)
            {
            case MoveDirection.Move_Left:
                LastScrollDelta = new Vector2(-EdgeMovementSpeeds * Time.deltaTime, 0.0f);
                bUpdateDragArea = bInDragSelect;
                break;

            case MoveDirection.Move_Right:
                LastScrollDelta = new Vector2(EdgeMovementSpeeds * Time.deltaTime, 0.0f);
                bUpdateDragArea = bInDragSelect;
                break;

            case MoveDirection.Move_Up:
                LastScrollDelta = new Vector2(0.0f, -EdgeMovementSpeeds * Time.deltaTime);
                bUpdateDragArea = bInDragSelect;
                break;

            case MoveDirection.Move_Down:
                LastScrollDelta = new Vector2(0.0f, EdgeMovementSpeeds * Time.deltaTime);
                bUpdateDragArea = bInDragSelect;
                break;

            default:
                break;
            }

            ScrollPosition += LastScrollDelta;

            if (bUpdateDragArea)
            {
                Vector2 CurrentPos = InputState.GetLocalMousePosition(this, Vector2.zero);

                Rect DragArea = new Rect(0.0f, 0.0f, 0.0f, 0.0f);

                if (DragSelectStartPosition.x < CurrentPos.x)
                {
                    DragArea.x     = DragSelectStartPosition.x;
                    DragArea.width = CurrentPos.x - DragSelectStartPosition.x;
                }
                else
                {
                    DragArea.x     = CurrentPos.x;
                    DragArea.width = DragSelectStartPosition.x - CurrentPos.x;
                }

                if (DragSelectStartPosition.y < CurrentPos.y)
                {
                    DragArea.y      = DragSelectStartPosition.y;
                    DragArea.height = CurrentPos.y - DragSelectStartPosition.y;
                }
                else
                {
                    DragArea.y      = CurrentPos.y;
                    DragArea.height = DragSelectStartPosition.y - CurrentPos.y;
                }

                LastDragArea = new Rect(DragArea.x - ScrollPosition.x, DragArea.y - ScrollPosition.y, DragArea.width, DragArea.height);

                GroupSelectAllBoxesInArea(DragArea);
            }

            CheckForDirtyBoxes();
        }
예제 #11
0
        public override void BuildConnectionsFromSourceData()
        {
            if (bIsInputBox)
            {
                List <EntityLink <EntityType> > OutputEvents = GetStartEntities();
                foreach (EntityLink <EntityType> CurrentLink in OutputEvents)
                {
                    Anchor <EntityType> LocalAnchor = GetAnchor("Output" + CurrentLink.Name);

                    if (LocalAnchor != null)
                    {
                        foreach (EntityLink <EntityType> CurrentRemoteLink in CurrentLink.LinkedEntities)
                        {
                            if (CurrentRemoteLink.GetOwner() != null)
                            {
                                if (CurrentRemoteLink.GetOwner().InputEvents.Contains(CurrentRemoteLink))
                                {
                                    EntityBox <EntityType> RemoteBox = Owner.GetEntityBoxForEntity(CurrentRemoteLink.GetOwner());

                                    if (RemoteBox != null)
                                    {
                                        Anchor <EntityType> RemoteAnchor = RemoteBox.GetAnchor("Input" + CurrentRemoteLink.Name);

                                        if (RemoteAnchor != null)
                                        {
                                            Owner.ConnectInputToOutput(LocalAnchor, RemoteAnchor);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                EntityBox <EntityType> EndBox = Owner.GetOutputBox();

                                if (EndBox != null)
                                {
                                    Anchor <EntityType> RemoteAnchor = EndBox.GetAnchor("Input" + CurrentRemoteLink.Name);

                                    if (RemoteAnchor != null)
                                    {
                                        Owner.ConnectInputToOutput(LocalAnchor, RemoteAnchor);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                List <EntityLink <EntityType> > InputEvents = GetEndEntities();
                foreach (EntityLink <EntityType> CurrentLink in InputEvents)
                {
                    Anchor <EntityType> LocalAnchor = GetAnchor("Input" + CurrentLink.Name);

                    if (LocalAnchor != null)
                    {
                        foreach (EntityLink <EntityType> CurrentRemoteLink in CurrentLink.LinkedEntities)
                        {
                            if (CurrentRemoteLink.GetOwner() != null)
                            {
                                if (CurrentRemoteLink.GetOwner().OutputEvents.Contains(CurrentRemoteLink))
                                {
                                    EntityBox <EntityType> RemoteBox = Owner.GetEntityBoxForEntity(CurrentRemoteLink.GetOwner());

                                    if (RemoteBox != null)
                                    {
                                        Anchor <EntityType> RemoteAnchor = RemoteBox.GetAnchor("Output" + CurrentRemoteLink.Name);

                                        if (RemoteAnchor != null)
                                        {
                                            Owner.ConnectInputToOutput(LocalAnchor, RemoteAnchor);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                EntityBox <EntityType> StartBox = Owner.GetInputBox();

                                if (StartBox != null)
                                {
                                    Anchor <EntityType> RemoteAnchor = StartBox.GetAnchor("Input" + CurrentRemoteLink.Name);

                                    if (RemoteAnchor != null)
                                    {
                                        Owner.ConnectInputToOutput(LocalAnchor, RemoteAnchor);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }