Esempio n. 1
0
 /// <summary>
 /// Append views for comments from a Graph
 /// </summary>
 private void AddComments(List <GraphComment> comments)
 {
     foreach (var comment in comments)
     {
         var commentView = new CommentView(comment);
         AddElement(commentView);
         Dirty(commentView);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Add a new comment to the canvas and the associated Graph
        ///
        /// If there are selected nodes, this'll encapsulate the selection with
        /// the comment box. Otherwise, it'll add at defaultPosition.
        /// </summary>
        private void AddComment()
        {
            // Pad out the bounding box a bit more on the selection
            float padding = 30; // TODO: Remove hardcoding

            Rect bounds = GetBounds(selection);

            if (bounds.width < 1 || bounds.height < 1)
            {
                Vector2 worldPosition = contentViewContainer.WorldToLocal(m_LastMousePosition);
                bounds.x = worldPosition.x;
                bounds.y = worldPosition.y;

                // TODO: For some reason CSS minWidth/minHeight isn't being respected.
                // Maybe I need to wait for CSS to load before setting bounds?
                bounds.width  = 150 - padding * 2;
                bounds.height = 100 - padding * 3;
            }

            bounds.x      -= padding;
            bounds.y      -= padding * 2;
            bounds.width  += padding * 2;
            bounds.height += padding * 3;

            var comment = new GraphComment();

            comment.title    = "New Comment";
            comment.position = bounds;

            var commentView = new CommentView(comment);

            commentView.onResize += Dirty;


            m_Graph.comments.Add(comment);
            m_CommentViews.Add(commentView);
            AddElement(commentView);

            Dirty(commentView);
        }
Esempio n. 3
0
 public void DestroyComment(CommentView comment)
 {
     m_CommentViews.Remove(comment);
     m_Graph.comments.Remove(comment.target);
 }