public void AttachMessage(string errString, ShaderCompilerMessageSeverity severity) { ClearMessage(); IconBadge badge; if (severity == ShaderCompilerMessageSeverity.Error) { badge = IconBadge.CreateError(errString); } else { badge = IconBadge.CreateComment(errString); } Add(badge); if (node is BlockNode) { FindPort(node.GetSlotReference(0), out var port); badge.AttachTo(port.parent, SpriteAlignment.RightCenter); } else { badge.AttachTo(m_TitleContainer, SpriteAlignment.RightCenter); } }
public void AddMessageView(string message, NodeMessageType messageType) { IconBadge badge = null; switch (messageType) { case NodeMessageType.Warning: badge = new NodeBadgeView(message, EditorGUIUtility.IconContent("Collab.Warning").image, Color.yellow); break; case NodeMessageType.Error: badge = IconBadge.CreateError(message); break; case NodeMessageType.Info: badge = IconBadge.CreateComment(message); break; default: case NodeMessageType.None: badge = new NodeBadgeView(message, null, Color.grey); break; } AddBadge(badge); }
public void UpdateError(string message) { if (!string.IsNullOrEmpty(message)) //Has error { if (errorBadge == null) { errorBadge = IconBadge.CreateError(message); Add(errorBadge); errorBadge.AttachTo(titleContainer, SpriteAlignment.LeftCenter); } else { errorBadge.badgeText = message; } } else { if (errorBadge != null && errorBadge.parent != null) { errorBadge.Detach(); errorBadge.RemoveFromHierarchy(); errorBadge = null; } } }
public void AttachError(string errString) { ClearError(); var badge = IconBadge.CreateError(errString); Add(badge); var myTitle = this.Q("title"); badge.AttachTo(myTitle, SpriteAlignment.RightCenter); }
public void AttachMessage(string errString, ShaderCompilerMessageSeverity severity) { ClearMessage(); IconBadge badge; badge = IconBadge.CreateComment(errString); Add(badge); badge.AttachTo(outputContainer, SpriteAlignment.RightCenter); }
public void AttachMessage(string errString, ShaderCompilerMessageSeverity severity) { ClearMessage(); IconBadge badge; if (severity == ShaderCompilerMessageSeverity.Error) { badge = IconBadge.CreateError(errString); } else { badge = IconBadge.CreateComment(errString); } Add(badge); badge.AttachTo(m_TitleContainer, SpriteAlignment.RightCenter); }
private static IconBadge GetNotificationItem(Node node, NotificationType type) { string className; switch (type) { case NotificationType.Error: className = NodeErrorNotificationClassName; break; case NotificationType.Info: className = NodeInfoNotificationClassName; break; default: return(null); } var item = node.Q <IconBadge>(null, className); if (item == null) { node.ClearNotifications(); switch (type) { case NotificationType.Error: item = IconBadge.CreateError(string.Empty); break; case NotificationType.Info: item = IconBadge.CreateComment(string.Empty); break; } item.AddToClassList(NodeNotificationClassName); item.AddToClassList(className); node.Add(item); item.AttachTo(node.titleContainer, UnityEngine.SpriteAlignment.RightCenter); } return(item); }
public static void ShowErrorBadge( this IBadgeContainer self, VisualElement parent, SpriteAlignment alignment, string description, Store store, CompilerQuickFix errorQuickFix ) { Assert.IsNotNull(parent); Assert.IsTrue(self is VisualElement); var target = (VisualElement)self; if (self.ErrorBadge?.parent == null) { var message = description; if (errorQuickFix != null) { message += $"\r\nQuick fix: {errorQuickFix.description}"; } self.ErrorBadge = IconBadge.CreateError(message); parent.Add(self.ErrorBadge); self.ErrorBadge.AttachTo(target, alignment); target.EnableInClassList(k_HasErrorBadge, true); if (errorQuickFix != null) { self.ErrorBadge.RegisterCallback <MouseDownEvent>(e => errorQuickFix.quickFix(store)); } return; } self.ErrorBadge.AttachTo(target, alignment); }
void UpdateData() { title = modelNode.fieldName; if (modelNode.field == null) { if (panel != null) { if (m_ErrorBadge == null) { m_ErrorBadge = IconBadge.CreateError("Field not found"); } if (m_ErrorBadge.parent == null) { parent.Add(m_ErrorBadge); m_ErrorBadge.AttachTo(this, SpriteAlignment.TopCenter); } } icon = null; } else { icon = modelNode.field.exposed ? GraphViewStaticBridge.LoadIconRequired("GraphView/Nodes/BlackboardFieldExposed.png") : null; if (m_ErrorBadge == null) { m_ErrorBadge = IconBadge.CreateError("Field not found"); } if (m_ErrorBadge != null && m_ErrorBadge.parent != null) { m_ErrorBadge.Detach(); m_ErrorBadge.RemoveFromHierarchy(); } } }
static void AttachNote(VisualElement target, IconBadge note, SpriteAlignment align) { VisualElement originalTarget = target; VisualElement noteParent = target.GetFirstOfType <Node>(); if (noteParent is StackNode) { noteParent = noteParent.parent; } else if (noteParent == null) { noteParent = target.parent; } if (target is Node) { var node = target as Node; target = node.mainContainer; if (target == null) { target = node; noteParent = target.parent; } } noteParent.Add(note); note.AttachTo(target, align); note.style.position = Position.Absolute; note.AddManipulator(new Clickable(() => { note.Detach(); note.RemoveFromHierarchy(); })); }
void AddBadge(IconBadge badge) { Add(badge); badges.Add(badge); badge.AttachTo(topContainer, SpriteAlignment.TopRight); }
public void Initialize(AbstractMaterialNode inNode, PreviewManager previewManager, IEdgeConnectorListener connectorListener) { AddStyleSheetPath("Styles/MaterialNodeView"); AddToClassList("MaterialNode"); if (inNode == null) { return; } var contents = this.Q("contents"); m_ConnectorListener = connectorListener; node = inNode; persistenceKey = node.guid.ToString(); UpdateTitle(); // Add controls container var controlsContainer = new VisualElement { name = "controls" }; { m_ControlsDivider = new VisualElement { name = "divider" }; m_ControlsDivider.AddToClassList("horizontal"); controlsContainer.Add(m_ControlsDivider); m_ControlItems = new VisualElement { name = "items" }; controlsContainer.Add(m_ControlItems); // Instantiate control views from node foreach (var propertyInfo in node.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { foreach (IControlAttribute attribute in propertyInfo.GetCustomAttributes(typeof(IControlAttribute), false)) { m_ControlItems.Add(attribute.InstantiateControl(node, propertyInfo)); } } } if (m_ControlItems.childCount > 0) { contents.Add(controlsContainer); } if (node.hasPreview) { // Add actual preview which floats on top of the node m_PreviewContainer = new VisualElement { name = "previewContainer", clippingOptions = ClippingOptions.ClipAndCacheContents, pickingMode = PickingMode.Ignore }; m_PreviewImage = new Image { name = "preview", pickingMode = PickingMode.Ignore, image = Texture2D.whiteTexture, }; { // Add preview collapse button on top of preview var collapsePreviewButton = new VisualElement { name = "collapse" }; collapsePreviewButton.Add(new VisualElement { name = "icon" }); collapsePreviewButton.AddManipulator(new Clickable(() => { node.owner.owner.RegisterCompleteObjectUndo("Collapse Preview"); UpdatePreviewExpandedState(false); })); m_PreviewImage.Add(collapsePreviewButton); } m_PreviewContainer.Add(m_PreviewImage); // Hook up preview image to preview manager m_PreviewRenderData = previewManager.GetPreview(inNode); m_PreviewRenderData.onPreviewChanged += UpdatePreviewTexture; UpdatePreviewTexture(); // Add fake preview which pads out the node to provide space for the floating preview m_PreviewFiller = new VisualElement { name = "previewFiller" }; m_PreviewFiller.AddToClassList("expanded"); { var previewDivider = new VisualElement { name = "divider" }; previewDivider.AddToClassList("horizontal"); m_PreviewFiller.Add(previewDivider); var expandPreviewButton = new VisualElement { name = "expand" }; expandPreviewButton.Add(new VisualElement { name = "icon" }); expandPreviewButton.AddManipulator(new Clickable(() => { node.owner.owner.RegisterCompleteObjectUndo("Expand Preview"); UpdatePreviewExpandedState(true); })); m_PreviewFiller.Add(expandPreviewButton); } contents.Add(m_PreviewFiller); UpdatePreviewExpandedState(node.previewExpanded); } // Add port input container, which acts as a pixel cache for all port inputs m_PortInputContainer = new VisualElement { name = "portInputContainer", clippingOptions = ClippingOptions.ClipAndCacheContents, pickingMode = PickingMode.Ignore }; Add(m_PortInputContainer); AddSlots(node.GetSlots <MaterialSlot>()); UpdatePortInputs(); base.expanded = node.drawState.expanded; RefreshExpandedState(); //This should not be needed. GraphView needs to improve the extension api here UpdatePortInputVisibilities(); SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0)); if (node is SubGraphNode) { RegisterCallback <MouseDownEvent>(OnSubGraphDoubleClick); } var masterNode = node as IMasterNode; if (masterNode != null) { if (!masterNode.IsPipelineCompatible(RenderPipelineManager.currentPipeline)) { IconBadge wrongPipeline = IconBadge.CreateError("The current render pipeline is not compatible with this node preview."); Add(wrongPipeline); VisualElement title = this.Q("title"); wrongPipeline.AttachTo(title, SpriteAlignment.LeftCenter); } } m_PortInputContainer.SendToBack(); // Remove this after updated to the correct API call has landed in trunk. ------------ VisualElement m_TitleContainer; VisualElement m_ButtonContainer; m_TitleContainer = this.Q("title"); // ----------------------------------------------------------------------------------- var settings = node as IHasSettings; if (settings != null) { m_NodeSettingsView = new NodeSettingsView(); m_NodeSettingsView.visible = false; Add(m_NodeSettingsView); m_SettingsButton = new VisualElement { name = "settings-button" }; m_SettingsButton.Add(new VisualElement { name = "icon" }); m_Settings = settings.CreateSettingsElement(); m_SettingsButton.AddManipulator(new Clickable(() => { UpdateSettingsExpandedState(); })); // Remove this after updated to the correct API call has landed in trunk. ------------ m_ButtonContainer = new VisualElement { name = "button-container" }; m_ButtonContainer.style.flexDirection = StyleValue <FlexDirection> .Create(FlexDirection.Row); m_ButtonContainer.Add(m_SettingsButton); m_ButtonContainer.Add(m_CollapseButton); m_TitleContainer.Add(m_ButtonContainer); // ----------------------------------------------------------------------------------- //titleButtonContainer.Add(m_SettingsButton); //titleButtonContainer.Add(m_CollapseButton); RegisterCallback <GeometryChangedEvent>(OnGeometryChanged); } }
public void AddBadge(IconBadge badge) { Add(badge); badges.Add(badge); badge.AttachTo(topContainer, SpriteAlignment.RightCenter); }
static public void CreateCommentNote(VisualElement target, SpriteAlignment align) { AttachNote(target, IconBadge.CreateComment(GetMessage("a comment", ref commentMessageCount)), align); }
static public void CreateErrorNote(VisualElement target, SpriteAlignment align) { AttachNote(target, IconBadge.CreateError(GetMessage("an error", ref errorMessageCount)), align); }