setBounds() public method

Sets the x, y, width, and height.
public setBounds ( float x, float y, float width, float height ) : void
x float The x coordinate.
y float The y coordinate.
width float Width.
height float Height.
return void
Esempio n. 1
0
        public override void layout()
        {
            if (_vertical)
            {
                calculateVertBoundsAndPositions();
            }
            else
            {
                calculateHorizBoundsAndPositions();
            }

            if (_firstWidget != null)
            {
                var firstWidgetBounds = this._firstWidgetBounds;
                _firstWidget.setBounds(firstWidgetBounds.x, firstWidgetBounds.y, firstWidgetBounds.width, firstWidgetBounds.height);

                if (_firstWidget is ILayout)
                {
                    ((ILayout)_firstWidget).validate();
                }
            }

            if (_secondWidget != null)
            {
                var secondWidgetBounds = this._secondWidgetBounds;
                _secondWidget.setBounds(secondWidgetBounds.x, secondWidgetBounds.y, secondWidgetBounds.width, secondWidgetBounds.height);

                if (_secondWidget is ILayout)
                {
                    ((ILayout)_secondWidget).validate();
                }
            }
        }
Esempio n. 2
0
        public override void layout()
        {
            if (sizeInvalid)
            {
                computeSize();
            }

            for (int i = 0, n = children.Count; i < n; i++)
            {
                Element child = children[i];
                child.setBounds(0, 0, width, height);
                if (child is ILayout)
                {
                    ((ILayout)child).validate();
                }
            }
        }
Esempio n. 3
0
        public override void layout()
        {
            if (_element == null)
            {
                return;
            }

            float padLeft = this._padLeft.get(this), padBottom = this._padBottom.get(this);
            float containerWidth = getWidth() - padLeft - _padRight.get(this);
            float containerHeight = getHeight() - padBottom - _padTop.get(this);
            float minWidth = this._minWidthValue.get(_element), minHeight = this._minHeightValue.get(_element);
            float prefWidth = this._prefWidthValue.get(_element), prefHeight = this._prefHeightValue.get(_element);
            float maxWidth = this._maxWidthValue.get(_element), maxHeight = this._maxHeightValue.get(_element);

            float width;

            if (_fillX > 0)
            {
                width = containerWidth * _fillX;
            }
            else
            {
                width = Math.Min(prefWidth, containerWidth);
            }
            if (width < minWidth)
            {
                width = minWidth;
            }
            if (maxWidth > 0 && width > maxWidth)
            {
                width = maxWidth;
            }

            float height;

            if (_fillY > 0)
            {
                height = containerHeight * _fillY;
            }
            else
            {
                height = Math.Min(prefHeight, containerHeight);
            }

            if (height < minHeight)
            {
                height = minHeight;
            }
            if (maxHeight > 0 && height > maxHeight)
            {
                height = maxHeight;
            }

            var x = padLeft;

            if ((_align & AlignInternal.right) != 0)
            {
                x += containerWidth - width;
            }
            else if ((_align & AlignInternal.left) == 0)                // center
            {
                x += (containerWidth - width) / 2;
            }

            float y = padBottom;

            if ((_align & AlignInternal.top) != 0)
            {
                y += containerHeight - height;
            }
            else if ((_align & AlignInternal.bottom) == 0)                // center
            {
                y += (containerHeight - height) / 2;
            }

            if (_round)
            {
                x      = Mathf.round(x);
                y      = Mathf.round(y);
                width  = Mathf.round(width);
                height = Mathf.round(height);
            }

            _element.setBounds(x, y, width, height);
            if (_element is ILayout)
            {
                ((ILayout)_element).validate();
            }
        }