SetSize() public method

Change size.
public SetSize ( float wv, float hv ) : void
wv float Width value.
hv float Height value.
return void
Example #1
0
 virtual protected void LayoutModalWaitPane()
 {
     if (_contentArea != null)
     {
         Vector2 pt = _frame.LocalToGlobal(Vector2.zero);
         pt = this.GlobalToLocal(pt);
         _modalWaitPane.SetXY((int)pt.x + _contentArea.x, (int)pt.y + _contentArea.y);
         _modalWaitPane.SetSize(_contentArea.width, _contentArea.height);
     }
     else
     {
         _modalWaitPane.SetSize(this.width, this.height);
     }
 }
Example #2
0
        private void SetErrorState()
        {
            if (!showErrorSign || !Application.isPlaying)
            {
                return;
            }

            if (_errorSign == null)
            {
                if (UIConfig.loaderErrorSign != null)
                {
                    if (errorSignPool == null)
                    {
                        errorSignPool = new GObjectPool(Stage.inst.CreatePoolManager("LoaderErrorSignPool"));
                    }

                    _errorSign = errorSignPool.GetObject(UIConfig.loaderErrorSign);
                }
                else
                {
                    return;
                }
            }

            if (_errorSign != null)
            {
                _errorSign.SetSize(this.width, this.height);
                ((Container)displayObject).AddChild(_errorSign.displayObject);
            }
        }
Example #3
0
        private void SetErrorState()
        {
            if (!showErrorSign || !Application.isPlaying)
            {
                return;
            }

            if (_errorSign == null)
            {
                if (UIConfig.loaderErrorSign != null)
                {
                    _errorSign = UIPackage.CreateObjectFromURL(UIConfig.loaderErrorSign);
                }
                else
                {
                    return;
                }
            }

            if (_errorSign != null)
            {
                _errorSign.SetSize(this.width, this.height);
                ((Container)displayObject).AddChild(_errorSign.displayObject);
            }
        }
Example #4
0
        private void SetErrorState()
        {
            if (!showErrorSign)
            {
                return;
            }

            if (_errorSign == null)
            {
                if (UIConfig.loaderErrorSign != null)
                {
                    if (errorSignPool == null)
                    {
                        errorSignPool = new GObjectPool();
                    }

                    _errorSign = errorSignPool.GetObject(UIConfig.loaderErrorSign);
                }
                else
                {
                    return;
                }
            }

            if (_errorSign != null)
            {
                _errorSign.SetSize(this.width, this.height);
                ((Container)displayObject).AddChild(_errorSign.displayObject);
            }
        }
Example #5
0
        /// <summary>
        /// Display a modal layer and a waiting sign in the front.
        /// 显示一个半透明层和一个等待标志在最前面。半透明层的颜色可以通过UIConfig.modalLayerColor设定。
        /// 等待标志的资源可以通过UIConfig.globalModalWaiting。等待标志组件会设置为屏幕大小,请内部做好关联。
        /// </summary>
        public void ShowModalWait()
        {
            if (UIConfig.globalModalWaiting != null)
            {
                if (_modalWaitPane == null)
                {
                    _modalWaitPane = UIPackage.CreateObjectFromURL(UIConfig.globalModalWaiting);
                }
                _modalWaitPane.SetSize(this.width, this.height);
                _modalWaitPane.AddRelation(this, RelationType.Size);

                AddChild(_modalWaitPane);
            }
        }
Example #6
0
        /// <summary>
        /// Replace this object to another object in the display list.
        /// 在显示列表中,将指定对象取代这个图形对象。这个图形对象相当于一个占位的用途。
        /// </summary>
        /// <param name="target">Target object.</param>
        public void ReplaceMe(GObject target)
        {
            if (parent == null)
            {
                throw new Exception("parent not set");
            }

            target.name      = this.name;
            target.alpha     = this.alpha;
            target.rotation  = this.rotation;
            target.visible   = this.visible;
            target.touchable = this.touchable;
            target.grayed    = this.grayed;
            target.SetXY(this.x, this.y);
            target.SetSize(this.width, this.height);

            int index = parent.GetChildIndex(this);

            parent.AddChildAt(target, index);
            target.relations.CopyFrom(this.relations);

            parent.RemoveChild(this, true);
        }
Example #7
0
        internal void ResizeChildren(float dw, float dh)
        {
            if (_layout == GroupLayoutType.None || (_updating & 2) != 0 || parent == null)
            {
                return;
            }

            _updating |= 2;

            if (_boundsChanged)
            {
                _boundsChanged = false;
                if (!_autoSizeDisabled)
                {
                    UpdateBounds();
                    return;
                }
            }

            int cnt = parent.numChildren;

            if (!_percentReady)
            {
                _percentReady   = true;
                _numChildren    = 0;
                _totalSize      = 0;
                _mainChildIndex = -1;

                int j = 0;
                for (int i = 0; i < cnt; i++)
                {
                    GObject child = parent.GetChildAt(i);
                    if (child.group != this)
                    {
                        continue;
                    }

                    if (!_excludeInvisibles || child.internalVisible3)
                    {
                        if (j == _mainGridIndex)
                        {
                            _mainChildIndex = i;
                        }

                        _numChildren++;

                        if (_layout == GroupLayoutType.Horizontal)
                        {
                            _totalSize += child.width;
                        }
                        else
                        {
                            _totalSize += child.height;
                        }
                    }

                    j++;
                }

                if (_mainChildIndex != -1)
                {
                    if (_layout == GroupLayoutType.Horizontal)
                    {
                        GObject child = parent.GetChildAt(_mainChildIndex);
                        _totalSize += _mainGridMinSize - child.width;
                        child._sizePercentInGroup = _mainGridMinSize / _totalSize;
                    }
                    else
                    {
                        GObject child = parent.GetChildAt(_mainChildIndex);
                        _totalSize += _mainGridMinSize - child.height;
                        child._sizePercentInGroup = _mainGridMinSize / _totalSize;
                    }
                }

                for (int i = 0; i < cnt; i++)
                {
                    GObject child = parent.GetChildAt(i);
                    if (child.group != this)
                    {
                        continue;
                    }

                    if (i == _mainChildIndex)
                    {
                        continue;
                    }

                    if (_totalSize > 0)
                    {
                        child._sizePercentInGroup = (_layout == GroupLayoutType.Horizontal ? child.width : child.height) / _totalSize;
                    }
                    else
                    {
                        child._sizePercentInGroup = 0;
                    }
                }
            }

            float remainSize    = 0;
            float remainPercent = 1;
            bool  priorHandled  = false;

            if (_layout == GroupLayoutType.Horizontal)
            {
                remainSize = this.width - (_numChildren - 1) * _columnGap;
                if (_mainChildIndex != -1 && remainSize >= _totalSize)
                {
                    GObject child = parent.GetChildAt(_mainChildIndex);
                    child.SetSize(remainSize - (_totalSize - _mainGridMinSize), child._rawHeight + dh, true);
                    remainSize    -= child.width;
                    remainPercent -= child._sizePercentInGroup;
                    priorHandled   = true;
                }

                float curX = this.x;
                for (int i = 0; i < cnt; i++)
                {
                    GObject child = parent.GetChildAt(i);
                    if (child.group != this)
                    {
                        continue;
                    }

                    if (_excludeInvisibles && !child.internalVisible3)
                    {
                        child.SetSize(child._rawWidth, child._rawHeight + dh, true);
                        continue;
                    }

                    if (!priorHandled || i != _mainChildIndex)
                    {
                        child.SetSize(Mathf.Round(child._sizePercentInGroup / remainPercent * remainSize), child._rawHeight + dh, true);
                        remainPercent -= child._sizePercentInGroup;
                        remainSize    -= child.width;
                    }

                    child.xMin = curX;
                    if (child.width != 0)
                    {
                        curX += child.width + _columnGap;
                    }
                }
            }
            else
            {
                remainSize = this.height - (_numChildren - 1) * _lineGap;
                if (_mainChildIndex != -1 && remainSize >= _totalSize)
                {
                    GObject child = parent.GetChildAt(_mainChildIndex);
                    child.SetSize(child._rawWidth + dw, remainSize - (_totalSize - _mainGridMinSize), true);
                    remainSize    -= child.height;
                    remainPercent -= child._sizePercentInGroup;
                    priorHandled   = true;
                }

                float curY = this.y;
                for (int i = 0; i < cnt; i++)
                {
                    GObject child = parent.GetChildAt(i);
                    if (child.group != this)
                    {
                        continue;
                    }

                    if (_excludeInvisibles && !child.internalVisible3)
                    {
                        child.SetSize(child._rawWidth + dw, child._rawHeight, true);
                        continue;
                    }

                    if (!priorHandled || i != _mainChildIndex)
                    {
                        child.SetSize(child._rawWidth + dw, Mathf.Round(child._sizePercentInGroup / remainPercent * remainSize), true);
                        remainPercent -= child._sizePercentInGroup;
                        remainSize    -= child.height;
                    }

                    child.yMin = curY;
                    if (child.height != 0)
                    {
                        curY += child.height + _lineGap;
                    }
                }
            }

            _updating &= 1;
        }
Example #8
0
        void ApplyOnSizeChanged(RelationDef info)
        {
            float targetX, targetY;

            if (_target != _owner.parent)
            {
                targetX = _target.x;
                targetY = _target.y;
            }
            else
            {
                targetX = 0;
                targetY = 0;
            }
            float v, tmp;

            switch (info.type)
            {
            case RelationType.Left_Left:
                break;

            case RelationType.Left_Center:
                v = _owner.x - (targetX + _targetData.z / 2);
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                _owner.x = targetX + _target._rawWidth / 2 + v;
                break;

            case RelationType.Left_Right:
                v = _owner.x - (targetX + _targetData.z);
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                _owner.x = targetX + _target._rawWidth + v;
                break;

            case RelationType.Center_Center:
                v = _owner.x + _owner._rawWidth / 2 - (targetX + _targetData.z / 2);
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                _owner.x = targetX + _target._rawWidth / 2 + v - _owner._rawWidth / 2;
                break;

            case RelationType.Right_Left:
                v = _owner.x + _owner._rawWidth - targetX;
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                _owner.x = targetX + v - _owner._rawWidth;
                break;

            case RelationType.Right_Center:
                v = _owner.x + _owner._rawWidth - (targetX + _targetData.z / 2);
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                _owner.x = targetX + _target._rawWidth / 2 + v - _owner._rawWidth;
                break;

            case RelationType.Right_Right:
                v = _owner.x + _owner._rawWidth - (targetX + _targetData.z);
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                _owner.x = targetX + _target._rawWidth + v - _owner._rawWidth;
                break;

            case RelationType.Top_Top:
                break;

            case RelationType.Top_Middle:
                v = _owner.y - (targetY + _targetData.w / 2);
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                _owner.y = targetY + _target._rawHeight / 2 + v;
                break;

            case RelationType.Top_Bottom:
                v = _owner.y - (targetY + _targetData.w);
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                _owner.y = targetY + _target._rawHeight + v;
                break;

            case RelationType.Middle_Middle:
                v = _owner.y + _owner._rawHeight / 2 - (targetY + _targetData.w / 2);
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                _owner.y = targetY + _target._rawHeight / 2 + v - _owner._rawHeight / 2;
                break;

            case RelationType.Bottom_Top:
                v = _owner.y + _owner._rawHeight - targetY;
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                _owner.y = targetY + v - _owner._rawHeight;
                break;

            case RelationType.Bottom_Middle:
                v = _owner.y + _owner._rawHeight - (targetY + _targetData.w / 2);
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                _owner.y = targetY + _target._rawHeight / 2 + v - _owner._rawHeight;
                break;

            case RelationType.Bottom_Bottom:
                v = _owner.y + _owner._rawHeight - (targetY + _targetData.w);
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                _owner.y = targetY + _target._rawHeight + v - _owner._rawHeight;
                break;

            case RelationType.Width:
                if (_owner.underConstruct && _owner == _target.parent)
                {
                    v = _owner.sourceWidth - _target.initWidth;
                }
                else
                {
                    v = _owner._rawWidth - _targetData.z;
                }
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                if (_target == _owner.parent)
                {
                    _owner.SetSize(_target._rawWidth + v, _owner._rawHeight, true);
                }
                else
                {
                    _owner.width = _target._rawWidth + v;
                }
                break;

            case RelationType.Height:
                if (_owner.underConstruct && _owner == _target.parent)
                {
                    v = _owner.sourceHeight - _target.initHeight;
                }
                else
                {
                    v = _owner._rawHeight - _targetData.w;
                }
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                if (_target == _owner.parent)
                {
                    _owner.SetSize(_owner._rawWidth, _target._rawHeight + v, true);
                }
                else
                {
                    _owner.height = _target._rawHeight + v;
                }
                break;

            case RelationType.LeftExt_Left:
                break;

            case RelationType.LeftExt_Right:
                v = _owner.x - (targetX + _targetData.z);
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                tmp          = _owner.x;
                _owner.x     = targetX + _target._rawWidth + v;
                _owner.width = _owner._rawWidth - (_owner.x - tmp);
                break;

            case RelationType.RightExt_Left:
                break;

            case RelationType.RightExt_Right:
                if (_owner.underConstruct && _owner == _target.parent)
                {
                    v = _owner.sourceWidth - (targetX + _target.initWidth);
                }
                else
                {
                    v = _owner._rawWidth - (targetX + _targetData.z);
                }
                if (_owner != _target.parent)
                {
                    v += _owner.x;
                }
                if (info.percent)
                {
                    v = (int)(v / _targetData.z * _target._rawWidth);
                }
                if (_owner != _target.parent)
                {
                    _owner.width = targetX + _target._rawWidth + v - _owner.x;
                }
                else
                {
                    _owner.width = targetX + _target._rawWidth + v;
                }
                break;

            case RelationType.TopExt_Top:
                break;

            case RelationType.TopExt_Bottom:
                v = _owner.y - (targetY + _targetData.w);
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                tmp           = _owner.y;
                _owner.y      = targetY + _target._rawHeight + v;
                _owner.height = _owner._rawHeight - (_owner.y - tmp);
                break;

            case RelationType.BottomExt_Top:
                break;

            case RelationType.BottomExt_Bottom:
                if (_owner.underConstruct && _owner == _target.parent)
                {
                    v = _owner.sourceHeight - (targetY + _target.initHeight);
                }
                else
                {
                    v = _owner._rawHeight - (targetY + _targetData.w);
                }
                if (_owner != _target.parent)
                {
                    v += _owner.y;
                }
                if (info.percent)
                {
                    v = (int)(v / _targetData.w * _target._rawHeight);
                }
                if (_owner != _target.parent)
                {
                    _owner.height = targetY + _target._rawHeight + v - _owner.y;
                }
                else
                {
                    _owner.height = targetY + _target._rawHeight + v;
                }
                break;
            }
        }
Example #9
0
        void ApplyOnSizeChanged(RelationDef info)
        {
            float pos = 0, pivot = 0, delta = 0;
            if (info.axis == 0)
            {
                if (_target != _owner.parent)
                {
                    pos = _target.x;
                    if (_target.pivotAsAnchor)
                        pivot = _target.pivotX;
                }

                if (info.percent)
                {
                    if (_targetData.z != 0)
                        delta = _target._width / _targetData.z;
                }
                else
                    delta = _target._width - _targetData.z;
            }
            else
            {
                if (_target != _owner.parent)
                {
                    pos = _target.y;
                    if (_target.pivotAsAnchor)
                        pivot = _target.pivotY;
                }

                if (info.percent)
                {
                    if (_targetData.w != 0)
                        delta = _target._height / _targetData.w;
                }
                else
                    delta = _target._height - _targetData.w;
            }

            float v, tmp;

            switch (info.type)
            {
                case RelationType.Left_Left:
                    if (info.percent)
                        _owner.xMin = pos + (_owner.xMin - pos) * delta;
                    else if (pivot != 0)
                        _owner.x += delta * (-pivot);
                    break;
                case RelationType.Left_Center:
                    if (info.percent)
                        _owner.xMin = pos + (_owner.xMin - pos) * delta;
                    else
                        _owner.x += delta * (0.5f - pivot);
                    break;
                case RelationType.Left_Right:
                    if (info.percent)
                        _owner.xMin = pos + (_owner.xMin - pos) * delta;
                    else
                        _owner.x += delta * (1 - pivot);
                    break;
                case RelationType.Center_Center:
                    if (info.percent)
                        _owner.xMin = pos + (_owner.xMin + _owner._rawWidth * 0.5f - pos) * delta - _owner._rawWidth * 0.5f;
                    else
                        _owner.x += delta * (0.5f - pivot);
                    break;
                case RelationType.Right_Left:
                    if (info.percent)
                        _owner.xMin = pos + (_owner.xMin + _owner._rawWidth - pos) * delta - _owner._rawWidth;
                    else if (pivot != 0)
                        _owner.x += delta * (-pivot);
                    break;
                case RelationType.Right_Center:
                    if (info.percent)
                        _owner.xMin = pos + (_owner.xMin + _owner._rawWidth - pos) * delta - _owner._rawWidth;
                    else
                        _owner.x += delta * (0.5f - pivot);
                    break;
                case RelationType.Right_Right:
                    if (info.percent)
                        _owner.xMin = pos + (_owner.xMin + _owner._rawWidth - pos) * delta - _owner._rawWidth;
                    else
                        _owner.x += delta * (1 - pivot);
                    break;

                case RelationType.Top_Top:
                    if (info.percent)
                        _owner.yMin = pos + (_owner.yMin - pos) * delta;
                    else if (pivot != 0)
                        _owner.y += delta * (-pivot);
                    break;
                case RelationType.Top_Middle:
                    if (info.percent)
                        _owner.yMin = pos + (_owner.yMin - pos) * delta;
                    else
                        _owner.y += delta * (0.5f - pivot);
                    break;
                case RelationType.Top_Bottom:
                    if (info.percent)
                        _owner.yMin = pos + (_owner.yMin - pos) * delta;
                    else
                        _owner.y += delta * (1 - pivot);
                    break;
                case RelationType.Middle_Middle:
                    if (info.percent)
                        _owner.yMin = pos + (_owner.yMin + _owner._rawHeight * 0.5f - pos) * delta - _owner._rawHeight * 0.5f;
                    else
                        _owner.y += delta * (0.5f - pivot);
                    break;
                case RelationType.Bottom_Top:
                    if (info.percent)
                        _owner.yMin = pos + (_owner.yMin + _owner._rawHeight - pos) * delta - _owner._rawHeight;
                    else if (pivot != 0)
                        _owner.y += delta * (-pivot);
                    break;
                case RelationType.Bottom_Middle:
                    if (info.percent)
                        _owner.yMin = pos + (_owner.yMin + _owner._rawHeight - pos) * delta - _owner._rawHeight;
                    else
                        _owner.y += delta * (0.5f - pivot);
                    break;
                case RelationType.Bottom_Bottom:
                    if (info.percent)
                        _owner.yMin = pos + (_owner.yMin + _owner._rawHeight - pos) * delta - _owner._rawHeight;
                    else
                        _owner.y += delta * (1 - pivot);
                    break;

                case RelationType.Width:
                    if (_owner.underConstruct && _owner == _target.parent)
                        v = _owner.sourceWidth - _target.initWidth;
                    else
                        v = _owner._rawWidth - _targetData.z;
                    if (info.percent)
                        v = v * delta;
                    if (_target == _owner.parent)
                    {
                        if (_owner.pivotAsAnchor)
                        {
                            tmp = _owner.xMin;
                            _owner.SetSize(_target._width + v, _owner._rawHeight, true);
                            _owner.xMin = tmp;
                        }
                        else
                            _owner.SetSize(_target._width + v, _owner._rawHeight, true);
                    }
                    else
                        _owner.width = _target._width + v;
                    break;
                case RelationType.Height:
                    if (_owner.underConstruct && _owner == _target.parent)
                        v = _owner.sourceHeight - _target.initHeight;
                    else
                        v = _owner._rawHeight - _targetData.w;
                    if (info.percent)
                        v = v * delta;
                    if (_target == _owner.parent)
                    {
                        if (_owner.pivotAsAnchor)
                        {
                            tmp = _owner.yMin;
                            _owner.SetSize(_owner._rawWidth, _target._height + v, true);
                            _owner.yMin = tmp;
                        }
                        else
                            _owner.SetSize(_owner._rawWidth, _target._height + v, true);
                    }
                    else
                        _owner.height = _target._height + v;
                    break;

                case RelationType.LeftExt_Left:
                    tmp = _owner.xMin;
                    if (info.percent)
                        v = pos + (tmp - pos) * delta - tmp;
                    else
                        v = delta * (-pivot);
                    _owner.width = _owner._rawWidth - v;
                    _owner.xMin = tmp + v;
                    break;
                case RelationType.LeftExt_Right:
                    tmp = _owner.xMin;
                    if (info.percent)
                        v = pos + (tmp - pos) * delta - tmp;
                    else
                        v = delta * (1 - pivot);
                    _owner.width = _owner._rawWidth - v;
                    _owner.xMin = tmp + v;
                    break;
                case RelationType.RightExt_Left:
                    tmp = _owner.xMin;
                    if (info.percent)
                        v = pos + (tmp + _owner._rawWidth - pos) * delta - (tmp + _owner._rawWidth);
                    else
                        v = delta * (-pivot);
                    _owner.width = _owner._rawWidth + v;
                    _owner.xMin = tmp;
                    break;
                case RelationType.RightExt_Right:
                    tmp = _owner.xMin;
                    if (info.percent)
                    {
                        if (_owner == _target.parent)
                        {
                            if (_owner.underConstruct)
                                _owner.width = pos + _target._width - _target._width * pivot +
                                    (_owner.sourceWidth - pos - _target.initWidth + _target.initWidth * pivot) * delta;
                            else
                                _owner.width = pos + (_owner._rawWidth - pos) * delta;
                        }
                        else
                        {
                            v = pos + (tmp + _owner._rawWidth - pos) * delta - (tmp + _owner._rawWidth);
                            _owner.width = _owner._rawWidth + v;
                            _owner.xMin = tmp;
                        }
                    }
                    else
                    {
                        if (_owner == _target.parent)
                        {
                            if (_owner.underConstruct)
                                _owner.width = _owner.sourceWidth + (_target._width - _target.initWidth) * (1 - pivot);
                            else
                                _owner.width = _owner._rawWidth + delta * (1 - pivot);
                        }
                        else
                        {
                            v = delta * (1 - pivot);
                            _owner.width = _owner._rawWidth + v;
                            _owner.xMin = tmp;
                        }
                    }
                    break;
                case RelationType.TopExt_Top:
                    tmp = _owner.yMin;
                    if (info.percent)
                        v = pos + (tmp - pos) * delta - tmp;
                    else
                        v = delta * (-pivot);
                    _owner.height = _owner._rawHeight - v;
                    _owner.yMin = tmp + v;
                    break;
                case RelationType.TopExt_Bottom:
                    tmp = _owner.yMin;
                    if (info.percent)
                        v = pos + (tmp - pos) * delta - tmp;
                    else
                        v = delta * (1 - pivot);
                    _owner.height = _owner._rawHeight - v;
                    _owner.yMin = tmp + v;
                    break;
                case RelationType.BottomExt_Top:
                    tmp = _owner.yMin;
                    if (info.percent)
                        v = pos + (tmp + _owner._rawHeight - pos) * delta - (tmp + _owner._rawHeight);
                    else
                        v = delta * (-pivot);
                    _owner.height = _owner._rawHeight + v;
                    _owner.yMin = tmp;
                    break;
                case RelationType.BottomExt_Bottom:
                    tmp = _owner.yMin;
                    if (info.percent)
                    {
                        if (_owner == _target.parent)
                        {
                            if (_owner.underConstruct)
                                _owner.height = pos + _target._height - _target._height * pivot +
                                    (_owner.sourceHeight - pos - _target.initHeight + _target.initHeight * pivot) * delta;
                            else
                                _owner.height = pos + (_owner._rawHeight - pos) * delta;
                        }
                        else
                        {
                            v = pos + (tmp + _owner._rawHeight - pos) * delta - (tmp + _owner._rawHeight);
                            _owner.height = _owner._rawHeight + v;
                            _owner.yMin = tmp;
                        }
                    }
                    else
                    {
                        if (_owner == _target.parent)
                        {
                            if (_owner.underConstruct)
                                _owner.height = _owner.sourceHeight + (_target._height - _target.initHeight) * (1 - pivot);
                            else
                                _owner.height = _owner._rawHeight + delta * (1 - pivot);
                        }
                        else
                        {
                            v = delta * (1 - pivot);
                            _owner.height = _owner._rawHeight + v;
                            _owner.yMin = tmp;
                        }
                    }
                    break;
            }
        }
Example #10
0
        /// <summary>
        /// Replace this object to another object in the display list.
        /// 在显示列表中,将指定对象取代这个图形对象。这个图形对象相当于一个占位的用途。
        /// </summary>
        /// <param name="target">Target object.</param>
        public void ReplaceMe(GObject target)
        {
            if (parent == null)
                throw new Exception("parent not set");

            target.name = this.name;
            target.alpha = this.alpha;
            target.rotation = this.rotation;
            target.visible = this.visible;
            target.touchable = this.touchable;
            target.grayed = this.grayed;
            target.SetXY(this.x, this.y);
            target.SetSize(this.width, this.height);

            int index = parent.GetChildIndex(this);
            parent.AddChildAt(target, index);
            target.relations.CopyFrom(this.relations);

            parent.RemoveChild(this, true);
        }