Ejemplo n.º 1
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (style.Font != null)
     {
         string          str = (!style.PreserveWhitespace && this.isWhitespace) ? " " : this.Text;
         dfMarkupBoxText box = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inline, style);
         box.SetText(str);
         container.AddChild(box);
     }
 }
Ejemplo n.º 2
0
    private void addInline(dfMarkupBox box)
    {
        dfMarkupBorders margins = box.Margins;
        bool            flag    = !this.Style.Preformatted && ((this.currentLine != null) && ((this.currentLinePos + box.Size.x) > this.currentLine.Size.x));

        if ((this.currentLine == null) || flag)
        {
            dfDynamicFont font;
            this.endCurrentLine(false);
            int         num             = this.getVerticalPosition(margins.top);
            dfMarkupBox containingBlock = this.GetContainingBlock();
            if (containingBlock == null)
            {
                Debug.LogError("Containing block not found");
                return;
            }
            if (this.Style.Font != null)
            {
                font = this.Style.Font;
            }
            else
            {
                font = this.Style.Host.Font;
            }
            float       num2 = ((float)font.FontSize) / ((float)font.FontSize);
            float       num3 = font.Baseline * num2;
            dfMarkupBox box3 = new dfMarkupBox(this.Element, dfMarkupDisplayType.block, this.Style)
            {
                Size     = new Vector2(containingBlock.Size.x, (float)this.Style.LineHeight),
                Position = new Vector2(0f, (float)num),
                Parent   = this,
                Baseline = (int)num3
            };
            this.currentLine = box3;
            this.children.Add(this.currentLine);
        }
        if (((this.currentLinePos == 0) && !box.Style.PreserveWhitespace) && (box is dfMarkupBoxText))
        {
            dfMarkupBoxText text = box as dfMarkupBoxText;
            if (text.IsWhitespace)
            {
                return;
            }
        }
        Vector2 vector = new Vector2((float)(this.currentLinePos + margins.left), (float)margins.top);

        box.Position = vector;
        box.Parent   = this.currentLine;
        this.currentLine.children.Add(box);
        this.currentLinePos = ((int)(vector.x + box.Size.x)) + box.Margins.right;
        float x = Mathf.Max(this.currentLine.Size.x, vector.x + box.Size.x);
        float y = Mathf.Max(this.currentLine.Size.y, vector.y + box.Size.y);

        this.currentLine.Size = new Vector2(x, y);
    }
Ejemplo n.º 3
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (style.Font == null)
        {
            return;
        }
        string          str = (style.PreserveWhitespace || !this.isWhitespace ? this.Text : " ");
        dfMarkupBoxText _dfMarkupBoxText = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inline, style);

        _dfMarkupBoxText.SetText(str);
        container.AddChild(_dfMarkupBoxText);
    }
Ejemplo n.º 4
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.ChildNodes.Count == 0)
        {
            return;
        }
        float       size         = container.Size.x;
        dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.listItem, style);

        _dfMarkupBox.Margins.top = 10;
        container.AddChild(_dfMarkupBox);
        dfMarkupTagList parent = base.Parent as dfMarkupTagList;

        if (parent == null)
        {
            base._PerformLayoutImpl(container, style);
            return;
        }
        style.VerticalAlign = dfMarkupVerticalAlign.Baseline;
        string str = "•";

        if (parent.TagName == "ol")
        {
            str = string.Concat(container.Children.Count, ".");
        }
        dfMarkupStyle _dfMarkupStyle = style;

        _dfMarkupStyle.VerticalAlign = dfMarkupVerticalAlign.Baseline;
        _dfMarkupStyle.Align         = dfMarkupTextAlign.Right;
        dfMarkupBoxText bulletWidth = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inlineBlock, _dfMarkupStyle);

        bulletWidth.SetText(str);
        bulletWidth.Width        = parent.BulletWidth;
        bulletWidth.Margins.left = style.FontSize * 2;
        _dfMarkupBox.AddChild(bulletWidth);
        dfMarkupBox vector2  = new dfMarkupBox(this, dfMarkupDisplayType.inlineBlock, style);
        int         fontSize = style.FontSize;
        float       single   = size - bulletWidth.Size.x - (float)bulletWidth.Margins.left - (float)fontSize;

        vector2.Size         = new Vector2(single, (float)fontSize);
        vector2.Margins.left = (int)((float)style.FontSize * 0.5f);
        _dfMarkupBox.AddChild(vector2);
        for (int i = 0; i < base.ChildNodes.Count; i++)
        {
            base.ChildNodes[i].PerformLayout(vector2, style);
        }
        vector2.FitToContents(false);
        vector2.Parent.FitToContents(false);
        _dfMarkupBox.FitToContents(false);
    }
Ejemplo n.º 5
0
 public static dfMarkupBoxText Obtain(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
 {
     if (objectPool.Count > 0)
     {
         dfMarkupBoxText text = objectPool.Dequeue();
         text.Element  = element;
         text.Display  = display;
         text.Style    = style;
         text.Position = Vector2.zero;
         text.Size     = Vector2.zero;
         text.Baseline = (int)(style.FontSize * 1.1f);
         text.Margins  = new dfMarkupBorders();
         text.Padding  = new dfMarkupBorders();
         return(text);
     }
     return(new dfMarkupBoxText(element, display, style));
 }
Ejemplo n.º 6
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count != 0)
     {
         float       x   = container.Size.x;
         dfMarkupBox box = new dfMarkupBox(this, dfMarkupDisplayType.listItem, style);
         box.Margins.top = 10;
         container.AddChild(box);
         dfMarkupTagList parent = base.Parent as dfMarkupTagList;
         if (parent == null)
         {
             base._PerformLayoutImpl(container, style);
         }
         else
         {
             style.VerticalAlign = dfMarkupVerticalAlign.Baseline;
             string str = "•";
             if (parent.TagName == "ol")
             {
                 str = container.Children.Count + ".";
             }
             dfMarkupStyle style2 = style;
             style2.VerticalAlign = dfMarkupVerticalAlign.Baseline;
             style2.Align         = dfMarkupTextAlign.Right;
             dfMarkupBoxText text = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inlineBlock, style2);
             text.SetText(str);
             text.Width        = parent.BulletWidth;
             text.Margins.left = style.FontSize * 2;
             box.AddChild(text);
             dfMarkupBox box2     = new dfMarkupBox(this, dfMarkupDisplayType.inlineBlock, style);
             int         fontSize = style.FontSize;
             float       num3     = ((x - text.Size.x) - text.Margins.left) - fontSize;
             box2.Size         = new Vector2(num3, (float)fontSize);
             box2.Margins.left = (int)(style.FontSize * 0.5f);
             box.AddChild(box2);
             for (int i = 0; i < base.ChildNodes.Count; i++)
             {
                 base.ChildNodes[i].PerformLayout(box2, style);
             }
             box2.FitToContents(false);
             box2.Parent.FitToContents(false);
             box.FitToContents(false);
         }
     }
 }
Ejemplo n.º 7
0
    public static dfMarkupBoxText Obtain(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
    {
        if (dfMarkupBoxText.objectPool.Count <= 0)
        {
            return(new dfMarkupBoxText(element, display, style));
        }
        dfMarkupBoxText fontSize = dfMarkupBoxText.objectPool.Dequeue();

        fontSize.Element  = element;
        fontSize.Display  = display;
        fontSize.Style    = style;
        fontSize.Position = Vector2.zero;
        fontSize.Size     = Vector2.zero;
        fontSize.Baseline = (int)((float)style.FontSize * 1.1f);
        fontSize.Margins  = new dfMarkupBorders();
        fontSize.Padding  = new dfMarkupBorders();
        return(fontSize);
    }
Ejemplo n.º 8
0
 private void doHorizontalAlignment()
 {
     if ((this.Style.Align != dfMarkupTextAlign.Left) && (this.children.Count != 0))
     {
         int num = this.children.Count - 1;
         while (num > 0)
         {
             dfMarkupBoxText text = this.children[num] as dfMarkupBoxText;
             if ((text == null) || !text.IsWhitespace)
             {
                 break;
             }
             num--;
         }
         if (this.Style.Align == dfMarkupTextAlign.Center)
         {
             float num2 = 0f;
             for (int i = 0; i <= num; i++)
             {
                 num2 += this.children[i].Size.x;
             }
             float num4 = ((this.Size.x - this.Padding.horizontal) - num2) * 0.5f;
             for (int j = 0; j <= num; j++)
             {
                 Vector2 position = this.children[j].Position;
                 position.x += num4;
                 this.children[j].Position = position;
             }
         }
         else if (this.Style.Align == dfMarkupTextAlign.Right)
         {
             float num6 = this.Size.x - this.Padding.horizontal;
             for (int k = num; k >= 0; k--)
             {
                 Vector2 vector2 = this.children[k].Position;
                 vector2.x = num6 - this.children[k].Size.x;
                 this.children[k].Position = vector2;
                 num6 -= this.children[k].Size.x;
             }
         }
         else
         {
             if (this.Style.Align != dfMarkupTextAlign.Justify)
             {
                 throw new NotImplementedException("text-align: " + this.Style.Align + " is not implemented");
             }
             if ((this.children.Count > 1) && (!this.IsNewline && !this.children[this.children.Count - 1].IsNewline))
             {
                 float a = 0f;
                 for (int m = 0; m <= num; m++)
                 {
                     dfMarkupBox box = this.children[m];
                     a = Mathf.Max(a, box.Position.x + box.Size.x);
                 }
                 float num10 = ((this.Size.x - this.Padding.horizontal) - a) / ((float)this.children.Count);
                 for (int n = 1; n <= num; n++)
                 {
                     dfMarkupBox local1 = this.children[n];
                     local1.Position += new Vector2(n * num10, 0f);
                 }
                 dfMarkupBox box2    = this.children[num];
                 Vector2     vector3 = box2.Position;
                 vector3.x     = (this.Size.x - this.Padding.horizontal) - box2.Size.x;
                 box2.Position = vector3;
             }
         }
     }
 }
Ejemplo n.º 9
0
    private void doHorizontalAlignment()
    {
        if (this.Style.Align == dfMarkupTextAlign.Left || this.children.Count == 0)
        {
            return;
        }
        int count = this.children.Count - 1;

        while (count > 0)
        {
            dfMarkupBoxText item = this.children[count] as dfMarkupBoxText;
            if (item == null || !item.IsWhitespace)
            {
                break;
            }
            else
            {
                count--;
            }
        }
        if (this.Style.Align == dfMarkupTextAlign.Center)
        {
            float size = 0f;
            for (int i = 0; i <= count; i++)
            {
                size = size + this.children[i].Size.x;
            }
            float single = (this.Size.x - (float)this.Padding.horizontal - size) * 0.5f;
            for (int j = 0; j <= count; j++)
            {
                Vector2 position = this.children[j].Position;
                position.x = position.x + single;
                this.children[j].Position = position;
            }
        }
        else if (this.Style.Align != dfMarkupTextAlign.Right)
        {
            if (this.Style.Align != dfMarkupTextAlign.Justify)
            {
                throw new NotImplementedException(string.Concat("text-align: ", this.Style.Align, " is not implemented"));
            }
            if (this.children.Count <= 1)
            {
                return;
            }
            if (this.IsNewline || this.children[this.children.Count - 1].IsNewline)
            {
                return;
            }
            float single1 = 0f;
            for (int k = 0; k <= count; k++)
            {
                dfMarkupBox _dfMarkupBox = this.children[k];
                single1 = Mathf.Max(single1, _dfMarkupBox.Position.x + _dfMarkupBox.Size.x);
            }
            float size1 = (this.Size.x - (float)this.Padding.horizontal - single1) / (float)this.children.Count;
            for (int l = 1; l <= count; l++)
            {
                dfMarkupBox item1 = this.children[l];
                item1.Position = item1.Position + new Vector2((float)l * size1, 0f);
            }
            dfMarkupBox _dfMarkupBox1 = this.children[count];
            Vector2     vector2       = _dfMarkupBox1.Position;
            vector2.x = this.Size.x - (float)this.Padding.horizontal - _dfMarkupBox1.Size.x;
            _dfMarkupBox1.Position = vector2;
        }
        else
        {
            float size2 = this.Size.x - (float)this.Padding.horizontal;
            for (int m = count; m >= 0; m--)
            {
                Vector2 position1 = this.children[m].Position;
                position1.x = size2 - this.children[m].Size.x;
                this.children[m].Position = position1;
                size2 = size2 - this.children[m].Size.x;
            }
        }
    }