public static Rect GetCommentResizeRect(GraphComment comment)
        {
            Vector2 size = new Vector2(8, 8);
            Vector2 pos  = new Vector2(comment.Rect.xMax - size.x - 2, comment.Rect.yMax - size.y - 2);

            return(new Rect(pos, size));
        }
 public static void BuildCommentCursorRects(GraphComment comment)
 {
     EditorGUIUtility.AddCursorRect(GetCommentResizeRect(comment), MouseCursor.ResizeUpLeft);
     EditorGUIUtility.AddCursorRect(new Rect(comment.Rect.position, new Vector2(comment.Rect.width, 16)), MouseCursor.Text);
     EditorGUIUtility.AddCursorRect(new Rect(new Vector2(comment.Rect.position.x, comment.Rect.position.y + 16), new Vector2(comment.Rect.width, 6)), MouseCursor.FPS);
     EditorGUIUtility.AddCursorRect(comment.Rect, MouseCursor.MoveArrow);
 }
Example #3
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 GraphComment AddComment()
        {
            GraphComment comment = new GraphComment();

            comment.AssignToGraph(this);
            comments.Add(comment);
            return(comment);
        }
Example #5
0
        public void CreateComment(Vector2 position)
        {
            GraphComment comment = Graph.AddComment();

            comment.SetSize(new Vector2(200, 150));
            comment.SetPosition(position - comment.Rect.size * 0.5f);
            EditorUtility.SetDirty(Graph);
        }
        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);
        }
 public void RemoveComment(GraphComment comment)
 {
     comments.Remove(comment);
 }