AddNewCurve() static private method

static private AddNewCurve ( AddCurvesPopupPropertyNode node ) : void
node AddCurvesPopupPropertyNode
return void
        private void AddPropertiesFromSelectedNodes()
        {
            int[] ids = m_TreeView.GetSelection();
            for (int i = 0; i < ids.Length; ++i)
            {
                var node         = m_TreeView.FindItem(ids[i]);
                var propertyNode = node as AddCurvesPopupPropertyNode;

                if (propertyNode != null)
                {
                    AddCurvesPopup.AddNewCurve(propertyNode);
                }
                else if (node.hasChildren)
                {
                    foreach (var childNode in node.children)
                    {
                        var childPropertyNode = childNode as AddCurvesPopupPropertyNode;
                        if (childPropertyNode != null)
                        {
                            AddCurvesPopup.AddNewCurve(childPropertyNode);
                        }
                    }
                }
            }

            m_TreeView.ReloadData();
        }
        private void DoAddCurveButton(Rect rowRect, TreeViewItem node)
        {
            // Is it propertynode. If not, then we don't need plusButton so quit here
            AddCurvesPopupPropertyNode hierarchyNode = node as AddCurvesPopupPropertyNode;

            if (hierarchyNode == null || hierarchyNode.curveBindings == null || hierarchyNode.curveBindings.Length == 0)
            {
                return;
            }

            Rect buttonRect = new Rect(rowRect.width - plusButtonWidth, rowRect.yMin, plusButtonWidth, plusButtonStyle.fixedHeight);

            // TODO Make a style for add curves popup
            // Draw background behind plus button to prevent text overlapping
            GUI.Box(buttonRect, GUIContent.none, plusButtonBackgroundStyle);

            // Check if the curve already exists and remove plus button
            if (GUI.Button(buttonRect, GUIContent.none, plusButtonStyle))
            {
                AddCurvesPopup.AddNewCurve(hierarchyNode);

                // Hold shift key to add new curves and keep window opened.
                if (Event.current.shift)
                {
                    m_TreeView.ReloadData();
                }
                else
                {
                    owner.Close();
                }
            }
        }
Example #3
0
        public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
        {
            base.OnRowGUI(rowRect, node, row, selected, focused);

            // Is it propertynode. If not, then we don't need plusButton so quit here
            AddCurvesPopupPropertyNode hierarchyNode = node as AddCurvesPopupPropertyNode;

            if (hierarchyNode == null || hierarchyNode.curveBindings == null || hierarchyNode.curveBindings.Length == 0)
            {
                return;
            }

            Rect buttonRect = new Rect(rowRect.width - plusButtonWidth, rowRect.yMin, plusButtonWidth, plusButtonStyle.fixedHeight);

            // TODO Make a style for add curves popup
            // Draw background behind plus button to prevent text overlapping
            GUI.Box(buttonRect, GUIContent.none, plusButtonBackgroundStyle);

            // Check if the curve already exists and remove plus button
            if (GUI.Button(buttonRect, GUIContent.none, plusButtonStyle))
            {
                AddCurvesPopup.AddNewCurve(hierarchyNode);
                owner.Close();
            }
        }
        public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
        {
            base.OnRowGUI(rowRect, node, row, selected, focused);
            AddCurvesPopupPropertyNode addCurvesPopupPropertyNode = node as AddCurvesPopupPropertyNode;

            if (addCurvesPopupPropertyNode != null && addCurvesPopupPropertyNode.curveBindings != null && addCurvesPopupPropertyNode.curveBindings.Length != 0)
            {
                Rect position = new Rect(rowRect.width - 17f, rowRect.yMin, 17f, this.plusButtonStyle.fixedHeight);
                GUI.Box(position, GUIContent.none, this.plusButtonBackgroundStyle);
                if (GUI.Button(position, GUIContent.none, this.plusButtonStyle))
                {
                    AddCurvesPopup.AddNewCurve(addCurvesPopupPropertyNode);
                    this.owner.Close();
                }
            }
        }
        public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused)
        {
            Rect result   = base.OnRowGUI(node, row, rowWidth, selected, focused);
            Rect position = new Rect(rowWidth - 17f, result.yMin, 17f, this.plusButtonStyle.fixedHeight);
            AddCurvesPopupPropertyNode addCurvesPopupPropertyNode = node as AddCurvesPopupPropertyNode;

            if (addCurvesPopupPropertyNode == null || addCurvesPopupPropertyNode.curveBindings == null || addCurvesPopupPropertyNode.curveBindings.Length == 0)
            {
                return(result);
            }
            GUI.Box(position, GUIContent.none, this.plusButtonBackgroundStyle);
            if (GUI.Button(position, GUIContent.none, this.plusButtonStyle))
            {
                AddCurvesPopup.AddNewCurve(addCurvesPopupPropertyNode);
                this.owner.Close();
                this.m_TreeView.ReloadData();
            }
            return(result);
        }