Example #1
0
        private CalculatedStyle GetDimensionsBasedOnParentDimensions(
            CalculatedStyle parentDimensions)
        {
            CalculatedStyle calculatedStyle;

            calculatedStyle.X = this.Left.GetValue(parentDimensions.Width) + parentDimensions.X;
            calculatedStyle.Y = this.Top.GetValue(parentDimensions.Height) + parentDimensions.Y;
            float min1 = this.MinWidth.GetValue(parentDimensions.Width);
            float max1 = this.MaxWidth.GetValue(parentDimensions.Width);
            float min2 = this.MinHeight.GetValue(parentDimensions.Height);
            float max2 = this.MaxHeight.GetValue(parentDimensions.Height);

            calculatedStyle.Width   = MathHelper.Clamp(this.Width.GetValue(parentDimensions.Width), min1, max1);
            calculatedStyle.Height  = MathHelper.Clamp(this.Height.GetValue(parentDimensions.Height), min2, max2);
            calculatedStyle.Width  += this.MarginLeft + this.MarginRight;
            calculatedStyle.Height += this.MarginTop + this.MarginBottom;
            calculatedStyle.X      += (float)((double)parentDimensions.Width * (double)this.HAlign - (double)calculatedStyle.Width * (double)this.HAlign);
            calculatedStyle.Y      += (float)((double)parentDimensions.Height * (double)this.VAlign - (double)calculatedStyle.Height * (double)this.VAlign);
            return(calculatedStyle);
        }
Example #2
0
        public virtual void Recalculate()
        {
            var calculatedStyle1 = this.Parent == null
                ? UserInterface.ActiveInstance.GetDimensions()
                : this.Parent.GetInnerDimensions();

            if (this.Parent != null && this.Parent is UIList)
            {
                calculatedStyle1.Height = float.MaxValue;
            }
            CalculatedStyle calculatedStyle2;

            calculatedStyle2.X = this.Left.GetValue(calculatedStyle1.Width) + calculatedStyle1.X;
            calculatedStyle2.Y = this.Top.GetValue(calculatedStyle1.Height) + calculatedStyle1.Y;
            var min1 = this.MinWidth.GetValue(calculatedStyle1.Width);
            var max1 = this.MaxWidth.GetValue(calculatedStyle1.Width);
            var min2 = this.MinHeight.GetValue(calculatedStyle1.Height);
            var max2 = this.MaxHeight.GetValue(calculatedStyle1.Height);

            calculatedStyle2.Width   = MathHelper.Clamp(this.Width.GetValue(calculatedStyle1.Width), min1, max1);
            calculatedStyle2.Height  = MathHelper.Clamp(this.Height.GetValue(calculatedStyle1.Height), min2, max2);
            calculatedStyle2.Width  += this.MarginLeft + this.MarginRight;
            calculatedStyle2.Height += this.MarginTop + this.MarginBottom;
            calculatedStyle2.X      += (float)((double)calculatedStyle1.Width * (double)this.HAlign -
                                               (double)calculatedStyle2.Width * (double)this.HAlign);
            calculatedStyle2.Y += (float)((double)calculatedStyle1.Height * (double)this.VAlign -
                                          (double)calculatedStyle2.Height * (double)this.VAlign);
            this._outerDimensions    = calculatedStyle2;
            calculatedStyle2.X      += this.MarginLeft;
            calculatedStyle2.Y      += this.MarginTop;
            calculatedStyle2.Width  -= this.MarginLeft + this.MarginRight;
            calculatedStyle2.Height -= this.MarginTop + this.MarginBottom;
            this._dimensions         = calculatedStyle2;
            calculatedStyle2.X      += this.PaddingLeft;
            calculatedStyle2.Y      += this.PaddingTop;
            calculatedStyle2.Width  -= this.PaddingLeft + this.PaddingRight;
            calculatedStyle2.Height -= this.PaddingTop + this.PaddingBottom;
            this._innerDimensions    = calculatedStyle2;
            this.RecalculateChildren();
        }
Example #3
0
        public virtual void Recalculate()
        {
            CalculatedStyle parentDimensions = (Parent == null) ? UserInterface.ActiveInstance.GetDimensions() : Parent.GetInnerDimensions();

            if (Parent != null && Parent is UIList)
            {
                parentDimensions.Height = float.MaxValue;
            }
            CalculatedStyle calculatedStyle = _outerDimensions = GetDimensionsBasedOnParentDimensions(parentDimensions);

            calculatedStyle.X      += MarginLeft;
            calculatedStyle.Y      += MarginTop;
            calculatedStyle.Width  -= MarginLeft + MarginRight;
            calculatedStyle.Height -= MarginTop + MarginBottom;
            _dimensions             = calculatedStyle;
            calculatedStyle.X      += PaddingLeft;
            calculatedStyle.Y      += PaddingTop;
            calculatedStyle.Width  -= PaddingLeft + PaddingRight;
            calculatedStyle.Height -= PaddingTop + PaddingBottom;
            _innerDimensions        = calculatedStyle;
            RecalculateChildren();
        }
Example #4
0
        public virtual void Recalculate()
        {
            CalculatedStyle parentDimensions1 = this.Parent == null?UserInterface.ActiveInstance.GetDimensions() : this.Parent.GetInnerDimensions();

            if (this.Parent != null && this.Parent is UIList)
            {
                parentDimensions1.Height = float.MaxValue;
            }
            CalculatedStyle parentDimensions2 = this.GetDimensionsBasedOnParentDimensions(parentDimensions1);

            this._outerDimensions     = parentDimensions2;
            parentDimensions2.X      += this.MarginLeft;
            parentDimensions2.Y      += this.MarginTop;
            parentDimensions2.Width  -= this.MarginLeft + this.MarginRight;
            parentDimensions2.Height -= this.MarginTop + this.MarginBottom;
            this._dimensions          = parentDimensions2;
            parentDimensions2.X      += this.PaddingLeft;
            parentDimensions2.Y      += this.PaddingTop;
            parentDimensions2.Width  -= this.PaddingLeft + this.PaddingRight;
            parentDimensions2.Height -= this.PaddingTop + this.PaddingBottom;
            this._innerDimensions     = parentDimensions2;
            this.RecalculateChildren();
        }
Example #5
0
        public virtual void Recalculate()
        {
            CalculatedStyle calculatedStyle  = (Parent == null) ? UserInterface.ActiveInstance.GetDimensions() : Parent.GetInnerDimensions();
            CalculatedStyle calculatedStyle2 = default(CalculatedStyle);

            calculatedStyle2.X = Left.GetValue(calculatedStyle.Width) + calculatedStyle.X;
            calculatedStyle2.Y = Top.GetValue(calculatedStyle.Height) + calculatedStyle.Y;
            float value  = MinWidth.GetValue(calculatedStyle.Width);
            float value2 = MaxWidth.GetValue(calculatedStyle.Width);
            float value3 = MinHeight.GetValue(calculatedStyle.Height);
            float value4 = MaxHeight.GetValue(calculatedStyle.Height);

            calculatedStyle2.Width   = MathHelper.Clamp(Width.GetValue(calculatedStyle.Width), value, value2);
            calculatedStyle2.Height  = MathHelper.Clamp(Height.GetValue(calculatedStyle.Height), value3, value4);
            calculatedStyle2.X      += calculatedStyle.Width * HAlign - calculatedStyle2.Width * HAlign;
            calculatedStyle2.Y      += calculatedStyle.Height * VAlign - calculatedStyle2.Height * VAlign;
            _dimensions              = calculatedStyle2;
            calculatedStyle2.X      += PaddingLeft;
            calculatedStyle2.Y      += PaddingTop;
            calculatedStyle2.Width  -= PaddingLeft + PaddingRight;
            calculatedStyle2.Height -= PaddingTop + PaddingBottom;
            _innerDimensions         = calculatedStyle2;
            RecalculateChildren();
        }
Example #6
0
        public void Calculate(UIElement element)
        {
            CalculatedStyle dimensions = element.GetDimensions();

            this.Position = dimensions.Position() + this._offset + this._anchor * new Vector2(dimensions.Width, dimensions.Height);
        }
Example #7
0
 public virtual void Recalculate()
 {
     CalculatedStyle calculatedStyle1 = this.Parent == null ? UserInterface.ActiveInstance.GetDimensions() : this.Parent.GetInnerDimensions();
     CalculatedStyle calculatedStyle2;
     calculatedStyle2.X = this.Left.GetValue(calculatedStyle1.Width) + calculatedStyle1.X;
     calculatedStyle2.Y = this.Top.GetValue(calculatedStyle1.Height) + calculatedStyle1.Y;
     float min1 = this.MinWidth.GetValue(calculatedStyle1.Width);
     float max1 = this.MaxWidth.GetValue(calculatedStyle1.Width);
     float min2 = this.MinHeight.GetValue(calculatedStyle1.Height);
     float max2 = this.MaxHeight.GetValue(calculatedStyle1.Height);
     calculatedStyle2.Width = MathHelper.Clamp(this.Width.GetValue(calculatedStyle1.Width), min1, max1);
     calculatedStyle2.Height = MathHelper.Clamp(this.Height.GetValue(calculatedStyle1.Height), min2, max2);
     calculatedStyle2.X += (float)((double)calculatedStyle1.Width * (double)this.HAlign - (double)calculatedStyle2.Width * (double)this.HAlign);
     calculatedStyle2.Y += (float)((double)calculatedStyle1.Height * (double)this.VAlign - (double)calculatedStyle2.Height * (double)this.VAlign);
     this._dimensions = calculatedStyle2;
     calculatedStyle2.X += this.PaddingLeft;
     calculatedStyle2.Y += this.PaddingTop;
     calculatedStyle2.Width -= this.PaddingLeft + this.PaddingRight;
     calculatedStyle2.Height -= this.PaddingTop + this.PaddingBottom;
     this._innerDimensions = calculatedStyle2;
     this.RecalculateChildren();
 }
		public virtual void Recalculate()
		{
			CalculatedStyle calculatedStyle;
			if (this.Parent != null)
			{
				calculatedStyle = this.Parent.GetInnerDimensions();
			}
			else
			{
				calculatedStyle = UserInterface.ActiveInstance.GetDimensions();
			}
			CalculatedStyle calculatedStyle2;
			calculatedStyle2.X = this.Left.GetValue(calculatedStyle.Width) + calculatedStyle.X;
			calculatedStyle2.Y = this.Top.GetValue(calculatedStyle.Height) + calculatedStyle.Y;
			float value = this.MinWidth.GetValue(calculatedStyle.Width);
			float value2 = this.MaxWidth.GetValue(calculatedStyle.Width);
			float value3 = this.MinHeight.GetValue(calculatedStyle.Height);
			float value4 = this.MaxHeight.GetValue(calculatedStyle.Height);
			calculatedStyle2.Width = MathHelper.Clamp(this.Width.GetValue(calculatedStyle.Width), value, value2);
			calculatedStyle2.Height = MathHelper.Clamp(this.Height.GetValue(calculatedStyle.Height), value3, value4);
			calculatedStyle2.X += calculatedStyle.Width * this.HAlign - calculatedStyle2.Width * this.HAlign;
			calculatedStyle2.Y += calculatedStyle.Height * this.VAlign - calculatedStyle2.Height * this.VAlign;
			this._dimensions = calculatedStyle2;
			calculatedStyle2.X += this.PaddingLeft;
			calculatedStyle2.Y += this.PaddingTop;
			calculatedStyle2.Width -= this.PaddingLeft + this.PaddingRight;
			calculatedStyle2.Height -= this.PaddingTop + this.PaddingBottom;
			this._innerDimensions = calculatedStyle2;
			this.RecalculateChildren();
		}