Example #1
0
    private void processMarkup()
    {
        this.releaseMarkupReferences();
        this.elements = dfMarkupParser.Parse(this, this.text);
        float         num   = this.getTextScaleMultiplier();
        int           num2  = Mathf.CeilToInt(this.FontSize * num);
        int           num3  = Mathf.CeilToInt(this.LineHeight * num);
        dfMarkupStyle style = new dfMarkupStyle {
            Host               = this,
            Atlas              = this.Atlas,
            Font               = this.Font,
            FontSize           = num2,
            FontStyle          = this.FontStyle,
            LineHeight         = num3,
            Color              = (Color)base.ApplyOpacity(base.Color),
            Opacity            = base.CalculateOpacity(),
            Align              = this.TextAlignment,
            PreserveWhitespace = this.preserveWhitespace
        };
        dfMarkupBox box = new dfMarkupBox(null, dfMarkupDisplayType.block, style)
        {
            Size = base.Size
        };

        this.viewportBox = box;
        for (int i = 0; i < this.elements.Count; i++)
        {
            dfMarkupElement element = this.elements[i];
            if (element != null)
            {
                element.PerformLayout(this.viewportBox, style);
            }
        }
    }
Example #2
0
 public dfMarkupBox(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
 {
     this.Element = element;
     this.Display = display;
     this.Style = style;
     this.Baseline = style.FontSize;
 }
Example #3
0
    private dfMarkupElement parseElement(Queue <dfMarkupElement> tokens)
    {
        dfMarkupElement element = tokens.Dequeue();

        if (element is dfMarkupString)
        {
            return(((dfMarkupString)element).SplitWords());
        }
        dfMarkupTag original = (dfMarkupTag)element;

        if (!original.IsClosedTag && !original.IsEndTag)
        {
            while (tokens.Count > 0)
            {
                dfMarkupElement node = this.parseElement(tokens);
                if (node is dfMarkupTag)
                {
                    dfMarkupTag tag2 = (dfMarkupTag)node;
                    if (tag2.IsEndTag)
                    {
                        if (tag2.TagName == original.TagName)
                        {
                            break;
                        }
                        return(this.refineTag(original));
                    }
                }
                original.AddChildNode(node);
            }
        }
        return(this.refineTag(original));
    }
Example #4
0
    private dfMarkupElement parseElement(Queue <dfMarkupElement> tokens)
    {
        dfMarkupElement _dfMarkupElement = tokens.Dequeue();

        if (_dfMarkupElement is dfMarkupString)
        {
            return(((dfMarkupString)_dfMarkupElement).SplitWords());
        }
        dfMarkupTag _dfMarkupTag = (dfMarkupTag)_dfMarkupElement;

        if (_dfMarkupTag.IsClosedTag || _dfMarkupTag.IsEndTag)
        {
            return(this.refineTag(_dfMarkupTag));
        }
        while (tokens.Count > 0)
        {
            dfMarkupElement _dfMarkupElement1 = this.parseElement(tokens);
            if (_dfMarkupElement1 is dfMarkupTag)
            {
                dfMarkupTag _dfMarkupTag1 = (dfMarkupTag)_dfMarkupElement1;
                if (_dfMarkupTag1.IsEndTag)
                {
                    if (_dfMarkupTag1.TagName != _dfMarkupTag.TagName)
                    {
                        return(this.refineTag(_dfMarkupTag));
                    }
                    break;
                }
            }
            _dfMarkupTag.AddChildNode(_dfMarkupElement1);
        }
        return(this.refineTag(_dfMarkupTag));
    }
Example #5
0
 public dfMarkupBox(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
 {
     this.Element  = element;
     this.Display  = display;
     this.Style    = style;
     this.Baseline = style.FontSize;
 }
Example #6
0
 public dfMarkupBox(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
 {
     this.Position = Vector2.zero;
     this.Size     = Vector2.zero;
     this.Margins  = new dfMarkupBorders(0, 0, 0, 0);
     this.Padding  = new dfMarkupBorders(0, 0, 0, 0);
     this.children = new System.Collections.Generic.List <dfMarkupBox>();
     this.Element  = element;
     this.Display  = display;
     this.Style    = style;
     this.Baseline = style.FontSize;
 }
Example #7
0
 public dfMarkupTag(dfMarkupTag original)
 {
     this.TagName     = original.TagName;
     this.Attributes  = original.Attributes;
     this.IsEndTag    = original.IsEndTag;
     this.IsClosedTag = original.IsClosedTag;
     this.IsInline    = original.IsInline;
     this.id          = original.id;
     System.Collections.Generic.List <dfMarkupElement> childNodes = original.ChildNodes;
     for (int i = 0; i < childNodes.Count; i++)
     {
         dfMarkupElement node = childNodes[i];
         base.AddChildNode(node);
     }
 }
Example #8
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         dfMarkupElement item = base.ChildNodes[i];
         if (!(item is dfMarkupString) || !((item as dfMarkupString).Text == "\n"))
         {
             item.PerformLayout(container, style);
         }
         else if (style.PreserveWhitespace)
         {
             container.AddLineBreak();
         }
     }
 }
Example #9
0
    private dfMarkupTag hitTestTag(dfMouseEventArgs args)
    {
        Vector2     point = base.GetHitPosition(args) + this.scrollPosition;
        dfMarkupBox box   = this.viewportBox.HitTest(point);

        if (box == null)
        {
            return(null);
        }
        dfMarkupElement parent = box.Element;

        while ((parent != null) && !(parent is dfMarkupTag))
        {
            parent = parent.Parent;
        }
        return(parent as dfMarkupTag);
    }
Example #10
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;
 }
Example #11
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));
 }
Example #12
0
    private dfMarkupTag hitTestTag(dfMouseEventArgs args)
    {
        Vector2     hitPosition  = base.GetHitPosition(args) + this.scrollPosition;
        dfMarkupBox _dfMarkupBox = this.viewportBox.HitTest(hitPosition);

        if (_dfMarkupBox == null)
        {
            return(null);
        }
        dfMarkupElement element = _dfMarkupBox.Element;

        while (element != null && !(element is dfMarkupTag))
        {
            element = element.Parent;
        }
        return(element as dfMarkupTag);
    }
Example #13
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);
    }
Example #14
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         dfMarkupElement element = base.ChildNodes[i];
         if (element is dfMarkupString)
         {
             dfMarkupString str = element as dfMarkupString;
             if (str.Text == "\n")
             {
                 if (style.PreserveWhitespace)
                 {
                     container.AddLineBreak();
                 }
                 continue;
             }
         }
         element.PerformLayout(container, style);
     }
 }
Example #15
0
    private void processMarkup()
    {
        this.releaseMarkupReferences();
        this.elements = dfMarkupParser.Parse(this, this.text);
        float         textScaleMultiplier = this.getTextScaleMultiplier();
        int           num            = Mathf.CeilToInt((float)this.FontSize * textScaleMultiplier);
        int           num1           = Mathf.CeilToInt((float)this.LineHeight * textScaleMultiplier);
        dfMarkupStyle _dfMarkupStyle = new dfMarkupStyle();
        dfMarkupStyle atlas          = _dfMarkupStyle;

        atlas.Host               = this;
        atlas.Atlas              = this.Atlas;
        atlas.Font               = this.Font;
        atlas.FontSize           = num;
        atlas.FontStyle          = this.FontStyle;
        atlas.LineHeight         = num1;
        atlas.Color              = base.ApplyOpacity(base.Color);
        atlas.Opacity            = base.CalculateOpacity();
        atlas.Align              = this.TextAlignment;
        atlas.PreserveWhitespace = this.preserveWhitespace;
        _dfMarkupStyle           = atlas;
        dfMarkupBox _dfMarkupBox = new dfMarkupBox(null, dfMarkupDisplayType.block, _dfMarkupStyle)
        {
            Size = base.Size
        };

        this.viewportBox = _dfMarkupBox;
        for (int i = 0; i < this.elements.Count; i++)
        {
            dfMarkupElement item = this.elements[i];
            if (item != null)
            {
                item.PerformLayout(this.viewportBox, _dfMarkupStyle);
            }
        }
    }
Example #16
0
 public void AddChildNode(dfMarkupElement node)
 {
     node.Parent = this;
     ChildNodes.Add(node);
 }
Example #17
0
 public void AddChildNode( dfMarkupElement node )
 {
     node.Parent = this;
     ChildNodes.Add( node );
 }
Example #18
0
        public static dfMarkupBoxText Obtain( dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style )
        {

        if( objectPool.Count > 0 )
        {

            var instance = objectPool.Dequeue();

            instance.Element = element;
            instance.Display = display;
            instance.Style = style;

            instance.Position = Vector2.zero;
            instance.Size = Vector2.zero;

            instance.Baseline = (int)( style.FontSize * 1.1f );
            instance.Margins = new dfMarkupBorders();
            instance.Padding = new dfMarkupBorders();

            return instance;

        }

        return new dfMarkupBoxText( element, display, style );

        }
Example #19
0
 public dfMarkupBoxText( dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style )
 : base( element, display, style )
 {
 }
Example #20
0
 public dfMarkupBoxTexture(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style) : base(element, display, style)
 {
     this.renderData = new dfRenderData(0x20);
 }
Example #21
0
 public dfMarkupBoxSprite(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style) : base(element, display, style)
 {
 }
Example #22
0
 internal virtual void Release()
 {
     this.Parent = null;
     this.ChildNodes.Clear();
 }