Beispiel #1
0
        public override void Draw(NVGcontext ctx)
        {
            base.Draw(ctx);

            if (0 > m_FontId)
            {
                return;
            }
            int prefFontSize = GetPreferredFontSize();

            NanoVG.nvgFontFace(ctx, m_FontId);
            NanoVG.nvgFontSize(ctx, prefFontSize);
            NanoVG.nvgFillColor(ctx, this.color);

            int     fixedWidth = (int)this.fixedSize.X;
            Vector2 pos        = this.localPosition;

            if (0 < fixedWidth)
            {
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_TOP));
                NanoVG.nvgTextBox(ctx, pos.X, pos.Y, fixedWidth, caption);
            }
            else
            {
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_MIDDLE));
                NanoVG.nvgText(ctx, pos.X, pos.Y + this.size.Y * 0.5f, caption);
            }

            // DEBUG: BOUNDS
            //NanoVG.nvgStrokeWidth (ctx, 1.0f);
            //NanoVG.nvgBeginPath (ctx);
            //NanoVG.nvgRect (ctx, pos.X, pos.Y, this.size.X, this.size.Y);
            //NanoVG.nvgStrokeColor (ctx, this.color);
            //NanoVG.nvgStroke(ctx);
        }