Beispiel #1
0
        private void DrawWindow(string title, float x, float y, float w, float h)
        {
            const float cornerRadius = 3.0f;

            _nvg.Save();

            _nvg.BeginPath();
            _nvg.RoundedRect(x, y, w, h, cornerRadius);
            _nvg.FillColour(_nvg.Rgba(28, 30, 34, 192));
            _nvg.Fill();

            Paint shadowPaint = Paint.BoxGradient(x, y + 2.0f, w, h, cornerRadius * 2.0f, 10.0f, _nvg.Rgba(0, 0, 0, 128), _nvg.Rgba(0, 0, 0, 0));

            _nvg.BeginPath();
            _nvg.Rect(x - 10.0f, y - 10.0f, w + 20.0f, h + 30.0f);
            _nvg.RoundedRect(x, y, w, h, cornerRadius);
            _nvg.PathWinding(Solidity.Hole);
            _nvg.FillPaint(shadowPaint);
            _nvg.Fill();

            Paint headerPaint = _nvg.LinearGradient(x, y, x, y + 15.0f, _nvg.Rgba(255, 255, 255, 8), _nvg.Rgba(0, 0, 0, 16));

            _nvg.BeginPath();
            _nvg.RoundedRect(x + 1.0f, y + 1.0f, w - 2.0f, 30.0f, cornerRadius - 1.0f);
            _nvg.FillPaint(headerPaint);
            _nvg.Fill();
            _nvg.BeginPath();
            _nvg.MoveTo(x + 0.5f, y + 0.5f + 30.0f);
            _nvg.LineTo(x + 0.5f + w - 1.0f, y + 0.5f + 30.0f);
            _nvg.StrokeColour(_nvg.Rgba(0, 0, 0, 30));
            _nvg.Stroke();

            _nvg.FontSize(15.0f);
            _nvg.FontFace("sans-bold");
            _nvg.TextAlign(Align.Centre | Align.Middle);

            _nvg.FontBlur(2.0f);
            _nvg.FillColour(_nvg.Rgba(0, 0, 0, 128));
            _ = _nvg.Text(x + w / 2.0f, y + 16.0f + 1.0f, title);

            _nvg.FontBlur(0);
            _nvg.FillColour(_nvg.Rgba(220, 220, 220, 160));
            _ = _nvg.Text(x + w / 2.0f, y + 16.0f, title);

            _nvg.Restore();
        }
Beispiel #2
0
        private void DrawCheckBox(string text, float x, float y, float _, float h)
        {
            _nvg.FontSize(15.0f);
            _nvg.FontFace("sans");
            _nvg.FillColour(_nvg.Rgba(255, 255, 255, 160));

            _nvg.TextAlign(Align.Left | Align.Middle);
            _nvg.Text(x + 28.0f, y + h * 0.5f, text);

            Paint bg = Paint.BoxGradient(x + 1.0f, y + (int)(h * 0.5f) - 9 + 1, 18.0f, 18.0f, 3.0f, 3.0f, _nvg.Rgba(0, 0, 0, 32), _nvg.Rgba(0, 0, 0, 92));

            _nvg.BeginPath();
            _nvg.RoundedRect(x + 1.0f, y + (int)(h * 0.5f) - 9, 18.0f, 18.0f, 3.0f);
            _nvg.FillPaint(bg);
            _nvg.Fill();

            _nvg.FontSize(33.0f);
            _nvg.FontFace("icons");
            _nvg.FillColour(_nvg.Rgba(255, 255, 255, 128));
            _nvg.TextAlign(Align.Centre | Align.Middle);
            _nvg.Text(x + 9.0f + 2.0f, y + h * 0.5f, CpToUTF8(ICON_CHECK));
        }
Beispiel #3
0
        private void DrawThumbnails(float x, float y, float w, float h, int[] images, float t)
        {
            const float cornerRadius = 3.0f;
            const float thumb        = 60.0f;
            const float arry         = 30.5f;
            float       stackh       = (images.Length / 2) * (thumb + 10.0f) + 10.0f;
            float       u            = (1.0f + MathF.Cos(t * 0.5f)) * 0.5f;
            float       u2           = (1.0f - MathF.Cos(t * 0.2f)) * 0.5f;

            _nvg.Save();

            Paint shadowPaint = _nvg.BoxGradient(x, y + 4.0f, w, h, cornerRadius * 2.0f, 20.0f, _nvg.Rgba(0, 0, 0, 128), _nvg.Rgba(0, 0, 0, 0));

            _nvg.BeginPath();
            _nvg.Rect(x - 10.0f, y - 10.0f, w + 20.0f, h + 30.0f);
            _nvg.RoundedRect(x, y, w, h, cornerRadius);
            _nvg.PathWinding(Solidity.Hole);
            _nvg.FillPaint(shadowPaint);
            _nvg.Fill();

            _nvg.BeginPath();
            _nvg.RoundedRect(x, y, w, h, cornerRadius);
            _nvg.MoveTo(x - 10.0f, y + arry);
            _nvg.LineTo(x + 1.0f, y + arry - 11.0f);
            _nvg.LineTo(x + 1.0f, y + arry + 11.0f);
            _nvg.FillColour(_nvg.Rgba(200, 200, 200, 255));
            _nvg.Fill();

            _nvg.Save();
            _nvg.Scissor(x, y, w, h);
            _nvg.Translate(0, -(stackh - h) * u);

            float dv = 1.0f / (float)(images.Length - 1);

            for (uint i = 0; i < images.Length; i++)
            {
                float iw, ih;
                float ix, iy;
                float tx = x + 10.0f;
                float ty = y + 10.0f;
                tx += (i % 2) * (thumb + 10.0f);
                ty += (i / 2) * (thumb + 10.0f);
                _nvg.ImageSize(images[i], out uint imgW, out uint imgH);
                if (imgW < imgH)
                {
                    iw = thumb;
                    ih = iw * (float)imgH / (float)imgW;
                    ix = 0.0f;
                    iy = -(ih - thumb) * 0.5f;
                }
                else
                {
                    ih = thumb;
                    iw = ih * (float)imgW / (float)imgH;
                    ix = -(iw - thumb) * 0.5f;
                    iy = 0.0f;
                }

                float v = i * dv;
                float a = Clamp((u2 - v) / dv, 0.0f, 1.0f);

                if (a < 1.0f)
                {
                    DrawSpinner(tx + thumb / 2.0f, ty + thumb / 2.0f, thumb * 0.25f, t);
                }

                Paint imgPaint = Paint.ImagePattern(tx + ix, ty + iy, iw, ih, 0.0f / 180.0f * MathF.PI, images[i], a);
                _nvg.BeginPath();
                _nvg.RoundedRect(tx, ty, thumb, thumb, 5.0f);
                _nvg.FillPaint(imgPaint);
                _nvg.Fill();

                shadowPaint = Paint.BoxGradient(tx - 1.0f, ty, thumb + 2.0f, thumb + 2.0f, 5.0f, 3.0f, _nvg.Rgba(0, 0, 0, 128), _nvg.Rgba(0, 0, 0, 0));
                _nvg.BeginPath();
                _nvg.Rect(tx - 5.0f, ty - 5.0f, thumb + 10.0f, thumb + 10.0f);
                _nvg.RoundedRect(tx, ty, thumb, thumb, 6.0f);
                _nvg.PathWinding(Solidity.Hole);
                _nvg.FillPaint(shadowPaint);
                _nvg.Fill();

                _nvg.BeginPath();
                _nvg.RoundedRect(tx + 0.5f, ty + 0.5f, thumb - 1.0f, thumb - 1.0f, 4.0f - 0.5f);
                _nvg.StrokeWidth(1.0f);
                _nvg.StrokeColour(_nvg.Rgba(255, 255, 255, 192));
                _nvg.Fill();
            }
            _nvg.Restore();

            Paint fadePaint = _nvg.LinearGradient(x, y, x, y + 6.0f, _nvg.Rgba(200, 200, 200, 255), _nvg.Rgba(200, 200, 200, 0));

            _nvg.BeginPath();
            _nvg.Rect(x + 4.0f, y, w - 8.0f, 6.0f);
            _nvg.FillPaint(fadePaint);
            _nvg.Fill();

            fadePaint = _nvg.LinearGradient(x, y + h, x, y + h - 6.0f, _nvg.Rgba(200, 200, 200, 255), _nvg.Rgba(200, 200, 200, 0));
            _nvg.BeginPath();
            _nvg.Rect(x + 4.0f, y + h - 6.0f, w - 8.0f, 6.0f);
            _nvg.FillPaint(fadePaint);
            _nvg.Fill();

            shadowPaint = _nvg.BoxGradient(x + w - 12.0f + 1.0f, y + 4.0f + 1.0f, 8.0f, h - 8.0f, 3.0f, 4.0f, _nvg.Rgba(0, 0, 0, 32), _nvg.Rgba(0, 0, 0, 92));
            _nvg.BeginPath();
            _nvg.RoundedRect(x + w - 12.0f, y + 4.0f, 8.0f, h - 8.0f, 3.0f);
            _nvg.FillPaint(shadowPaint);
            _nvg.Fill();

            float scrollH = (h / stackh) * (h - 8.0f);

            shadowPaint = _nvg.BoxGradient(x + w - 12.0f - 1.0f, y + 4.0f + (h - 8.0f - scrollH) * u - 1.0f, 8.0f, scrollH, 3.0f, 4.0f, _nvg.Rgba(220, 220, 220, 255), _nvg.Rgba(128, 128, 128, 255));
            _nvg.BeginPath();
            _nvg.RoundedRect(x + w - 12.0f + 1.0f, y + 4.0f + 1.0f + (h - 8.0f - scrollH) * u, 8.0f - 2.0f, scrollH - 2.0f, 2.0f);
            _nvg.FillPaint(shadowPaint);
            _nvg.Fill();

            _nvg.Restore();
        }