Example #1
0
    public LokiGraphView()
    {
        this.AddManipulator(new ClickSelector());
        this.AddManipulator(new ContentDragger());
        this.AddManipulator(new SelectionDragger());
        this.AddManipulator(new RectangleSelector());

        SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale * 2f);

        var styleSheet = LokiResources.Get <StyleSheet>(STYLE_SHEET_PATH);

        styleSheets.Add(styleSheet);

        searchWindowProvider = ScriptableObject.CreateInstance <SearchWindowProvider>();
        searchWindowProvider.Prepare();

        var node = new Node();

        var port = node.InstantiatePort(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, typeof(float));

        node.inputContainer.Add(port);

        this.AddElement(node);


        var type = typeof(TestClass);
        var f0   = type.GetField("x");
        var f1   = type.GetField("y");

        var nodeView2 = new LokiNodeView(new VariableAdapter(f0));

        nodeView2.SetPosition(Vector2.one * 300f);

        var nodeView = new LokiNodeView(new VariableAdapter(f1));

        nodeView.SetPosition(Vector3.right * 200f + Vector3.up * 100f);

        this.AddElement(nodeView);
        this.AddElement(nodeView2);


        // EventCallback<GeometryChangedEvent> func = null;
        // func = evt =>
        // {
        //  var edge = new LokiEdge();
        //  edge.Connect(nodeView.Q<LokiPort>(), null); // nodeView2.Q<LokiPort>());
        //  this.AddElement(edge);
        //  nodeView.UnregisterCallback<GeometryChangedEvent>(func);
        // };
        //
        // nodeView.RegisterCallback<GeometryChangedEvent>(func);
    }
Example #2
0
        public override void BuildNodeView(LokiNodeView view)
        {
            view.titleLabel.text = field.Name;

            view.midContainer.RemoveFromHierarchy();

            var setPort =
                view.headerContainer.InsertPort(0, Orientation.Horizontal, Direction.Input, Capacity.Single,
                                                field.Name);
            var getPort =
                view.headerContainer.AddPort(Orientation.Horizontal, Direction.Output, Capacity.Multi, field.Name);

            setPort.tooltip = $"Set {field.Name}";
            getPort.tooltip = $"Get {field.Name}";
        }
Example #3
0
 public abstract void BuildNodeView(LokiNodeView view);
Example #4
0
 public SerializableNodeView(LokiNodeView view)
 {
     this.guid     = view.guid;
     this.position = view.GetPosition().position;
 }