InternalSetParent() private method

private InternalSetParent ( GComponent value ) : void
value GComponent
return void
Example #1
0
        override public void Dispose()
        {
            int cnt = _transitions.Count;

            for (int i = 0; i < cnt; ++i)
            {
                Transition trans = _transitions[i];
                trans.Dispose();
            }

            cnt = _controllers.Count;
            for (int i = 0; i < cnt; ++i)
            {
                Controller c = _controllers[i];
                c.Dispose();
            }

            if (scrollPane != null)
            {
                scrollPane.Dispose();
            }

            base.Dispose();             //Dispose native tree first, avoid DisplayObject.RemoveFromParent call

            cnt = _children.Count;
            for (int i = cnt - 1; i >= 0; --i)
            {
                GObject obj = _children[i];
                obj.InternalSetParent(null);                 //Avoid GObject.RemoveParent call
                obj.Dispose();
            }
        }
Example #2
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);
            }
        }
        override public void Dispose()
        {
            int transCnt = _transitions.Count;

            for (int i = 0; i < transCnt; ++i)
            {
                Transition trans = _transitions[i];
                trans.Dispose();
            }

            base.Dispose();             //Dispose native tree first, avoid DisplayObject.RemoveFromParent call

            int numChildren = _children.Count;

            for (int i = numChildren - 1; i >= 0; --i)
            {
                GObject obj = _children[i];
                obj.InternalSetParent(null);                 //Avoid GObject.RemoveParent call
                obj.Dispose();
            }
        }
Example #4
0
        /// <summary>
        /// Removes a child at a certain index. Children above the child will move down.
        /// </summary>
        /// <param name="index">Index</param>
        /// <param name="dispose">If true, the child will be disposed right away.</param>
        /// <returns>GObject</returns>
        virtual public GObject RemoveChildAt(int index, bool dispose)
        {
            if (index >= 0 && index < numChildren)
            {
                GObject child = _children[index];

                child.InternalSetParent(null);

                if (child.sortingOrder != 0)
                {
                    _sortingChildCount--;
                }

                _children.RemoveAt(index);
                child.group = null;
                if (child.inContainer)
                {
                    container.RemoveChild(child.displayObject);
                    if (_childrenRenderOrder == ChildrenRenderOrder.Arch)
                    {
                        Stage.beforeUpdate -= _buildDelegate;
                        Stage.beforeUpdate += _buildDelegate;
                    }
                }

                if (dispose)
                {
                    child.Dispose();
                }

                SetBoundsChangedFlag();
                return(child);
            }
            else
            {
                throw new Exception("Invalid child index: " + index + ">" + numChildren);
            }
        }
Example #5
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>
        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.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();
                }
                return child;
            }
            else
            {
                throw new Exception("Invalid child index: " + index + ">" + numChildren);
            }
        }