예제 #1
0
        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, buttonStyle.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, plusIcon, buttonStyle))
            {
                AddCurvesPopup.AddNewCurve(hierarchyNode);

                // Hold shift key to add new curves and keep window opened.
                if (Event.current.shift)
                {
                    m_TreeView.ReloadData();
                }
                else
                {
                    owner.Close();
                }
            }
        }
예제 #2
0
        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();
        }
예제 #3
0
 void OnDisable()
 {
     AssemblyReloadEvents.beforeAssemblyReload -= Close;
     s_LastClosedTime = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
     s_AddCurvesPopup = null;
     s_Hierarchy      = null;
 }
예제 #4
0
        internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state, OnNewCurveAdded newCurveCallback)
        {
            // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
            long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
            bool justClosed      = nowMilliSeconds < s_LastClosedTime + 50;

            if (!justClosed)
            {
                Event.current.Use();
                if (s_AddCurvesPopup == null)
                {
                    s_AddCurvesPopup = ScriptableObject.CreateInstance <AddCurvesPopup>();
                }

                NewCurveAddedCallback = newCurveCallback;
                s_State = state;
                s_AddCurvesPopup.Init(buttonRect);
                return(true);
            }
            return(false);
        }
        private void DoAddCurveButton(Rect rect, AnimationWindowHierarchyNode node, int row)
        {
            const int k_ButtonWidth = 230;
            float     xMargin       = (rect.width - k_ButtonWidth) / 2f;
            float     yMargin       = 10f;

            Rect rectWithMargin = new Rect(rect.xMin + xMargin, rect.yMin + yMargin, rect.width - xMargin * 2f, rect.height - yMargin * 2f);

            // case 767863.
            // This control id is unique to the hierarchy node it refers to.
            // The tree view only renders the elements that are visible, and will cause
            // the control id counter to shift when scrolling through the view.
            if (DoTreeViewButton(m_HierarchyItemButtonControlIDs[row], rectWithMargin, k_AnimatePropertyLabel, GUI.skin.button))
            {
                AddCurvesPopupHierarchyDataSource.showEntireHierarchy = true;

                if (AddCurvesPopup.ShowAtPosition(rectWithMargin, state, OnNewCurveAdded))
                {
                    GUIUtility.ExitGUI();
                }
            }
        }