/// <inheritdoc /> protected override void BuildPartUI(VisualElement container) { if (m_Model is IConstantNodeModel constantNodeModel) { m_Root = new VisualElement { name = PartName }; m_Root.AddToClassList(m_ParentClassName.WithUssElement(PartName)); m_Label = new Label { name = labelUssName }; m_Label.AddToClassList(m_ParentClassName.WithUssElement(labelUssName)); m_Root.Add(m_Label); var tokenEditor = InlineValueEditor.CreateEditorForConstant( m_OwnerElement.View, null, constantNodeModel.Value, OnValueChanged, constantNodeModel.IsLocked); if (tokenEditor != null) { tokenEditor.AddToClassList(m_ParentClassName.WithUssElement(constantEditorElementUssClassName)); m_Root.Add(tokenEditor); } container.Add(m_Root); } }
protected void BuildConstantEditor() { if (m_Model is IPortModel portModel) { // Rebuild editor if port data type changed. if (m_Editor != null && portModel.EmbeddedValue?.Type != m_EditorDataType) { m_Editor.RemoveFromHierarchy(); m_Editor = null; } if (m_Editor == null) { if (portModel.Direction == PortDirection.Input && portModel.EmbeddedValue != null) { m_EditorDataType = portModel.EmbeddedValue.Type; m_Editor = InlineValueEditor.CreateEditorForConstant( m_OwnerElement.View, portModel, portModel.EmbeddedValue, OnValueChanged, false); if (m_Editor != null) { m_Editor.AddToClassList(m_ParentClassName.WithUssElement(constantEditorUssName)); m_Root.Add(m_Editor); } } } } }
protected void AddInitializationField() { VisualElement initializationElement = null; if (Model is IVariableDeclarationModel variableDeclarationModel) { if (variableDeclarationModel.InitializationModel == null) { var stencil = (Stencil)CommandDispatcher.State.WindowState.GraphModel.Stencil; if (stencil.RequiresInitialization(variableDeclarationModel)) { initializationElement = new Button(OnInitializationButton) { text = "Create Init value" }; } } else { initializationElement = InlineValueEditor.CreateEditorForConstant( View, null, variableDeclarationModel.InitializationModel, (_, v) => { CommandDispatcher.Dispatch(new UpdateConstantValueCommand(variableDeclarationModel.InitializationModel, v, null)); }, false); } } if (initializationElement != null) { AddRow("Initialization", initializationElement, rowInitValueUssClassName); } }