Reflow() private method

private Reflow ( ) : void
return void
示例#1
0
 internal virtual void Reflow()
 {
     View[] children = this.children;
     for (int i = 0; i < children.Length; i++)
     {
         View view = children[i];
         view.Reflow();
     }
 }
        /// clean up this view & propagate down
        public void Cleanup()
        {
            // if I'm a one-view splitview, I can propagate my child up and kill myself

            SplitView sp = parent as SplitView;

            if (children.Length == 1 && sp != null)
            {
                View c = children[0];
                c.position = position;
                if (parent != null)
                {
                    parent.AddChild(c, parent.IndexOfChild(this));
                    parent.RemoveChild(this);
                    if (sp)
                    {
                        sp.Cleanup();
                    }
                    c.position = position;
                    if (!Unsupported.IsDestroyScriptableObject(this))
                    {
                        DestroyImmediate(this);
                    }
                    return;
                }
                else if (c is SplitView)
                {
                    RemoveChild(c);
                    window.rootView = c;
                    c.position      = new Rect(0, 0, c.window.position.width, window.position.height);
                    c.Reflow();
                    if (!Unsupported.IsDestroyScriptableObject(this))
                    {
                        DestroyImmediate(this);
                    }
                    return;
                }
            }

            if (sp)
            {
                sp.Cleanup();
                // the parent might have moved US up and gotten rid of itself
                sp = parent as SplitView;
                if (sp)
                {
                    // If the parent has the same orientation as us, we can move our views up and kill ourselves
                    if (sp.vertical == vertical)
                    {
                        int idx = new List <View>(parent.children).IndexOf(this);
                        foreach (View child in children)
                        {
                            sp.AddChild(child, idx++);
                            child.position = new Rect(position.x + child.position.x, position.y + child.position.y, child.position.width, child.position.height);
                        }
                    }
                }
            }
            if (children.Length == 0)
            {
                if (parent == null && window != null)
                {
                    // if we're root in the window, we'll remove ourselves
                    window.Close();
                }
                else
                {
                    ICleanuppable ic = parent as ICleanuppable;
                    if (parent is SplitView)
                    {
                        ((SplitView)parent).RemoveChildNice(this);
                        if (!Unsupported.IsDestroyScriptableObject(this))
                        {
                            DestroyImmediate(this, true);
                        }
                    }
                    else
                    {
                        // This is we're root in the main window.
                        // We want to stay, but tell the parent (MainWindow) to Cleanup, so he can reduce us to zero-size
                        /*                  parent.RemoveChild (this);*/
                    }
                    ic.Cleanup();
                }
                return;
            }
            else
            {
                splitState = null;
                Reflow();
            }
        }
示例#3
0
        public void Cleanup()
        {
            SplitView parent = base.parent as SplitView;

            if ((base.children.Length == 1) && (parent != null))
            {
                View child = base.children[0];
                child.position = base.position;
                if (base.parent != null)
                {
                    base.parent.AddChild(child, base.parent.IndexOfChild(this));
                    base.parent.RemoveChild(this);
                    if (parent != null)
                    {
                        parent.Cleanup();
                    }
                    child.position = base.position;
                    if (!Unsupported.IsDestroyScriptableObject(this))
                    {
                        UnityEngine.Object.DestroyImmediate(this);
                    }
                    return;
                }
                if (child is SplitView)
                {
                    this.RemoveChild(child);
                    base.window.rootView = child;
                    child.position       = new Rect(0f, 0f, child.window.position.width, base.window.position.height);
                    child.Reflow();
                    if (!Unsupported.IsDestroyScriptableObject(this))
                    {
                        UnityEngine.Object.DestroyImmediate(this);
                    }
                    return;
                }
            }
            if (parent != null)
            {
                parent.Cleanup();
                parent = base.parent as SplitView;
                if ((parent != null) && (parent.vertical == this.vertical))
                {
                    int index = new List <View>(base.parent.children).IndexOf(this);
                    foreach (View view3 in base.children)
                    {
                        parent.AddChild(view3, index++);
                        view3.position = new Rect(base.position.x + view3.position.x, base.position.y + view3.position.y, view3.position.width, view3.position.height);
                    }
                }
            }
            if (base.children.Length == 0)
            {
                if ((base.parent == null) && (base.window != null))
                {
                    base.window.Close();
                }
                else
                {
                    ICleanuppable cleanuppable = base.parent as ICleanuppable;
                    if (base.parent is SplitView)
                    {
                        ((SplitView)base.parent).RemoveChildNice(this);
                        if (!Unsupported.IsDestroyScriptableObject(this))
                        {
                            UnityEngine.Object.DestroyImmediate(this, true);
                        }
                    }
                    cleanuppable.Cleanup();
                }
            }
            else
            {
                this.splitState = null;
                this.Reflow();
            }
        }
示例#4
0
        public void Cleanup()
        {
            SplitView parent1 = this.parent as SplitView;

            if (this.children.Length == 1 && (Object)parent1 != (Object)null)
            {
                View child = this.children[0];
                child.position = this.position;
                if ((Object)this.parent != (Object)null)
                {
                    this.parent.AddChild(child, this.parent.IndexOfChild((View)this));
                    this.parent.RemoveChild((View)this);
                    if ((bool)((Object)parent1))
                    {
                        parent1.Cleanup();
                    }
                    child.position = this.position;
                    if (Unsupported.IsDestroyScriptableObject((ScriptableObject)this))
                    {
                        return;
                    }
                    Object.DestroyImmediate((Object)this);
                    return;
                }
                if (child is SplitView)
                {
                    this.RemoveChild(child);
                    this.window.mainView = child;
                    child.position       = new Rect(0.0f, 0.0f, child.window.position.width, this.window.position.height);
                    child.Reflow();
                    if (Unsupported.IsDestroyScriptableObject((ScriptableObject)this))
                    {
                        return;
                    }
                    Object.DestroyImmediate((Object)this);
                    return;
                }
            }
            if ((bool)((Object)parent1))
            {
                parent1.Cleanup();
                SplitView parent2 = this.parent as SplitView;
                if ((bool)((Object)parent2) && parent2.vertical == this.vertical)
                {
                    int num = new List <View>((IEnumerable <View>) this.parent.children).IndexOf((View)this);
                    foreach (View child in this.children)
                    {
                        parent2.AddChild(child, num++);
                        child.position = new Rect(this.position.x + child.position.x, this.position.y + child.position.y, child.position.width, child.position.height);
                    }
                }
            }
            if (this.children.Length == 0)
            {
                if ((Object)this.parent == (Object)null && (Object)this.window != (Object)null)
                {
                    this.window.Close();
                }
                else
                {
                    ICleanuppable parent2 = this.parent as ICleanuppable;
                    if (this.parent is SplitView)
                    {
                        ((SplitView)this.parent).RemoveChildNice((View)this);
                        if (!Unsupported.IsDestroyScriptableObject((ScriptableObject)this))
                        {
                            Object.DestroyImmediate((Object)this, true);
                        }
                    }
                    parent2.Cleanup();
                }
            }
            else
            {
                this.splitState = (SplitterState)null;
                this.Reflow();
            }
        }
示例#5
0
        public void Cleanup()
        {
            SplitView splitView = base.parent as SplitView;

            if (base.children.Length == 1 && splitView != null)
            {
                View view = base.children[0];
                view.position = base.position;
                if (base.parent != null)
                {
                    base.parent.AddChild(view, base.parent.IndexOfChild(this));
                    base.parent.RemoveChild(this);
                    if (splitView)
                    {
                        splitView.Cleanup();
                    }
                    view.position = base.position;
                    if (!Unsupported.IsDestroyScriptableObject(this))
                    {
                        UnityEngine.Object.DestroyImmediate(this);
                    }
                    return;
                }
                if (view is SplitView)
                {
                    this.RemoveChild(view);
                    base.window.rootView = view;
                    view.position        = new Rect(0f, 0f, view.window.position.width, base.window.position.height);
                    view.Reflow();
                    if (!Unsupported.IsDestroyScriptableObject(this))
                    {
                        UnityEngine.Object.DestroyImmediate(this);
                    }
                    return;
                }
            }
            if (splitView)
            {
                splitView.Cleanup();
                splitView = (base.parent as SplitView);
                if (splitView)
                {
                    if (splitView.vertical == this.vertical)
                    {
                        int    num      = new List <View>(base.parent.children).IndexOf(this);
                        View[] children = base.children;
                        for (int i = 0; i < children.Length; i++)
                        {
                            View view2 = children[i];
                            splitView.AddChild(view2, num++);
                            view2.position = new Rect(base.position.x + view2.position.x, base.position.y + view2.position.y, view2.position.width, view2.position.height);
                        }
                    }
                }
            }
            if (base.children.Length == 0)
            {
                if (base.parent == null && base.window != null)
                {
                    base.window.Close();
                }
                else
                {
                    ICleanuppable cleanuppable = base.parent as ICleanuppable;
                    if (base.parent is SplitView)
                    {
                        ((SplitView)base.parent).RemoveChildNice(this);
                        if (!Unsupported.IsDestroyScriptableObject(this))
                        {
                            UnityEngine.Object.DestroyImmediate(this, true);
                        }
                    }
                    cleanuppable.Cleanup();
                }
            }
            else
            {
                this.splitState = null;
                this.Reflow();
            }
        }