RemoveFromParent() public method

public RemoveFromParent ( ) : void
return void
Exemplo n.º 1
0
        /// <summary>
        /// Adds a child to the component at a certain index.
        /// </summary>
        /// <param name="child">A child object</param>
        /// <param name="index">Index</param>
        /// <returns>GObject</returns>
        virtual public GObject AddChildAt(GObject child, int index)
        {
            int numChildren = _children.Count;

            if (index >= 0 && index <= numChildren)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    child.InternalSetParent(this);

                    int cnt = _children.Count;
                    if (child.sortingOrder != 0)
                    {
                        _sortingChildCount++;
                        index = GetInsertPosForSortingChild(child);
                    }
                    else if (_sortingChildCount > 0)
                    {
                        if (index > (cnt - _sortingChildCount))
                        {
                            index = cnt - _sortingChildCount;
                        }
                    }

                    if (index == cnt)
                    {
                        _children.Add(child);
                    }
                    else
                    {
                        _children.Insert(index, child);
                    }

                    ChildStateChanged(child);
                    SetBoundsChangedFlag();
                    if (child.group != null)
                    {
                        child.group.SetBoundsChangedFlag(true);
                    }
                }
                return(child);
            }
            else
            {
                throw new Exception("Invalid child index: " + index + ">" + numChildren);
            }
        }
Exemplo n.º 2
0
        virtual public GObject AddChildAt(GObject child, int index)
        {
            int numChildren = _children.Count;

            if (index >= 0 && index <= numChildren)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    child.parent = this;

                    int cnt = _children.Count;
                    if (child.alwaysOnTop != 0)
                    {
                        _AOTChildCount++;
                        index = GetInsertPosForAOTChild(child);
                    }
                    else if (_AOTChildCount > 0)
                    {
                        if (index > (cnt - _AOTChildCount))
                        {
                            index = cnt - _AOTChildCount;
                        }
                    }

                    if (index == cnt)
                    {
                        _children.Add(child);
                    }
                    else
                    {
                        _children.Insert(index, child);
                    }

                    ChildStateChanged(child);
                    SetBoundsChangedFlag();
                }
                return(child);
            }
            else
            {
                throw new Exception("Invalid child index: " + index + ">" + numChildren);
            }
        }
Exemplo n.º 3
0
        public virtual GObject AddChildAt(GObject child, int index)
        {
            int numChildren = _children.Count;

            if (index >= 0 && index <= numChildren)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    child.parent = this;

                    int cnt = _children.Count;
                    if (child.alwaysOnTop != 0)
                    {
                        _AOTChildCount++;
                        index = GetInsertPosForAOTChild(child);
                    }
                    else if (_AOTChildCount > 0)
                    {
                        if (index > (cnt - _AOTChildCount))
                            index = cnt - _AOTChildCount;
                    }

                    if (index == cnt)
                        _children.Add(child);
                    else
                        _children.Insert(index, child);

                    ChildStateChanged(child);
                    SetBoundsChangedFlag();
                }
                return child;
            }
            else
            {
                throw new Exception("Invalid child index: " + index + ">" + numChildren);
            }
        }