예제 #1
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);
    }
예제 #2
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        var headingMargins = new dfMarkupBorders();

        var headingStyle = applyDefaultStyles(style, ref headingMargins);

        headingStyle = applyTextStyleAttributes(headingStyle);

        // Allow overriding of margins
        var marginAttribute = findAttribute("margin");

        if (marginAttribute != null)
        {
            headingMargins = dfMarkupBorders.Parse(marginAttribute.Value);
        }

        var headingBox = new dfMarkupBox(this, dfMarkupDisplayType.block, headingStyle);

        headingBox.Margins = headingMargins;

        container.AddChild(headingBox);

        base._PerformLayoutImpl(headingBox, headingStyle);
        headingBox.FitToContents();
    }
예제 #3
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (Owner == null)
        {
            Debug.LogError("Tag has no parent: " + this);
            return;
        }

        style = applyStyleAttributes(style);

        var sourceAttribute = findAttribute("src");

        if (sourceAttribute == null)
        {
            return;
        }

        var source = sourceAttribute.Value;

        var imageBox = createImageBox(Owner.Atlas, source, style);

        if (imageBox == null)
        {
            return;
        }

        var size = Vector2.zero;

        var heightAttribute = findAttribute("height");

        if (heightAttribute != null)
        {
            size.y = dfMarkupStyle.ParseSize(heightAttribute.Value, (int)imageBox.Size.y);
        }

        var widthAttribute = findAttribute("width");

        if (widthAttribute != null)
        {
            size.x = dfMarkupStyle.ParseSize(widthAttribute.Value, (int)imageBox.Size.x);
        }

        if (size.sqrMagnitude <= float.Epsilon)
        {
            size = imageBox.Size;
        }
        else if (size.x <= float.Epsilon)
        {
            size.x = size.y * (imageBox.Size.x / imageBox.Size.y);
        }
        else if (size.y <= float.Epsilon)
        {
            size.y = size.x * (imageBox.Size.y / imageBox.Size.x);
        }

        imageBox.Size     = size;
        imageBox.Baseline = (int)size.y;

        container.AddChild(imageBox);
    }
예제 #4
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     style.PreserveWhitespace = true;
     style.Preformatted = true;
     if (style.Align == dfMarkupTextAlign.Justify)
     {
         style.Align = dfMarkupTextAlign.Left;
     }
     dfMarkupBox _dfMarkupBox = null;
     if (style.BackgroundColor.a <= 0.1f)
     {
         _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     }
     else
     {
         dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
         _dfMarkupBoxSprite.LoadImage(base.Owner.Atlas, base.Owner.BlankTextureSprite);
         _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
         _dfMarkupBox = _dfMarkupBoxSprite;
     }
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });
     if (_dfMarkupAttribute != null)
     {
         _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });
     if (_dfMarkupAttribute1 != null)
     {
         _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
     }
     container.AddChild(_dfMarkupBox);
     base._PerformLayoutImpl(_dfMarkupBox, style);
     _dfMarkupBox.FitToContents(false);
 }
예제 #5
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (this.ChildNodes.Count == 0)
        {
            return;
        }

        style.Align = dfMarkupTextAlign.Left;

        var listContainer = new dfMarkupBox(this, dfMarkupDisplayType.block, style);

        container.AddChild(listContainer);

        calculateBulletWidth(style);

        for (int i = 0; i < ChildNodes.Count; i++)
        {
            var child = ChildNodes[i] as dfMarkupTag;
            if (child == null || child.TagName != "li")
            {
                continue;
            }

            child.PerformLayout(listContainer, style);
        }

        listContainer.FitToContents();
    }
예제 #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);
         }
     }
 }
예제 #7
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);
 }
예제 #8
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (this.ChildNodes.Count == 0)
        {
            return;
        }

        style = applyTextStyleAttributes(style);

        var topMargin = container.Children.Count == 0 ? 0 : style.LineHeight;

        dfMarkupBox paragraphBox = null;

        if (style.BackgroundColor.a > 0.005f)
        {
            var spriteBox = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
            spriteBox.Atlas       = this.Owner.Atlas;
            spriteBox.Source      = this.Owner.BlankTextureSprite;
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;
        }
        else
        {
            paragraphBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }

        paragraphBox.Margins = new dfMarkupBorders(0, 0, topMargin, style.LineHeight);

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute("margin");
        if (marginAttribute != null)
        {
            paragraphBox.Margins = dfMarkupBorders.Parse(marginAttribute.Value);
        }

        var paddingAttribute = findAttribute("padding");
        if (paddingAttribute != null)
        {
            paragraphBox.Padding = dfMarkupBorders.Parse(paddingAttribute.Value);
        }

        #endregion

        container.AddChild(paragraphBox);

        base._PerformLayoutImpl(paragraphBox, style);

        if (paragraphBox.Children.Count > 0)
        {
            paragraphBox.Children[paragraphBox.Children.Count - 1].IsNewline = true;
        }

        paragraphBox.FitToContents(true);
    }
예제 #9
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);
     }
 }
예제 #10
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);
    }
예제 #11
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.Owner == null)
        {
            Debug.LogError(string.Concat("Tag has no parent: ", this));
            return;
        }
        style = this.applyStyleAttributes(style);
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "src" });

        if (_dfMarkupAttribute == null)
        {
            return;
        }
        string      value        = _dfMarkupAttribute.Value;
        dfMarkupBox _dfMarkupBox = this.createImageBox(base.Owner.Atlas, value, style);

        if (_dfMarkupBox == null)
        {
            return;
        }
        Vector2           size = Vector2.zero;
        dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "height" });

        if (_dfMarkupAttribute1 != null)
        {
            size.y = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute1.Value, (int)_dfMarkupBox.Size.y);
        }
        dfMarkupAttribute _dfMarkupAttribute2 = base.findAttribute(new string[] { "width" });

        if (_dfMarkupAttribute2 != null)
        {
            size.x = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute2.Value, (int)_dfMarkupBox.Size.x);
        }
        if (size.sqrMagnitude <= 1.401298E-45f)
        {
            size = _dfMarkupBox.Size;
        }
        else if (size.x <= 1.401298E-45f)
        {
            size.x = size.y * (_dfMarkupBox.Size.x / _dfMarkupBox.Size.y);
        }
        else if (size.y <= 1.401298E-45f)
        {
            size.y = size.x * (_dfMarkupBox.Size.y / _dfMarkupBox.Size.x);
        }
        _dfMarkupBox.Size     = size;
        _dfMarkupBox.Baseline = (int)size.y;
        container.AddChild(_dfMarkupBox);
    }
예제 #12
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.Owner == null)
     {
         Debug.LogError("Tag has no parent: " + this);
     }
     else
     {
         style = this.applyStyleAttributes(style);
         string[]          names     = new string[] { "src" };
         dfMarkupAttribute attribute = base.findAttribute(names);
         if (attribute != null)
         {
             string      source = attribute.Value;
             dfMarkupBox box    = this.createImageBox(base.Owner.Atlas, source, style);
             if (box != null)
             {
                 Vector2           zero       = Vector2.zero;
                 string[]          textArray2 = new string[] { "height" };
                 dfMarkupAttribute attribute2 = base.findAttribute(textArray2);
                 if (attribute2 != null)
                 {
                     zero.y = dfMarkupStyle.ParseSize(attribute2.Value, (int)box.Size.y);
                 }
                 string[]          textArray3 = new string[] { "width" };
                 dfMarkupAttribute attribute3 = base.findAttribute(textArray3);
                 if (attribute3 != null)
                 {
                     zero.x = dfMarkupStyle.ParseSize(attribute3.Value, (int)box.Size.x);
                 }
                 if (zero.sqrMagnitude <= float.Epsilon)
                 {
                     zero = box.Size;
                 }
                 else if (zero.x <= float.Epsilon)
                 {
                     zero.x = zero.y * (box.Size.x / box.Size.y);
                 }
                 else if (zero.y <= float.Epsilon)
                 {
                     zero.y = zero.x * (box.Size.y / box.Size.x);
                 }
                 box.Size     = zero;
                 box.Baseline = (int)zero.y;
                 container.AddChild(box);
             }
         }
     }
 }
예제 #13
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        style = applyTextStyleAttributes(style);

        style.PreserveWhitespace = true;
        style.Preformatted       = true;

        if (style.Align == dfMarkupTextAlign.Justify)
        {
            style.Align = dfMarkupTextAlign.Left;
        }

        dfMarkupBox paragraphBox = null;

        if (style.BackgroundColor.a > 0.1f)
        {
            var spriteBox = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
            spriteBox.LoadImage(this.Owner.Atlas, this.Owner.BlankTextureSprite);
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;
        }
        else
        {
            paragraphBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute("margin");
        if (marginAttribute != null)
        {
            paragraphBox.Margins = dfMarkupBorders.Parse(marginAttribute.Value);
        }

        var paddingAttribute = findAttribute("padding");
        if (paddingAttribute != null)
        {
            paragraphBox.Padding = dfMarkupBorders.Parse(paddingAttribute.Value);
        }

        #endregion

        container.AddChild(paragraphBox);

        base._PerformLayoutImpl(paragraphBox, style);

        paragraphBox.FitToContents();
    }
예제 #14
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (style.Font == null)
        {
            return;
        }

        var effectiveText = style.PreserveWhitespace || !isWhitespace ? this.Text : " ";

        var box = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inline, style);

        box.SetText(effectiveText);

        container.AddChild(box);
    }
예제 #15
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.Owner == null)
     {
         Debug.LogError(string.Concat("Tag has no parent: ", this));
         return;
     }
     style = this.applyStyleAttributes(style);
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "src" });
     if (_dfMarkupAttribute == null)
     {
         return;
     }
     string value = _dfMarkupAttribute.Value;
     dfMarkupBox _dfMarkupBox = this.createImageBox(base.Owner.Atlas, value, style);
     if (_dfMarkupBox == null)
     {
         return;
     }
     Vector2 size = Vector2.zero;
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "height" });
     if (_dfMarkupAttribute1 != null)
     {
         size.y = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute1.Value, (int)_dfMarkupBox.Size.y);
     }
     dfMarkupAttribute _dfMarkupAttribute2 = base.findAttribute(new string[] { "width" });
     if (_dfMarkupAttribute2 != null)
     {
         size.x = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute2.Value, (int)_dfMarkupBox.Size.x);
     }
     if (size.sqrMagnitude <= 1.401298E-45f)
     {
         size = _dfMarkupBox.Size;
     }
     else if (size.x <= 1.401298E-45f)
     {
         size.x = size.y * (_dfMarkupBox.Size.x / _dfMarkupBox.Size.y);
     }
     else if (size.y <= 1.401298E-45f)
     {
         size.y = size.x * (_dfMarkupBox.Size.y / _dfMarkupBox.Size.x);
     }
     _dfMarkupBox.Size = size;
     _dfMarkupBox.Baseline = (int)size.y;
     container.AddChild(_dfMarkupBox);
 }
예제 #16
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.ChildNodes.Count == 0)
        {
            return;
        }
        style = base.applyTextStyleAttributes(style);
        int         num          = (container.Children.Count != 0 ? style.LineHeight : 0);
        dfMarkupBox _dfMarkupBox = null;

        if (style.BackgroundColor.a <= 0.005f)
        {
            _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }
        else
        {
            dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
            {
                Atlas  = base.Owner.Atlas,
                Source = base.Owner.BlankTextureSprite
            };
            _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
            _dfMarkupBox = _dfMarkupBoxSprite;
        }
        _dfMarkupBox.Margins = new dfMarkupBorders(0, 0, num, style.LineHeight);
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });

        if (_dfMarkupAttribute != null)
        {
            _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
        }
        dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });

        if (_dfMarkupAttribute1 != null)
        {
            _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
        }
        container.AddChild(_dfMarkupBox);
        base._PerformLayoutImpl(_dfMarkupBox, style);
        if (_dfMarkupBox.Children.Count > 0)
        {
            _dfMarkupBox.Children[_dfMarkupBox.Children.Count - 1].IsNewline = true;
        }
        _dfMarkupBox.FitToContents(true);
    }
예제 #17
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count != 0)
     {
         style.Align = dfMarkupTextAlign.Left;
         dfMarkupBox box = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
         container.AddChild(box);
         this.calculateBulletWidth(style);
         for (int i = 0; i < base.ChildNodes.Count; i++)
         {
             dfMarkupTag tag = base.ChildNodes[i] as dfMarkupTag;
             if ((tag != null) && (tag.TagName == "li"))
             {
                 tag.PerformLayout(box, style);
             }
         }
         box.FitToContents(false);
     }
 }
예제 #18
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count != 0)
     {
         style = base.applyTextStyleAttributes(style);
         int         top = (container.Children.Count != 0) ? style.LineHeight : 0;
         dfMarkupBox box = null;
         if (style.BackgroundColor.a > 0.005f)
         {
             dfMarkupBoxSprite sprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
             {
                 Atlas  = base.Owner.Atlas,
                 Source = base.Owner.BlankTextureSprite
             };
             sprite.Style.Color = style.BackgroundColor;
             box = sprite;
         }
         else
         {
             box = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
         }
         box.Margins = new dfMarkupBorders(0, 0, top, style.LineHeight);
         string[]          names     = new string[] { "margin" };
         dfMarkupAttribute attribute = base.findAttribute(names);
         if (attribute != null)
         {
             box.Margins = dfMarkupBorders.Parse(attribute.Value);
         }
         string[]          textArray2 = new string[] { "padding" };
         dfMarkupAttribute attribute2 = base.findAttribute(textArray2);
         if (attribute2 != null)
         {
             box.Padding = dfMarkupBorders.Parse(attribute2.Value);
         }
         container.AddChild(box);
         base._PerformLayoutImpl(box, style);
         if (box.Children.Count > 0)
         {
             box.Children[box.Children.Count - 1].IsNewline = true;
         }
         box.FitToContents(true);
     }
 }
예제 #19
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count == 0)
     {
         return;
     }
     style = base.applyTextStyleAttributes(style);
     int num = (container.Children.Count != 0 ? style.LineHeight : 0);
     dfMarkupBox _dfMarkupBox = null;
     if (style.BackgroundColor.a <= 0.005f)
     {
         _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     }
     else
     {
         dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
         {
             Atlas = base.Owner.Atlas,
             Source = base.Owner.BlankTextureSprite
         };
         _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
         _dfMarkupBox = _dfMarkupBoxSprite;
     }
     _dfMarkupBox.Margins = new dfMarkupBorders(0, 0, num, style.LineHeight);
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });
     if (_dfMarkupAttribute != null)
     {
         _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });
     if (_dfMarkupAttribute1 != null)
     {
         _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
     }
     container.AddChild(_dfMarkupBox);
     base._PerformLayoutImpl(_dfMarkupBox, style);
     if (_dfMarkupBox.Children.Count > 0)
     {
         _dfMarkupBox.Children[_dfMarkupBox.Children.Count - 1].IsNewline = true;
     }
     _dfMarkupBox.FitToContents(true);
 }
예제 #20
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count == 0)
     {
         return;
     }
     style.Align = dfMarkupTextAlign.Left;
     dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     container.AddChild(_dfMarkupBox);
     this.calculateBulletWidth(style);
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         dfMarkupTag item = base.ChildNodes[i] as dfMarkupTag;
         if (item != null && !(item.TagName != "li"))
         {
             item.PerformLayout(_dfMarkupBox, style);
         }
     }
     _dfMarkupBox.FitToContents(false);
 }
예제 #21
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.ChildNodes.Count == 0)
        {
            return;
        }
        style.Align = dfMarkupTextAlign.Left;
        dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);

        container.AddChild(_dfMarkupBox);
        this.calculateBulletWidth(style);
        for (int i = 0; i < base.ChildNodes.Count; i++)
        {
            dfMarkupTag item = base.ChildNodes[i] as dfMarkupTag;
            if (item != null && !(item.TagName != "li"))
            {
                item.PerformLayout(_dfMarkupBox, style);
            }
        }
        _dfMarkupBox.FitToContents(false);
    }
예제 #22
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        dfMarkupBorders dfMarkupBorder = new dfMarkupBorders();
        dfMarkupStyle   _dfMarkupStyle = this.applyDefaultStyles(style, ref dfMarkupBorder);

        _dfMarkupStyle = base.applyTextStyleAttributes(_dfMarkupStyle);
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });

        if (_dfMarkupAttribute != null)
        {
            dfMarkupBorder = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
        }
        dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, _dfMarkupStyle)
        {
            Margins = dfMarkupBorder
        };

        container.AddChild(_dfMarkupBox);
        base._PerformLayoutImpl(_dfMarkupBox, _dfMarkupStyle);
        _dfMarkupBox.FitToContents(false);
    }
예제 #23
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        style = base.applyTextStyleAttributes(style);
        style.PreserveWhitespace = true;
        style.Preformatted       = true;
        if (style.Align == dfMarkupTextAlign.Justify)
        {
            style.Align = dfMarkupTextAlign.Left;
        }
        dfMarkupBox box = null;

        if (style.BackgroundColor.a > 0.1f)
        {
            dfMarkupBoxSprite sprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
            sprite.LoadImage(base.Owner.Atlas, base.Owner.BlankTextureSprite);
            sprite.Style.Color = style.BackgroundColor;
            box = sprite;
        }
        else
        {
            box = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }
        string[]          names     = new string[] { "margin" };
        dfMarkupAttribute attribute = base.findAttribute(names);

        if (attribute != null)
        {
            box.Margins = dfMarkupBorders.Parse(attribute.Value);
        }
        string[]          textArray2 = new string[] { "padding" };
        dfMarkupAttribute attribute2 = base.findAttribute(textArray2);

        if (attribute2 != null)
        {
            box.Padding = dfMarkupBorders.Parse(attribute2.Value);
        }
        container.AddChild(box);
        base._PerformLayoutImpl(box, style);
        box.FitToContents(false);
    }
예제 #24
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        style = applyTextStyleAttributes(style);

        dfMarkupBox spanBox = container;

        var marginAttribute = findAttribute("margin");

        if (marginAttribute != null)
        {
            spanBox         = new dfMarkupBox(this, dfMarkupDisplayType.inlineBlock, style);
            spanBox.Margins = dfMarkupBorders.Parse(marginAttribute.Value);

            // Span does not utilize top and bottom margins
            spanBox.Margins.top    = 0;
            spanBox.Margins.bottom = 0;

            container.AddChild(spanBox);
        }

        for (int i = 0; i < ChildNodes.Count; i++)
        {
            var child = ChildNodes[i];

            if (child is dfMarkupString)
            {
                var text = child as dfMarkupString;
                if (text.Text == "\n")
                {
                    if (style.PreserveWhitespace)
                    {
                        spanBox.AddLineBreak();
                    }
                    continue;
                }
            }

            child.PerformLayout(spanBox, style);
        }
    }
예제 #25
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        dfMarkupBorders margins = new dfMarkupBorders();
        dfMarkupStyle   style2  = this.applyDefaultStyles(style, ref margins);

        style2 = base.applyTextStyleAttributes(style2);
        string[]          names     = new string[] { "margin" };
        dfMarkupAttribute attribute = base.findAttribute(names);

        if (attribute != null)
        {
            margins = dfMarkupBorders.Parse(attribute.Value);
        }
        dfMarkupBox box = new dfMarkupBox(this, dfMarkupDisplayType.block, style2)
        {
            Margins = margins
        };

        container.AddChild(box);
        base._PerformLayoutImpl(box, style2);
        box.FitToContents(false);
    }
예제 #26
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        style = applyTextStyleAttributes( style );

        style.PreserveWhitespace = true;
        style.Preformatted = true;

        if( style.Align == dfMarkupTextAlign.Justify )
        {
            style.Align = dfMarkupTextAlign.Left;
        }

        dfMarkupBox paragraphBox = null;

        if( style.BackgroundColor.a > 0.1f )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.block, style );
            spriteBox.LoadImage( this.Owner.Atlas, this.Owner.BlankTextureSprite );
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;

        }
        else
        {
            paragraphBox = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        }

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            paragraphBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var paddingAttribute = findAttribute( "padding" );
        if( paddingAttribute != null )
        {
            paragraphBox.Padding = dfMarkupBorders.Parse( paddingAttribute.Value );
        }

        #endregion

        container.AddChild( paragraphBox );

        base._PerformLayoutImpl( paragraphBox, style );

        paragraphBox.FitToContents();
    }
예제 #27
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( this.ChildNodes.Count == 0 )
            return;

        style = applyTextStyleAttributes( style );

        var topMargin = container.Children.Count == 0 ? 0 : style.LineHeight;

        dfMarkupBox paragraphBox = null;

        if( style.BackgroundColor.a > 0.005f )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.block, style );
            spriteBox.Atlas = this.Owner.Atlas;
            spriteBox.Source = this.Owner.BlankTextureSprite;
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;

        }
        else
        {
            paragraphBox = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        }

        paragraphBox.Margins = new dfMarkupBorders( 0, 0, topMargin, style.LineHeight );

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            paragraphBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var paddingAttribute = findAttribute( "padding" );
        if( paddingAttribute != null )
        {
            paragraphBox.Padding = dfMarkupBorders.Parse( paddingAttribute.Value );
        }

        #endregion

        container.AddChild( paragraphBox );

        base._PerformLayoutImpl( paragraphBox, style );

        if( paragraphBox.Children.Count > 0 )
        {
            paragraphBox.Children[ paragraphBox.Children.Count - 1 ].IsNewline = true;
        }

        paragraphBox.FitToContents( true );
    }
예제 #28
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( this.ChildNodes.Count == 0 )
            return;

        var containerWidth = container.Size.x;

        var listItemContainer = new dfMarkupBox( this, dfMarkupDisplayType.listItem, style );
        listItemContainer.Margins.top = 10;
        container.AddChild( listItemContainer );

        var list = this.Parent as dfMarkupTagList;
        if( list == null )
        {
            // If the list item is not contained in a list, process its
            // child elements as normal html elements
            base._PerformLayoutImpl( container, style );
            return;
        }

        style.VerticalAlign = dfMarkupVerticalAlign.Baseline;

        var bulletText = "•";
        if( list.TagName == "ol" )
        {
            bulletText = container.Children.Count + ".";
        }

        var bulletBoxStyle = style;
        bulletBoxStyle.VerticalAlign = dfMarkupVerticalAlign.Baseline;
        bulletBoxStyle.Align = dfMarkupTextAlign.Right;

        // TODO: Pre-measure bullet item size (for ordered lists) at the <UL> tag level
        var listBulletElement = dfMarkupBoxText.Obtain( this, dfMarkupDisplayType.inlineBlock, bulletBoxStyle );
        listBulletElement.SetText( bulletText );
        listBulletElement.Width = list.BulletWidth;
        listBulletElement.Margins.left = style.FontSize * 2;
        listItemContainer.AddChild( listBulletElement );

        var listItemBox = new dfMarkupBox( this, dfMarkupDisplayType.inlineBlock, style );
        var listItemLeftMargin = style.FontSize;
        var listItemWidth = containerWidth - listBulletElement.Size.x - listBulletElement.Margins.left - listItemLeftMargin;
        listItemBox.Size = new Vector2( listItemWidth, listItemLeftMargin );
        listItemBox.Margins.left = (int)( style.FontSize * 0.5f );
        listItemContainer.AddChild( listItemBox );

        for( int i = 0; i < ChildNodes.Count; i++ )
        {
            ChildNodes[ i ].PerformLayout( listItemBox, style );
        }

        listItemBox.FitToContents();

        // The listItemBox.Parent property will actually refer to an internal
        // linebox that hosts the listItemBox, which needs to be fit to the
        // contents of the list item box.
        if( listItemBox.Parent != null )
        {
            listItemBox.Parent.FitToContents();
        }

        listItemContainer.FitToContents();
    }
예제 #29
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( this.ChildNodes.Count == 0 )
            return;

        style.Align = dfMarkupTextAlign.Left;

        var listContainer = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        container.AddChild( listContainer );

        calculateBulletWidth( style );

        for( int i = 0; i < ChildNodes.Count; i++ )
        {

            var child = ChildNodes[ i ] as dfMarkupTag;
            if( child == null || child.TagName != "li" )
            {
                continue;
            }

            child.PerformLayout( listContainer, style );

        }

        listContainer.FitToContents();
    }
예제 #30
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( Owner == null )
        {
            Debug.LogError( "Tag has no parent: " + this );
            return;
        }

        style = applyStyleAttributes( style );

        var sourceAttribute = findAttribute( "src" );
        if( sourceAttribute == null )
            return;

        var source = sourceAttribute.Value;

        var imageBox = createImageBox( Owner.Atlas, source, style );
        if( imageBox == null )
            return;

        var size = Vector2.zero;

        var heightAttribute = findAttribute( "height" );
        if( heightAttribute != null )
        {
            size.y = dfMarkupStyle.ParseSize( heightAttribute.Value, (int)imageBox.Size.y );
        }

        var widthAttribute = findAttribute( "width" );
        if( widthAttribute != null )
        {
            size.x = dfMarkupStyle.ParseSize( widthAttribute.Value, (int)imageBox.Size.x );
        }

        if( size.sqrMagnitude <= float.Epsilon )
        {
            size = imageBox.Size;
        }
        else if( size.x <= float.Epsilon )
        {
            size.x = size.y * ( imageBox.Size.x / imageBox.Size.y );
        }
        else if( size.y <= float.Epsilon )
        {
            size.y = size.x * ( imageBox.Size.y / imageBox.Size.x );
        }

        imageBox.Size = size;
        imageBox.Baseline = (int)size.y;

        container.AddChild( imageBox );
    }
예제 #31
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        var headingMargins = new dfMarkupBorders();

        var headingStyle = applyDefaultStyles( style, ref headingMargins );
        headingStyle = applyTextStyleAttributes( headingStyle );

        // Allow overriding of margins
        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            headingMargins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var headingBox = new dfMarkupBox( this, dfMarkupDisplayType.block, headingStyle );
        headingBox.Margins = headingMargins;

        container.AddChild( headingBox );

        base._PerformLayoutImpl( headingBox, headingStyle );
        headingBox.FitToContents();
    }
예제 #32
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        style = applyTextStyleAttributes( style );

        dfMarkupBox spanBox = container;

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {

            spanBox = new dfMarkupBox( this, dfMarkupDisplayType.inlineBlock, style );
            spanBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );

            // Span does not utilize top and bottom margins
            spanBox.Margins.top = 0;
            spanBox.Margins.bottom = 0;

            container.AddChild( spanBox );

        }

        for( int i = 0; i < ChildNodes.Count; i++ )
        {

            var child = ChildNodes[i];

            if( child is dfMarkupString )
            {

                var text = child as dfMarkupString;
                if( text.Text == "\n" )
                {
                    if( style.PreserveWhitespace )
                    {
                        spanBox.AddLineBreak();
                    }
                    continue;
                }

            }

            child.PerformLayout( spanBox, style );

        }
    }
예제 #33
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);
 }
예제 #34
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( style.Font == null )
            return;

        var effectiveText = style.PreserveWhitespace || !isWhitespace ? this.Text : " ";

        var box = dfMarkupBoxText.Obtain( this, dfMarkupDisplayType.inline, style );
        box.SetText( effectiveText );

        container.AddChild( box );
    }
예제 #35
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (this.ChildNodes.Count == 0)
        {
            return;
        }

        var containerWidth = container.Size.x;

        var listItemContainer = new dfMarkupBox(this, dfMarkupDisplayType.listItem, style);

        listItemContainer.Margins.top = 10;
        container.AddChild(listItemContainer);

        var list = this.Parent as dfMarkupTagList;

        if (list == null)
        {
            // If the list item is not contained in a list, process its
            // child elements as normal html elements
            base._PerformLayoutImpl(container, style);
            return;
        }

        style.VerticalAlign = dfMarkupVerticalAlign.Baseline;

        var bulletText = "•";

        if (list.TagName == "ol")
        {
            bulletText = container.Children.Count + ".";
        }

        var bulletBoxStyle = style;

        bulletBoxStyle.VerticalAlign = dfMarkupVerticalAlign.Baseline;
        bulletBoxStyle.Align         = dfMarkupTextAlign.Right;

        // TODO: Pre-measure bullet item size (for ordered lists) at the <UL> tag level
        var listBulletElement = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inlineBlock, bulletBoxStyle);

        listBulletElement.SetText(bulletText);
        listBulletElement.Width        = list.BulletWidth;
        listBulletElement.Margins.left = style.FontSize * 2;
        listItemContainer.AddChild(listBulletElement);

        var listItemBox        = new dfMarkupBox(this, dfMarkupDisplayType.inlineBlock, style);
        var listItemLeftMargin = style.FontSize;
        var listItemWidth      = containerWidth - listBulletElement.Size.x - listBulletElement.Margins.left - listItemLeftMargin;

        listItemBox.Size         = new Vector2(listItemWidth, listItemLeftMargin);
        listItemBox.Margins.left = (int)(style.FontSize * 0.5f);
        listItemContainer.AddChild(listItemBox);

        for (int i = 0; i < ChildNodes.Count; i++)
        {
            ChildNodes[i].PerformLayout(listItemBox, style);
        }

        listItemBox.FitToContents();

        // The listItemBox.Parent property will actually refer to an internal
        // linebox that hosts the listItemBox, which needs to be fit to the
        // contents of the list item box.
        if (listItemBox.Parent != null)
        {
            listItemBox.Parent.FitToContents();
        }

        listItemContainer.FitToContents();
    }