Ejemplo n.º 1
0
        public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback = true)
        {
            var metrics = Handle.GetCharMetrics(rune, scale);

            if (!metrics.HasValue)
            {
                if (fallback && !Rune.IsWhiteSpace(rune))
                {
                    rune    = new Rune('�');
                    metrics = Handle.GetCharMetrics(rune, scale);
                    if (!metrics.HasValue)
                    {
                        return(0);
                    }
                }
                else
                {
                    return(0);
                }
            }

            var texture = Handle.GetCharTexture(rune, scale);

            if (texture == null)
            {
                return(metrics.Value.Advance);
            }

            baseline += new Vector2(metrics.Value.BearingX, -metrics.Value.BearingY);
            handle.DrawTexture(texture, baseline, color);
            return(metrics.Value.Advance);
        }
Ejemplo n.º 2
0
        protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box)
        {
            var(btl, btt, btr, btb) = BorderThickness;
            if (btl > 0)
            {
                handle.DrawRect(new UIBox2(box.Left, box.Top, box.Left + btl, box.Bottom), BorderColor);
            }

            if (btt > 0)
            {
                handle.DrawRect(new UIBox2(box.Left, box.Top, box.Right, box.Top + btt), BorderColor);
            }

            if (btr > 0)
            {
                handle.DrawRect(new UIBox2(box.Right - btr, box.Top, box.Right, box.Bottom), BorderColor);
            }

            if (btb > 0)
            {
                handle.DrawRect(new UIBox2(box.Left, box.Bottom - btb, box.Right, box.Bottom), BorderColor);
            }

            handle.DrawRect(BorderThickness.Deflate(box), BackgroundColor);
        }
Ejemplo n.º 3
0
        // DrawChar just proxies to the stack, or invokes _main's fallback.
        public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback = true)
        {
            foreach (var f in Stack)
            {
                var w = f.DrawChar(handle, rune, baseline, scale, color, fallback: false);
                if (w != 0f)
                {
                    return(w);
                }
            }

            if (fallback)
            {
                return(_main.DrawChar(handle, rune, baseline, scale, color, fallback: true));
            }

            return(0f);
        }
Ejemplo n.º 4
0
        public override float DrawChar(DrawingHandleScreen handle, char chr, Vector2 baseline, float scale, Color color)
        {
            var metrics = Handle.GetCharMetrics(chr, scale);

            if (!metrics.HasValue)
            {
                return(0);
            }

            var texture = Handle.GetCharTexture(chr, scale);

            if (texture == null)
            {
                return(metrics.Value.Advance);
            }

            baseline += new Vector2(metrics.Value.BearingX, -metrics.Value.BearingY);
            handle.DrawTexture(texture, baseline, color);
            return(metrics.Value.Advance);
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Draw a character at a certain baseline position on screen.
 /// </summary>
 /// <param name="handle">The drawing handle to draw to.</param>
 /// <param name="rune">The Unicode code point to draw.</param>
 /// <param name="baseline">The baseline from which to draw the character.</param>
 /// <param name="scale">DPI scale factor to render the font at.</param>
 /// <param name="color">The color of the character to draw.</param>
 /// <param name="fallback">If the character is not available, render "�" instead.</param>
 /// <returns>How much to advance the cursor to draw the next character.</returns>
 public abstract float DrawChar(
     DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale,
     Color color, bool fallback = true);
Ejemplo n.º 6
0
 public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback = true)
 {
     // Nada, it's a dummy after all.
     return(0);
 }
Ejemplo n.º 7
0
 protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box)
 {
     handle.DrawRect(box, BackgroundColor);
 }
Ejemplo n.º 8
0
 protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box)
 {
     // It's empty what more do you want?
 }
Ejemplo n.º 9
0
 public float DrawChar(DrawingHandleScreen handle, char chr, Vector2 baseline, float scale, Color color)
 {
     return(DrawChar(handle, (Rune)chr, baseline, scale, color));
 }
Ejemplo n.º 10
0
 public abstract float DrawChar(DrawingHandleScreen handle, char chr, Vector2 baseline, float scale,
                                Color color);
Ejemplo n.º 11
0
 public override float DrawChar(DrawingHandleScreen handle, char chr, Vector2 baseline, float scale, Color color)
 {
     // Nada, it's a dummy after all.
     return(0);
 }