Example #1
0
 public static void DrawComment(GraphComment comment)
 {
     Handles.DrawSolidRectangleWithOutline(comment.Rect, comment.Color, new Color(1, 1, 1, 0.5f));
     comment.Comment = GUI.TextField(new Rect(comment.Rect.position, new Vector2(comment.Rect.width, 16)), comment.Comment);
     comment.Color   = EditorGUI.ColorField(new Rect(new Vector2(comment.Rect.position.x, comment.Rect.position.y + 16), new Vector2(comment.Rect.width, 6)), GUIContent.none, comment.Color, false, false, false);
     GUI.Box(TerraUtility.GetCommentResizeRect(comment), GUIContent.none);
 }
        public static void ProcessCommentEvent(Event e, GraphComment comment)
        {
            switch (e.type)
            {
            case EventType.MouseDown:

                if (e.button == 0)
                {
                    if (TerraUtility.GetCommentResizeRect(comment).Contains(e.mousePosition))
                    {
                        TerraGraphEditor.CommentSelection.Clear();
                        TerraGraphEditor.NodeSelection.Clear();
                        TerraGraphEditor.ResizingComment = comment;
                        GUI.FocusControl(null);
                        e.Use();
                    }

                    else if (comment.Rect.Contains(e.mousePosition))
                    {
                        if (!TerraGraphEditor.CommentSelection.Contains(comment))
                        {
                            if (!e.shift)
                            {
                                TerraGraphEditor.CommentSelection.Clear();
                                TerraGraphEditor.NodeSelection.Clear();
                            }

                            TerraGraphEditor.CommentSelection.Add(comment);
                        }
                        else
                        {
                            if (e.shift)
                            {
                                TerraGraphEditor.CommentSelection.Remove(comment);
                            }
                        }

                        GUI.FocusControl(null);
                        e.Use();
                    }
                }

                if (e.button == 1)
                {
                    if (comment.Rect.Contains(e.mousePosition))
                    {
                        TerraGraphEditor.NodeSelection.Clear();
                        TerraGraphEditor.CommentSelection.Clear();

                        GenericMenu contextMenu = TerraUtility.CreateNodeContextMenu((t) => TerraGraphEditor.Window.CreateNode(t, e.mousePosition));
                        contextMenu.AddSeparator("");
                        contextMenu.AddItem(new GUIContent("Remove Comment"), false, () => TerraGraphEditor.Graph.RemoveComment(comment));
                        contextMenu.ShowAsContext();

                        e.Use();
                    }
                }

                break;
            }

            TerraUtility.BuildCommentCursorRects(comment);
        }