Beispiel #1
0
        private Rect LayoutFlow(WindowItem <T> startWindow, Vector2 startPoint)
        {
            var list = new List <WindowItem <T> >()
            {
                startWindow
            };

            this.layoutLayerBuffer = new float[1000];
            return(LayoutWindowLayer(list, startPoint, 0));
        }
Beispiel #2
0
        public WindowItem <T> GetCurrentWindow(Vector2 mousePosition, bool connectionAreaOnly)
        {
            var            position  = mousePosition;
            WindowItem <T> windowHit = null;

            foreach (var w in this.windowList.Values)
            {
                if (w.HitTest(position, connectionAreaOnly))
                {
                    windowHit = w;
                    break;
                }
            }
            return(windowHit);
        }
Beispiel #3
0
        private bool UpdateWindowList(INodeLoader assembleController)
        {
            bool needRefresh = false;
            // A bit hacky, but so far the best way to convert any type to T
            IEnumerable <T> nodeList           = assembleController.GetAllNodes <T>();
            var             nodeSetToBeDeleted = new HashSet <int>(windowList.Keys);

            foreach (var node in nodeList)
            {
                WindowItem <T> window;
                this.windowList.TryGetValue(node.GetID(), out window);
                if (window != null)
                {
                    // Exist item, just remove from node set and do nothing
                    nodeSetToBeDeleted.Remove(node.GetID());

                    if (window.IsDeleted())
                    {
                        window.MarkDeleted(false);
                    }
                    if (node.GetName() != window.GetNodeName())
                    {
                        window.UpdateNodeName(node.GetName());
                        needRefresh = true;
                    }
                }
                else
                {
                    // The key is new, add new item
                    var newWindow = new WindowItem <T>(node);
                    this.windowList.Add(newWindow.GetNodeId(), newWindow);
                    needRefresh = true;
                    //Debug.Log("Added item " + newWindow.GetNodeId());
                }
            }
            foreach (var item in nodeSetToBeDeleted)
            {
                this.windowList[item].MarkDeleted(true);
                needRefresh = true;
                Debug.Log("Item deleted " + item);
            }
            return(needRefresh);
        }
        private void UpdateConnecting()
        {
            switch (Event.current.type)
            {
            case EventType.mouseDown:
                if (Event.current.isMouse && Event.current.clickCount == 1)
                {
                    this.dragStartWindow = this.windowManager.GetCurrentWindow(Event.current.mousePosition, true);
                    if (this.dragStartWindow != null)
                    {
                        this.uiState     = UIState.connectingState;
                        this.draggingPos = Event.current.mousePosition;
                    }
                }
                else if (Event.current.isMouse && Event.current.clickCount == 2)
                {
                    var window = this.windowManager.GetCurrentWindow(Event.current.mousePosition, true);
                    if (window != null)
                    {
                        window.SelectAndFrameObject();
                    }
                }
                break;

            case EventType.mouseDrag:
                this.draggingPos     = Event.current.mousePosition;
                this.dragEndWindow   = this.windowManager.GetCurrentWindow(Event.current.mousePosition, false);
                this.scrollPosition += GetAdjustmentOffset(this.draggingPos);
                Repaint();
                break;

            case EventType.mouseUp:
                if (this.dragEndWindow != null && this.dragStartWindow != null && this.dragEndWindow != this.dragStartWindow)
                {
                    // Connect the two nodes
                    this.dragEndWindow.AddPreviousStep(this.dragStartWindow);
                    this.windowManager.SetDirty();
                }
                this.uiState         = UIState.normalState;
                this.dragStartWindow = null;
                this.dragEndWindow   = null;
                Repaint();
                break;

            case EventType.repaint:
                if (this.uiState == UIState.connectingState)
                {
                    if (this.dragEndWindow != null && this.dragEndWindow != this.dragStartWindow)
                    {
                        WindowItem <T> .curveFromToBg(this.dragStartWindow, this.dragEndWindow);

                        WindowItem <T> .curveFromTo(this.dragStartWindow, this.dragEndWindow);
                    }
                    else
                    {
                        WindowItem <T> .curveFromTo(this.dragStartWindow, this.draggingPos);
                    }
                }
                break;
            }
        }
Beispiel #5
0
        public static void curveFromTo(WindowItem <T> w1, Vector2 point)
        {
            Color s = new Color(0.4f, 0.4f, 0.5f);

            Drawing.curveFromTo(w1.windowRect, new Rect(point, Vector2.zero), new Color(0.3f, 0.7f, 0.4f), s);
        }
Beispiel #6
0
        public static void curveFromToBg(WindowItem <T> w1, WindowItem <T> w2)
        {
            Color s = new Color(0.4f, 0.4f, 0.5f);

            Drawing.curveFromTo(w1.windowRect, w2.windowRect, new Color(0.3f, 0.7f, 0.4f), s, 2);
        }