Exemplo n.º 1
0
 private void Inspect(TreeViewItem treeView, Vector2 position)
 {
     if (treeView is HierarchyNodeTree nodeTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = nodeTree.node
             });
         }, 300, 300).ChangePosition(position);
     }
     else if (treeView is HierarchyFunctionTree functionTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = functionTree.function
             });
         }, 300, 300).ChangePosition(position);
     }
     else if (treeView is HierarchyPropertyTree propertyTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = propertyTree.property
             });
         }, 300, 300).ChangePosition(position);
     }
     else if (treeView is HierarchyVariableTree variableTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = variableTree.variable
             });
         }, 300, 300).ChangePosition(position);
     }
 }
Exemplo n.º 2
0
        protected void Initialize(UGraphView owner)
        {
            this.owner = owner;
            this.AddToClassList("node-view");
            if (!ShowExpandButton())             //Hides colapse button
            {
                m_CollapseButton.style.position = Position.Absolute;
                m_CollapseButton.style.width    = 0;
                m_CollapseButton.style.height   = 0;
                m_CollapseButton.visible        = false;
            }
            base.expanded = true;
            RegisterCallback <MouseDownEvent>(evt => {
                var mPos = (evt.currentTarget as VisualElement).GetScreenMousePosition(evt.localMousePosition, graph.window);
                if (evt.button == 0 && evt.shiftKey && !evt.altKey)
                {
                    ActionPopupWindow.ShowWindow(Vector2.zero, () => {
                        CustomInspector.ShowInspector(new GraphEditorData(graph.editorData)
                        {
                            selected = targetNode
                        });
                    }, 300, 300).ChangePosition(mPos);
                }
            });
            RegisterCallback <MouseOverEvent>((e) => {
                for (int i = 0; i < inputPorts.Count; i++)
                {
                    var edges = inputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = true;
                        }
                    }
                }
                for (int i = 0; i < outputPorts.Count; i++)
                {
                    var edges = outputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = true;
                        }
                    }
                }
            });
            RegisterCallback <MouseLeaveEvent>((e) => {
                for (int i = 0; i < inputPorts.Count; i++)
                {
                    var edges = inputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = false;
                        }
                    }
                }
                for (int i = 0; i < outputPorts.Count; i++)
                {
                    var edges = outputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = false;
                        }
                    }
                }
            });
            RegisterCallback <GeometryChangedEvent>(evt => {
                if (evt.oldRect != Rect.zero && evt.oldRect.width != evt.newRect.width)
                {
                    Teleport(new Rect(evt.newRect.x + (evt.oldRect.width - evt.newRect.width), evt.newRect.y, evt.newRect.width, evt.newRect.height));
                }
            });

            border = this.Q("node-border");
            {            //Flow inputs
                flowInputContainer      = new VisualElement();
                flowInputContainer.name = "flow-inputs";
                flowInputContainer.AddToClassList("flow-container");
                flowInputContainer.AddToClassList("input");
                flowInputContainer.pickingMode = PickingMode.Ignore;
                border.Insert(0, flowInputContainer);
            }
            {            //Flow outputs
                flowOutputContainer      = new VisualElement();
                flowOutputContainer.name = "flow-outputs";
                flowOutputContainer.AddToClassList("flow-container");
                flowOutputContainer.AddToClassList("output");
                flowOutputContainer.pickingMode = PickingMode.Ignore;
                Add(flowOutputContainer);
            }

            controlsContainer = new VisualElement {
                name = "controls"
            };
            mainContainer.Add(controlsContainer);

            titleIcon = new Image()
            {
                name = "title-icon"
            };
            titleContainer.Add(titleIcon);
            titleIcon.SendToBack();

            OnSetup();
        }