public void UserInputChangedExpandedState(TreeViewItem item, int row, bool expand) { bool alt = Event.current.alt; if (this.useExpansionAnimation) { if (expand) { this.ChangeExpandedState(item, true, alt); } int num = row + 1; int lastChildRowUnder = this.GetLastChildRowUnder(row); float width = GUIClip.visibleRect.width; Rect rectForRows = this.GetRectForRows(num, lastChildRowUnder, width); float animationDuration = this.GetAnimationDuration(rectForRows.height); TreeViewAnimationInput setup = new TreeViewAnimationInput { animationDuration = (double)animationDuration, startRow = num, endRow = lastChildRowUnder, startRowRect = this.gui.GetRowRect(num, width), rowsRect = rectForRows, expanding = expand, includeChildren = alt, animationEnded = new Action <TreeViewAnimationInput>(this.ExpansionAnimationEnded), item = item, treeView = this }; this.expansionAnimator.BeginAnimating(setup); } else { this.ChangeExpandedState(item, expand, alt); } }
public void BeginAnimating(TreeViewAnimationInput setup) { if (this.m_Setup != null) { if (this.m_Setup.item.id == setup.item.id) { if (this.m_Setup.elapsedTime >= 0.0) { setup.elapsedTime = this.m_Setup.animationDuration - this.m_Setup.elapsedTime; } else { Debug.LogError("Invaid duration " + this.m_Setup.elapsedTime); } this.m_Setup = setup; } else { this.m_Setup.FireAnimationEndedEvent(); this.m_Setup = setup; } this.m_Setup.expanding = setup.expanding; } this.m_Setup = setup; if (this.m_Setup == null) { Debug.LogError("Setup is null"); } if (this.printDebug) { Console.WriteLine("Begin animating: " + this.m_Setup); } this.m_CurrentClipRect = this.GetCurrentClippingRect(); }
private void ExpansionAnimationEnded(TreeViewAnimationInput setup) { if (!setup.expanding) { this.ChangeExpandedState(setup.item, false, setup.includeChildren); } }
public void SkipAnimating() { if (this.m_Setup != null) { this.m_Setup.FireAnimationEndedEvent(); this.m_Setup = null; } }
public void SkipAnimating() { if (m_Setup != null) { m_Setup.FireAnimationEndedEvent(); m_Setup = null; } }
public void OnBeforeAllRowsGUI() { if (this.isAnimating) { this.m_CurrentClipRect = this.GetCurrentClippingRect(); if (this.m_Setup.elapsedTime > this.m_Setup.animationDuration) { this.m_Setup.FireAnimationEndedEvent(); this.m_Setup = null; if (this.printDebug) { Debug.Log("Animation ended"); } } } }
public void BeginAnimating(TreeViewAnimationInput setup) { if (m_Setup != null) { if (m_Setup.item.id == setup.item.id && m_Setup.expanding != setup.expanding) { // If same item (changed expand/collapse while animating) then just change direction, but skip the time that already passed if (m_Setup.elapsedTime >= 0) { setup.elapsedTime = m_Setup.animationDuration - m_Setup.elapsedTime; } else { Debug.LogError("Invalid duration " + m_Setup.elapsedTime); } m_Setup = setup; } else { // Ensure current animation ends before starting a new (just finish it immediately) SkipAnimating(); m_Setup = setup; } m_Setup.expanding = setup.expanding; } m_Setup = setup; if (m_Setup == null) { Debug.LogError("Setup is null"); } if (printDebug) { Console.WriteLine("Begin animating: " + m_Setup); } m_CurrentClipRect = GetCurrentClippingRect(); }
public void OnBeforeAllRowsGUI() { if (!isAnimating) { return; } // Cache to ensure consistent across all rows (it is dependant on time) m_CurrentClipRect = GetCurrentClippingRect(); // Stop animation when duration has passed if (m_Setup.elapsedTime > m_Setup.animationDuration) { m_Setup.FireAnimationEndedEvent(); m_Setup = null; if (printDebug) { Debug.Log("Animation ended"); } } }