Exemplo n.º 1
0
    private Vector3 getVertAlignOffset(dfFontRendererBase textRenderer)
    {
        var p2u          = PixelsToUnits();
        var renderedSize = textRenderer.MeasureString(this.text) * p2u;
        var origin       = textRenderer.VectorOffset;
        var clientHeight = (Height - padding.vertical) * p2u;

        if (renderedSize.y >= clientHeight)
        {
            return(origin);
        }

        switch (this.vertAlign)
        {
        case dfVerticalAlignment.Middle:
            origin.y -= (clientHeight - renderedSize.y) * 0.5f;
            break;

        case dfVerticalAlignment.Bottom:
            origin.y -= clientHeight - renderedSize.y;
            break;
        }

        return(origin);
    }
Exemplo n.º 2
0
 private void autoSizeToText()
 {
     if (((this.Font != null) && this.Font.IsValid) && !string.IsNullOrEmpty(this.Text))
     {
         using (dfFontRendererBase base2 = this.obtainTextRenderer())
         {
             Vector2 vector  = base2.MeasureString(this.Text);
             Vector2 vector2 = new Vector2(vector.x + this.padding.horizontal, vector.y + this.padding.vertical);
             base.Size = vector2;
         }
     }
 }
Exemplo n.º 3
0
 private void autoSizeToText()
 {
     if (this.Font == null || !this.Font.IsValid || string.IsNullOrEmpty(this.Text))
     {
         return;
     }
     using (dfFontRendererBase _dfFontRendererBase = this.obtainTextRenderer())
     {
         Vector2 vector2  = _dfFontRendererBase.MeasureString(this.Text);
         Vector2 vector21 = new Vector2(vector2.x + (float)this.padding.horizontal, vector2.y + (float)this.padding.vertical);
         base.Size = vector21;
     }
 }
Exemplo n.º 4
0
    private Vector3 getVertAlignOffset(dfFontRendererBase textRenderer)
    {
        float   num          = base.PixelsToUnits();
        Vector2 vector       = (Vector2)(textRenderer.MeasureString(this.text) * num);
        Vector3 vectorOffset = textRenderer.VectorOffset;
        float   num2         = (base.Height - this.padding.vertical) * num;

        if (vector.y < num2)
        {
            dfVerticalAlignment vertAlign = this.vertAlign;
            if (vertAlign != dfVerticalAlignment.Middle)
            {
                if (vertAlign == dfVerticalAlignment.Bottom)
                {
                    vectorOffset.y -= num2 - vector.y;
                }
                return(vectorOffset);
            }
            vectorOffset.y -= (num2 - vector.y) * 0.5f;
        }
        return(vectorOffset);
    }
Exemplo n.º 5
0
    public override void Invalidate()
    {
        base.Invalidate();
        if (this.Font == null || !this.Font.IsValid)
        {
            return;
        }
        bool flag = this.size.sqrMagnitude <= 1.401298E-45f;

        if (!this.autoSize && !this.autoHeight && !flag)
        {
            return;
        }
        if (string.IsNullOrEmpty(this.Text))
        {
            if (flag)
            {
                base.Size = new Vector2(150f, 24f);
            }
            if (this.AutoSize || this.AutoHeight)
            {
                base.Height = (float)Mathf.CeilToInt((float)this.Font.LineHeight * this.TextScale);
            }
            return;
        }
        using (dfFontRendererBase _dfFontRendererBase = this.obtainRenderer())
        {
            Vector2 num = _dfFontRendererBase.MeasureString(this.text).RoundToInt();
            if (this.AutoSize || flag)
            {
                this.size = num + new Vector2((float)this.padding.horizontal, (float)this.padding.vertical);
            }
            else if (this.AutoHeight)
            {
                this.size = new Vector2(this.size.x, num.y + (float)this.padding.vertical);
            }
        }
    }
Exemplo n.º 6
0
    private Vector3 getVertAlignOffset(dfFontRendererBase textRenderer)
    {
        float   units        = base.PixelsToUnits();
        Vector2 vector2      = textRenderer.MeasureString(this.text) * units;
        Vector3 vectorOffset = textRenderer.VectorOffset;
        float   height       = (base.Height - (float)this.padding.vertical) * units;

        if (vector2.y >= height)
        {
            return(vectorOffset);
        }
        dfVerticalAlignment _dfVerticalAlignment = this.vertAlign;

        if (_dfVerticalAlignment == dfVerticalAlignment.Middle)
        {
            vectorOffset.y = vectorOffset.y - (height - vector2.y) * 0.5f;
        }
        else if (_dfVerticalAlignment == dfVerticalAlignment.Bottom)
        {
            vectorOffset.y = vectorOffset.y - (height - vector2.y);
        }
        return(vectorOffset);
    }
Exemplo n.º 7
0
 public override void Invalidate()
 {
     base.Invalidate();
     if ((this.Font != null) && this.Font.IsValid)
     {
         bool flag = this.size.sqrMagnitude <= float.Epsilon;
         if ((this.autoSize || this.autoHeight) || flag)
         {
             if (string.IsNullOrEmpty(this.Text))
             {
                 if (flag)
                 {
                     base.Size = new Vector2(150f, 24f);
                 }
                 if (this.AutoSize || this.AutoHeight)
                 {
                     base.Height = Mathf.CeilToInt(this.Font.LineHeight * this.TextScale);
                 }
             }
             else
             {
                 using (dfFontRendererBase base2 = this.obtainRenderer())
                 {
                     Vector2 vector = base2.MeasureString(this.text).RoundToInt();
                     if (this.AutoSize || flag)
                     {
                         base.size = vector + new Vector2((float)this.padding.horizontal, (float)this.padding.vertical);
                     }
                     else if (this.AutoHeight)
                     {
                         base.size = new Vector2(this.size.x, vector.y + this.padding.vertical);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
    private Vector3 getVertAlignOffset( dfFontRendererBase textRenderer )
    {
        var p2u = PixelsToUnits();
        var renderedSize = textRenderer.MeasureString( this.text ) * p2u;
        var origin = textRenderer.VectorOffset;
        var clientHeight = ( Height - padding.vertical ) * p2u;

        if( renderedSize.y >= clientHeight )
            return origin;

        switch( this.vertAlign )
        {
            case dfVerticalAlignment.Middle:
                origin.y -= ( clientHeight - renderedSize.y ) * 0.5f;
                break;
            case dfVerticalAlignment.Bottom:
                origin.y -= clientHeight - renderedSize.y;
                break;
        }

        return origin;
    }
Exemplo n.º 9
0
 private Vector3 getVertAlignOffset(dfFontRendererBase textRenderer)
 {
     float units = base.PixelsToUnits();
     Vector2 vector2 = textRenderer.MeasureString(this.text) * units;
     Vector3 vectorOffset = textRenderer.VectorOffset;
     float height = (base.Height - (float)this.padding.vertical) * units;
     if (vector2.y >= height)
     {
         return vectorOffset;
     }
     dfVerticalAlignment _dfVerticalAlignment = this.vertAlign;
     if (_dfVerticalAlignment == dfVerticalAlignment.Middle)
     {
         vectorOffset.y = vectorOffset.y - (height - vector2.y) * 0.5f;
     }
     else if (_dfVerticalAlignment == dfVerticalAlignment.Bottom)
     {
         vectorOffset.y = vectorOffset.y - (height - vector2.y);
     }
     return vectorOffset;
 }