Beispiel #1
0
        public TokenDeclaration(Store store, IVariableDeclarationModel model, GraphView graphView)
        {
            m_Pill = new Pill();
            Add(m_Pill);

            if (model is IObjectReference modelReference)
            {
                if (modelReference is IExposeTitleProperty titleProperty)
                {
#if UNITY_2019_3_OR_NEWER
                    m_TitleLabel = m_Pill.Q <Label>("title-label");
#else
                    m_TitleLabel = m_Pill.Q <Label>("title-label").ReplaceWithBoundLabel();
#endif
                    m_TitleLabel.bindingPath = titleProperty.TitlePropertyName;
                }
            }

            RegisterCallback <AttachToPanelEvent>(OnAttachToPanel);
            RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);

            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "Token.uss"));

            Declaration = model;
            m_Store     = store;
            m_GraphView = graphView;

            m_Pill.icon = Declaration.IsExposed
                ? VisualScriptingIconUtility.LoadIconRequired("GraphView/Nodes/BlackboardFieldExposed.png")
                : null;

            m_Pill.text = Declaration.Title;

            if (model != null)
            {
                capabilities = VseUtility.ConvertCapabilities(model);
            }

            var     variableModel = model as VariableDeclarationModel;
            Stencil stencil       = store.GetState().CurrentGraphModel?.Stencil;
            if (variableModel != null && stencil && variableModel.DataType.IsValid)
            {
                string friendlyTypeName = variableModel.DataType.GetMetadata(stencil).FriendlyName;
                Assert.IsTrue(!string.IsNullOrEmpty(friendlyTypeName));
                tooltip = $"{variableModel.VariableString} declaration of type {friendlyTypeName}";
                if (!string.IsNullOrEmpty(variableModel.Tooltip))
                {
                    tooltip += "\n" + variableModel.Tooltip;
                }
            }

            SetClasses();

            this.EnableRename();

            if (model != null)
            {
                viewDataKey = model.GetId();
            }
        }
Beispiel #2
0
        public Edge(IEdgeModel edgeModel) : this()
        {
            m_EdgeModel = edgeModel;

            capabilities = VseUtility.ConvertCapabilities(m_EdgeModel);

            PortType portType = m_EdgeModel?.OutputPortModel?.PortType ?? PortType.Data;

            EnableInClassList("execution", portType == PortType.Execution || portType == PortType.Loop);
            EnableInClassList("event", portType == PortType.Event);
            viewDataKey = m_EdgeModel?.GetId();
        }
Beispiel #3
0
        public Placemat(PlacematModel model, Store store, GraphView graphView)
        {
            m_Model = model;
            m_Store = store;

            base.SetPosition(model.Position);
            base.Color     = model.Color;
            base.title     = model.Title;
            base.ZOrder    = model.ZOrder;
            base.Collapsed = model.Collapsed;

            capabilities = VseUtility.ConvertCapabilities(model);
        }
        void UpdateFromModel()
        {
            SetPosition(new Rect(stackModel.Position.x, stackModel.Position.y, 0, 0));

            capabilities = VseUtility.ConvertCapabilities(stackModel);

            UpdatePortsFromModels(stackModel.InputPorts, "input");
            UpdatePortsFromModels(stackModel.OutputPorts, "output");

            viewDataKey = stackModel.GetId();

            if (!stackModel.NodeModels.Any())
            {
                var contentContainerPlaceholder = this.MandatoryQ("stackNodeContentContainerPlaceholder");
                contentContainerPlaceholder.AddToClassList("empty");
            }
        }