Esempio n. 1
0
        public override void Draw(NVGcontext ctx)
        {
            if (!this.enabled && this.pushed)
            {
                this.pushed = false;
            }

            if (m_Popup)
            {
                m_Popup.isVisible = this.pushed;
            }

            base.Draw(ctx);

            if (0 != this.chevronIcon)
            {
                Theme    style         = this.theme;
                byte[]   icon          = Fonts.GetIconUTF8(this.chevronIcon);
                NVGcolor currTextColor = GetCurrTextColor();
                int      currFontSize  = (0 <= this.fontSize) ? this.fontSize : style.buttonFontSize;
                int      fontFace      = Fonts.Get(style.fontIcons);

                NanoVG.nvgFontSize(ctx, currFontSize * 1.5f);
                NanoVG.nvgFontFace(ctx, fontFace);
                NanoVG.nvgFillColor(ctx, currTextColor);
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_MIDDLE));

                float   iw      = NanoVG.nvgTextBounds(ctx, 0f, 0f, icon, null);
                Vector2 iconPos = this.localPosition;
                iconPos.X += this.size.X - iw - 8;
                iconPos.Y += this.size.Y * 0.5f - 1;
                NanoVG.nvgText(ctx, iconPos.X, iconPos.Y, icon);
            }
        }
Esempio n. 2
0
        public static SizeF MeasureString(string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return(SizeF.Empty);
            }

            if (text.EndsWith(" "))
            {
                text = $"{text.Substring(0, text.Length - 1)}(";
            }
            NanoVG.nvgFontFace(MainWindow.Nvg, "sans");
            var sb = new float[4];

            try
            {
                NanoVG.nvgTextBounds(MainWindow.Nvg, 0, 0, text, sb);
            }
            catch (Exception e)
            {
                Lumberjack.Error($"NvgHelper::MeasureString: {e.Message}");
            }

            var sfw = sb[2] - sb[0];
            var sfh = sb[3] - sb[1];

            return(new SizeF(sfw, sfh));
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public override Vector2 GetPreferredSize(NVGcontext ctx)
        {
            if (string.IsNullOrEmpty(caption))
            {
                return(Vector2.Zero);
            }

            Vector2 ret          = Vector2.Zero;
            int     prefFontSize = GetPreferredFontSize();

            NanoVG.nvgFontFace(ctx, font);
            NanoVG.nvgFontSize(ctx, prefFontSize);

            int fixedWidth = (int)this.fixedSize.X;

            if (0 < fixedWidth)
            {
                Vector2 pos = this.localPosition;
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_TOP));
                NanoVG.nvgTextBoxBounds(ctx, pos.X, pos.Y, fixedWidth, caption, m_Bounds);

                ret.X = fixedWidth;
                ret.Y = (m_Bounds[3] - m_Bounds[1]);
            }
            else
            {
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_MIDDLE));
                ret.X = NanoVG.nvgTextBounds(ctx, 0, 0, caption, m_Bounds);
                ret.Y = prefFontSize;
            }
            return(ret);
        }
Esempio n. 5
0
        public override void Draw(NVGcontext ctx)
        {
            base.Draw(ctx);

            Theme   style = this.theme;
            Vector2 pos   = this.localPosition;
            Vector2 size  = this.size;

            if (!string.IsNullOrEmpty(this.caption))
            {
                int currFontSize = GetPreferredFontSize();
                if (0 < currFontSize)
                {
                    int      currFontFace  = Fonts.Get(this.theme.fontNormal);
                    NVGcolor currTextColor = this.enabled ? style.textColor : style.disabledTextColor;

                    NanoVG.nvgFontSize(ctx, currFontSize);
                    NanoVG.nvgFontFace(ctx, currFontFace);
                    NanoVG.nvgFillColor(ctx, currTextColor);
                    NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_MIDDLE));

                    NanoVG.nvgText(ctx, pos.X + size.Y * 1.2f + 5, pos.Y + this.size.Y * 0.5f, this.caption);
                }
            }

            Color4f col  = Color4f.Black;
            Color4f icol = this.pushed ? col.WithAlpha(100) : col.WithAlpha(32);
            Color4f ocol = col.WithAlpha(180);

            NVGpaint bg = NanoVG.nvgBoxGradient(ctx, pos.X + 1.5f, pos.Y + 1.5f
                                                , size.X - 2f, size.Y - 2f, 3f, 3f
                                                , icol.ToNVGColor()
                                                , ocol.ToNVGColor());

            NanoVG.nvgBeginPath(ctx);
            NanoVG.nvgRoundedRect(ctx, pos.X + 1f, pos.Y + 1f, size.Y - 2f, size.Y - 2f, 3f);
            NanoVG.nvgFillPaint(ctx, bg);
            NanoVG.nvgFill(ctx);

            if (this.check)
            {
                int      fontIcons = Fonts.Get(style.fontIcons);
                NVGcolor iconColor = this.enabled ? style.iconColor : style.disabledTextColor;
                NanoVG.nvgFontSize(ctx, 1.8f * size.Y);
                NanoVG.nvgFontFace(ctx, fontIcons);
                NanoVG.nvgFillColor(ctx, iconColor);
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_CENTER | NVGalign.NVG_ALIGN_MIDDLE));
                byte[] icon = Fonts.GetIconUTF8((int)Font.Entypo.ICON_CHECK);
                NanoVG.nvgText(ctx, pos.X + size.Y * 0.5f + 1f, pos.Y + size.Y * 0.5f, icon);
            }
        }
Esempio n. 6
0
        public static void RenderString(string s)
        {
            if (string.IsNullOrWhiteSpace(s))
            {
                return;
            }

            NanoVG.nvgTextAlign(MainWindow.Nvg, (int)NvgAlign.Top | (int)NvgAlign.Left);
            NanoVG.nvgFontSize(MainWindow.Nvg, 16);
            NanoVG.nvgFontFace(MainWindow.Nvg, "sans");
            try
            {
                NanoVG.nvgText(MainWindow.Nvg, 0, 0, s);
            }
            catch (Exception e)
            {
                Lumberjack.Error($"NvgHelper::RenderString: {e.Message}");
            }
        }
Esempio n. 7
0
        public override Vector2 GetPreferredSize(NVGcontext ctx)
        {
            if (!Vector2.Zero.Equals(this.fixedSize))
            {
                return(this.fixedSize);
            }

            int currFontSize = GetPreferredFontSize();
            int currFontFace = Fonts.Get(this.theme.fontNormal);

            NanoVG.nvgFontSize(ctx, currFontSize);
            NanoVG.nvgFontFace(ctx, currFontFace);

            float   tw = NanoVG.nvgTextBounds(ctx, 0f, 0f, this.caption, null);
            Vector2 ret;

            ret.X = tw + 1.7f * currFontSize;
            ret.Y = 1.3f * currFontSize;

            return(ret);
        }
Esempio n. 8
0
        public override Vector2 GetPreferredSize(NVGcontext ctx)
        {
            Vector2 ret;

            int prefFontSize = GetPreferredFontSize();

            NanoVG.nvgFontSize(ctx, prefFontSize);
            NanoVG.nvgFontFace(ctx, this.theme.fontBold);
            float tw = NanoVG.nvgTextBounds(ctx, 0f, 0f, this.caption, null);
            float iw = 0f;
            float ih = prefFontSize;

            int btnIcon = this.icon;

            if (0 < btnIcon)
            {
                if (NanoVG.nvgIsFontIcon(btnIcon))
                {
                    byte[] icon = Fonts.GetIconUTF8(btnIcon);
                    ih *= 1.5f;
                    NanoVG.nvgFontFace(ctx, this.theme.fontIcons);
                    NanoVG.nvgFontSize(ctx, ih);
                    iw = NanoVG.nvgTextBounds(ctx, 0f, 0f, icon, null) + this.size.Y * 0.15f;
                }
                else
                {
                    int w, h;
                    w   = h = 1;
                    ih *= 0.9f;
                    NanoVG.nvgImageSize(ctx, btnIcon, ref w, ref h);
                    iw = w * ih / h;
                }
            }
            ret.X = (int)(tw + iw) + 20;
            ret.Y = prefFontSize + 10;

            return(ret);
        }
Esempio n. 9
0
        public static void RenderGraph(NVGcontext vg, float x, float y)
        {
            int    i;
            float  avg, w, h;
            string str;

            avg = GetGraphAverage();

            w = 200;
            h = 35;

            NanoVG.nvgBeginPath(vg);
            NanoVG.nvgRect(vg, x, y, w, h);
            NanoVG.nvgFillColor(vg, NanoVG.nvgRGBA(0, 0, 0, 128));
            NanoVG.nvgFill(vg);

            NanoVG.nvgBeginPath(vg);
            NanoVG.nvgMoveTo(vg, x, y + h);
            if (style == (int)GraphrenderStyle.GRAPH_RENDER_FPS)
            {
                for (i = 0; i < GRAPH_HISTORY_COUNT; i++)
                {
                    float v = 1.0f / (0.00001f + values[(head + i) % GRAPH_HISTORY_COUNT]);
                    float vx, vy;
                    if (v > 80.0f)
                    {
                        v = 80.0f;
                    }
                    vx = x + ((float)i / (GRAPH_HISTORY_COUNT - 1)) * w;
                    vy = y + h - ((v / 80.0f) * h);
                    NanoVG.nvgLineTo(vg, vx, vy);
                }
            }
            else if (style == (int)GraphrenderStyle.GRAPH_RENDER_PERCENT)
            {
                for (i = 0; i < GRAPH_HISTORY_COUNT; i++)
                {
                    float v = values[(head + i) % GRAPH_HISTORY_COUNT] * 1.0f;
                    float vx, vy;
                    if (v > 100.0f)
                    {
                        v = 100.0f;
                    }
                    vx = x + ((float)i / (GRAPH_HISTORY_COUNT - 1)) * w;
                    vy = y + h - ((v / 100.0f) * h);
                    NanoVG.nvgLineTo(vg, vx, vy);
                }
            }
            else
            {
                for (i = 0; i < GRAPH_HISTORY_COUNT; i++)
                {
                    float v = values[(head + i) % GRAPH_HISTORY_COUNT] * 1000.0f;
                    float vx, vy;
                    if (v > 20.0f)
                    {
                        v = 20.0f;
                    }
                    vx = x + ((float)i / (GRAPH_HISTORY_COUNT - 1)) * w;
                    vy = y + h - ((v / 20.0f) * h);
                    NanoVG.nvgLineTo(vg, vx, vy);
                }
            }
            NanoVG.nvgLineTo(vg, x + w, y + h);
            NanoVG.nvgFillColor(vg, NanoVG.nvgRGBA(255, 192, 0, 128));
            NanoVG.nvgFill(vg);

            NanoVG.nvgFontFace(vg, "sans");

            if (name[0] != '\0')
            {
                NanoVG.nvgFontSize(vg, 14.0f);
                NanoVG.nvgTextAlign(vg, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_TOP));
                NanoVG.nvgFillColor(vg, NanoVG.nvgRGBA(240, 240, 240, 192));
                NanoVG.nvgText(vg, x + 3, y + 1, name);
            }

            if (style == (int)GraphrenderStyle.GRAPH_RENDER_FPS)
            {
                NanoVG.nvgFontSize(vg, 18.0f);
                NanoVG.nvgTextAlign(vg, (int)(NVGalign.NVG_ALIGN_RIGHT | NVGalign.NVG_ALIGN_TOP));
                NanoVG.nvgFillColor(vg, NanoVG.nvgRGBA(240, 240, 240, 255));
                str = String.Format("{0:0.00} FPS", 1.0f / avg);
                NanoVG.nvgText(vg, x + w - 3, y + 1, str);

                NanoVG.nvgFontSize(vg, 15.0f);
                NanoVG.nvgTextAlign(vg, (int)(NVGalign.NVG_ALIGN_RIGHT | NVGalign.NVG_ALIGN_BOTTOM));
                NanoVG.nvgFillColor(vg, NanoVG.nvgRGBA(240, 240, 240, 160));
                str = String.Format("{0:0.00} ms", avg * 1000.0f);
                NanoVG.nvgText(vg, x + w - 3, y + h - 1, str);
            }
            else if (style == (int)GraphrenderStyle.GRAPH_RENDER_PERCENT)
            {
                NanoVG.nvgFontSize(vg, 18.0f);
                NanoVG.nvgTextAlign(vg, (int)(NVGalign.NVG_ALIGN_RIGHT | NVGalign.NVG_ALIGN_TOP));
                NanoVG.nvgFillColor(vg, NanoVG.nvgRGBA(240, 240, 240, 255));
                str = String.Format("{0:0.0} %", avg * 1.0f);
                NanoVG.nvgText(vg, x + w - 3, y + 1, str);
            }
            else
            {
                NanoVG.nvgFontSize(vg, 18.0f);
                NanoVG.nvgTextAlign(vg, (int)(NVGalign.NVG_ALIGN_RIGHT | NVGalign.NVG_ALIGN_TOP));
                NanoVG.nvgFillColor(vg, NanoVG.nvgRGBA(240, 240, 240, 255));
                str = String.Format("{0:0.00} ms", avg * 1000.0f);
                NanoVG.nvgText(vg, x + w - 3, y + 1, str);
            }
        }
Esempio n. 10
0
        public override void Draw(NVGcontext ctx)
        {
            Theme style = this.theme;
            int   ds    = style.windowDropShadowSize;
            int   cr    = style.windowCornerRadius;
            int   hh    = style.windowHeaderHeight;

            Vector2 pos  = this.localPosition;
            Vector2 size = this.size;

            NanoVG.nvgSave(ctx);
            NanoVG.nvgBeginPath(ctx);
            NanoVG.nvgRoundedRect(ctx, pos.X, pos.Y, size.X, size.Y, cr);
            NanoVG.nvgFillColor(ctx, this.mouseFocus ? style.windowFillFocusedColor
                                 : style.windowFillUnfocusedColor);

            NanoVG.nvgFill(ctx);

            NVGpaint shadowPaint = NanoVG.nvgBoxGradient(ctx
                                                         , pos.X, pos.Y, size.X, size.Y
                                                         , cr * 2, ds * 2
                                                         , style.dropShadowColor
                                                         , style.transparentColor);

            NanoVG.nvgBeginPath(ctx);
            NanoVG.nvgRect(ctx, pos.X - ds, pos.Y - ds, size.X + 2 * ds, size.Y + 2 * ds);
            NanoVG.nvgRoundedRect(ctx, pos.X, pos.Y, size.X, size.Y, cr);
            NanoVG.nvgPathWinding(ctx, (int)NVGsolidity.NVG_HOLE);
            NanoVG.nvgFillPaint(ctx, shadowPaint);
            NanoVG.nvgFill(ctx);

            // draw header.
            if (!string.IsNullOrEmpty(this.title))
            {
                NVGpaint headerPaint = NanoVG.nvgLinearGradient(
                    ctx
                    , pos.X, pos.Y, pos.X, pos.Y + hh
                    , style.windowHeaderGradientTopColor
                    , style.windowHeaderGradientBotColor
                    );

                NanoVG.nvgBeginPath(ctx);
                NanoVG.nvgRoundedRect(ctx, pos.X, pos.Y, size.X, hh, cr);
                NanoVG.nvgFillPaint(ctx, headerPaint);
                NanoVG.nvgFill(ctx);

                NanoVG.nvgBeginPath(ctx);
                NanoVG.nvgRoundedRect(ctx, pos.X, pos.Y, size.X, hh, cr);
                NanoVG.nvgStrokeColor(ctx, style.windowHeaderSepTopColor);

                NanoVG.nvgSave(ctx);
                NanoVG.nvgIntersectScissor(ctx, pos.X, pos.Y, size.X, 0.5f);
                NanoVG.nvgStroke(ctx);
                NanoVG.nvgResetScissor(ctx);
                NanoVG.nvgRestore(ctx);

                NanoVG.nvgBeginPath(ctx);
                NanoVG.nvgMoveTo(ctx, pos.X + 0.5f, pos.Y + hh - 1.5f);
                NanoVG.nvgLineTo(ctx, pos.X + size.X - 0.5f, pos.Y + hh - 1.5f);
                NanoVG.nvgStrokeColor(ctx, style.windowHeaderSepBotColor);
                NanoVG.nvgStroke(ctx);

                NanoVG.nvgFontSize(ctx, style.standardFontSize + 2f);
                NanoVG.nvgFontFace(ctx, style.fontBold);
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_CENTER | NVGalign.NVG_ALIGN_MIDDLE));

                Vector2 headerTextPos;
                headerTextPos.X = pos.X + size.X * 0.5f;
                headerTextPos.Y = pos.Y + hh * 0.5f;

                NanoVG.nvgFontBlur(ctx, 2f);
                NanoVG.nvgFillColor(ctx, style.dropShadowColor);
                NanoVG.nvgText(ctx, headerTextPos.X, headerTextPos.Y, this.title);

                NanoVG.nvgFontBlur(ctx, 0f);
                NanoVG.nvgFillColor(ctx, this.focused ? style.windowTitleFocusedColor
                                     : style.windowTitleUnfocusedColor);
                NanoVG.nvgText(ctx, headerTextPos.X, headerTextPos.Y - 1f, this.title);
            }

            NanoVG.nvgRestore(ctx);
            base.Draw(ctx);
        }
Esempio n. 11
0
        public override void Draw(NVGcontext ctx)
        {
            base.Draw(ctx);

            Theme style = this.theme;

            NVGcolor gradTopColor = style.buttonGradientTopUnfocusedColor;
            NVGcolor gradBotColor = style.buttonGradientBotUnfocusedColor;

            if (this.pushed)
            {
                gradTopColor = style.buttonGradientTopPushedColor;
                gradBotColor = style.buttonGradientBotPushedColor;
            }
            else
            {
                gradTopColor = style.buttonGradientTopFocusedColor;
                gradBotColor = style.buttonGradientBotFocusedColor;
            }

            Vector2 pos  = this.localPosition;
            Vector2 size = this.size;

            NanoVG.nvgBeginPath(ctx);
            NanoVG.nvgRoundedRect(ctx, pos.X + 1f, pos.Y + 1f, size.X - 2f, size.Y - 2f
                                  , style.buttonCornerRadius - 1f);

            NanoVG.nvgFillColor(ctx, gradTopColor);
            NanoVG.nvgFill(ctx);

            if (0f < this.backgroundColor.a)
            {
                // fill background.
            }

            NVGpaint gradient = NanoVG.nvgLinearGradient(ctx, pos.X, pos.Y, pos.X, pos.Y + size.Y
                                                         , gradTopColor, gradBotColor);

            NanoVG.nvgFillPaint(ctx, gradient);
            NanoVG.nvgFill(ctx);

            NanoVG.nvgBeginPath(ctx);
            NanoVG.nvgStrokeWidth(ctx, 1f);
            NanoVG.nvgRoundedRect(ctx, pos.X + 0.5f, pos.Y + (this.pushed ? 0.5f : 1.5f)
                                  , size.X - 1f, size.Y - 1 - (this.pushed ? 0f : 1f)
                                  , style.buttonCornerRadius);
            NanoVG.nvgStrokeColor(ctx, style.borderLightColor);
            NanoVG.nvgStroke(ctx);

            NanoVG.nvgBeginPath(ctx);
            NanoVG.nvgRoundedRect(ctx, pos.X + 0.5f, pos.Y + 0.5f
                                  , size.X - 1f, size.Y - 2f
                                  , style.buttonCornerRadius);
            NanoVG.nvgStrokeColor(ctx, style.borderDarkColor);
            NanoVG.nvgStroke(ctx);

            int currFontSize = 0 > this.fontSize ? style.buttonFontSize : this.fontSize;

            NanoVG.nvgFontSize(ctx, currFontSize);
            NanoVG.nvgFontFace(ctx, style.fontBold);

            float    tw            = NanoVG.nvgTextBounds(ctx, 0f, 0f, this.caption, null);
            Vector2  center        = pos + size * 0.5f;
            Vector2  textPos       = new Vector2(center.X - tw * 0.5f, center.Y - 1f);
            NVGcolor currTextColor = GetCurrTextColor();

            int btnIcon = this.icon;

            if (0 != btnIcon)
            {
                float iw, ih;
                iw = 0f;
                ih = currFontSize;
                byte[] icon = Fonts.GetIconUTF8(btnIcon);
                if (NanoVG.nvgIsFontIcon(btnIcon))
                {
                    ih *= 1.5f;
                    NanoVG.nvgFontSize(ctx, ih);
                    NanoVG.nvgFontFace(ctx, style.fontIcons);
                    iw = NanoVG.nvgTextBounds(ctx, 0, 0, icon, null);
                }
                else
                {
                    int w, h;
                    w   = h = 1;
                    ih *= 0.9f;
                    NanoVG.nvgImageSize(ctx, btnIcon, ref w, ref h);
                    if (0 < h)
                    {
                        iw = w * ih / h;
                    }
                }

                if (!string.IsNullOrEmpty(this.caption))
                {
                    iw += size.Y * 0.15f;
                }
                NanoVG.nvgFillColor(ctx, currTextColor);
                NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_MIDDLE));
                Vector2 iconPos = center;
                iconPos.Y -= 1f;

                switch (this.iconAnchorType)
                {
                case IconAnchorType.LeftCentered:
                {
                    iconPos.X -= (tw + iw) * 0.5f;
                    textPos.X += iw * 0.5f;
                }
                break;

                case IconAnchorType.RightCentered:
                {
                    textPos.X -= iw * 0.5f;
                    iconPos.X += tw * 0.5f;
                }
                break;

                case IconAnchorType.Left:
                {
                    iconPos.X = pos.X + 8f;
                }
                break;

                case IconAnchorType.Right:
                {
                    iconPos.X = pos.X + size.X - iw - 8f;
                }
                break;

                default:
                    break;
                }

                if (NanoVG.nvgIsFontIcon(btnIcon))
                {
                    // NOTE: icon rendering bug, any unicode > 0x10000 not being rendered correctly.
                    //       e.g. 0x1F680 (Font.Entypo.ICON_ROCKET).
                    NanoVG.nvgText(ctx, iconPos.X, iconPos.Y + 1f, icon);
                }
                else
                {
                    float    imgAlpha = this.enabled ? 0.5f : 0.25f;
                    NVGpaint imgPaint = NanoVG.nvgImagePattern(
                        ctx
                        , iconPos.X, iconPos.Y - ih * 0.5f, iw, ih
                        , 0f, btnIcon, imgAlpha);
                    NanoVG.nvgFillPaint(ctx, imgPaint);
                    NanoVG.nvgFill(ctx);
                }

                // DEBUG: ICON BOUNDS
                //NanoVG.nvgStrokeWidth (ctx, 1.0f);
                //NanoVG.nvgBeginPath (ctx);
                //NanoVG.nvgRect (ctx, iconPos.X, iconPos.Y - ih * 0.5f, iw, ih);
                //NanoVG.nvgStrokeColor (ctx, textColor);
                //NanoVG.nvgStroke(ctx);
            }

            NanoVG.nvgFontSize(ctx, currFontSize);
            NanoVG.nvgFontFace(ctx, style.fontBold);
            NanoVG.nvgTextAlign(ctx, (int)(NVGalign.NVG_ALIGN_LEFT | NVGalign.NVG_ALIGN_MIDDLE));
            NanoVG.nvgFillColor(ctx, style.textShadowColor);
            NanoVG.nvgText(ctx, textPos.X, textPos.Y, this.caption);
            NanoVG.nvgFillColor(ctx, currTextColor);
            NanoVG.nvgText(ctx, textPos.X, textPos.Y + 1f, this.caption);
        }