コード例 #1
0
        private void RemovePreview(bool animated)
        {
            if (m_CurrentPreview == null || m_RemovedPreview != null)
            {
                return;
            }

            m_AddAnimation.Stop();

            m_RemovedPreview = m_CurrentPreview;

            if (animated)
            {
                Rect startRect = new Rect(Vector2.zero, m_RemovedPreview.layout.size);
                Rect endRect   = startRect;

                endRect.height             = 0f;
                m_RemoveAnimation.from     = startRect;
                m_RemoveAnimation.to       = endRect;
                m_RemoveAnimation.duration = animationDuration;
                m_RemoveAnimation.Start();
            }
            else
            {
                RemovePreviewHelper();
            }
        }
コード例 #2
0
        private void RemovePreview(bool animated)
        {
            if (m_CurrentPreviews == null || m_RemovedPreviews != null)
            {
                return;
            }

            if (m_AddAnimations != null)
            {
                foreach (ValueAnimation <Rect> addAnimation in m_AddAnimations)
                {
                    addAnimation.Stop();
                }
                m_AddAnimations = null;
            }

            m_RemovedPreviews = m_CurrentPreviews;

            if (animated)
            {
                m_RemoveAnimations = new List <ValueAnimation <Rect> >(m_CurrentPreviews.Count);

                foreach (VisualElement preview in m_RemovedPreviews)
                {
                    Rect startRect = new Rect(Vector2.zero, preview.layout.size);
                    Rect endRect   = startRect;

                    endRect.height = 0f;

                    var removeAnimations = new ValueAnimation <Rect>(this)
                    {
                        from     = startRect,
                        to       = endRect,
                        duration = animationDuration
                    };
                    removeAnimations.valueUpdated += value => UpdatePreviewLayout(preview, value);
                    removeAnimations.finished     += OnRemoveAnimationFinished;
                    removeAnimations.Start();
                    m_RemoveAnimations.Add(removeAnimations);
                }
            }
            else
            {
                RemovePreviewHelper();
            }
        }
コード例 #3
0
        private void AddPreview(IList <VisualElement> previews, int index, bool animated)
        {
            // Update the current preview with the newly added preview
            m_CurrentPreviews = previews;

            foreach (VisualElement preview in m_CurrentPreviews)
            {
                Insert(index++, preview);
            }

            if (animated)
            {
                m_AddAnimations = new List <ValueAnimation <Rect> >(m_CurrentPreviews.Count);

                foreach (VisualElement preview in m_CurrentPreviews)
                {
                    Rect startRect = new Rect(Vector2.zero, preview.layout.size);
                    Rect endRect   = startRect;

                    startRect.height = 0f;

                    var addAnimation = new ValueAnimation <Rect>(this)
                    {
                        from     = startRect,
                        to       = endRect,
                        duration = animationDuration
                    };
                    addAnimation.valueUpdated += value => UpdatePreviewLayout(preview, value);
                    addAnimation.Start();
                    m_AddAnimations.Add(addAnimation);
                }
            }
            else
            {
                foreach (VisualElement currentPreview in m_CurrentPreviews)
                {
                    currentPreview.style.positionType = PositionType.Relative;
                }
            }
        }
コード例 #4
0
        private void AddPreviewHelper(VisualElement preview, int index, bool animated)
        {
            // Update the current preview with the newly added preview
            m_CurrentPreview = preview;

            Insert(index, m_CurrentPreview);

            if (animated)
            {
                Rect startRect = new Rect(Vector2.zero, m_CurrentPreview.layout.size);
                Rect endRect   = startRect;

                startRect.height        = 0f;
                m_AddAnimation.from     = startRect;
                m_AddAnimation.to       = endRect;
                m_AddAnimation.duration = animationDuration;
                m_AddAnimation.Start();
            }
            else
            {
                m_CurrentPreview.style.positionType = PositionType.Relative;
                m_CurrentPreview.Dirty(ChangeType.Layout);
            }
        }