コード例 #1
0
        /////////////////////////////////////////

        protected override void OnRenderProgress(UIProgress control, CanvasRenderer renderer)
        {
            control.GetScreenRectangle(out var rect);

            //back
            {
                var color = DarkTheme ? new ColorByte(40, 40, 40) : new ColorByte(230, 230, 230);
                renderer.AddQuad(rect, color.ToColorValue());
            }

            //border
            {
                var color = DarkTheme ? new ColorByte(80, 80, 80) : new ColorByte(188, 188, 188);
                renderer.AddRectangle(rect, color.ToColorValue());
            }

            //progress
            if (control.Maximum.Value != 0)
            {
                double progress = control.Value.Value / control.Maximum.Value;
                if (progress > 0)
                {
                    var color = DarkTheme ? new ColorByte(0, 150, 0) : new ColorByte(0, 190, 0);

                    var rect2 = rect;
                    //!!!!Pixels?
                    rect2.Expand(-control.GetScreenOffsetByValue(new UIMeasureValueVector2(UIMeasure.Units, 2, 2)));
                    rect2.Right = MathEx.Lerp(rect2.Left, rect2.Right, progress);

                    renderer.AddQuad(rect2, color.ToColorValue());
                }
            }
        }
コード例 #2
0
        protected override void OnRenderButton(UIButton control, CanvasRenderer renderer)
        {
            //!!!!context menu

            //if( control.Parent as UIContextMenu != null )
            //{
            //	//context menu button
            //}
            //else
            //{
            //	//usual button
            //}

            //!!!!
            //RenderButtonTextImage( control, renderer, new ColorValue( 1, 1, 1 ), new ColorValue( 1, 1, 1 ) );

            control.GetScreenRectangle(out var rect);

            //back
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(60, 60, 60) : new ColorByte(253, 253, 253); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(80, 80, 80) : new ColorByte(205, 230, 247); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(204, 228, 247); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(204, 228, 247); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(50, 50, 50) : new ColorByte(250, 250, 250); break;
                }

                renderer.AddQuad(rect, color.ToColorValue());
            }

            //text
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(59, 59, 59); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(167, 167, 167); break;
                }

                var center = rect.GetCenter() + new Vector2(0, renderer.DefaultFontSize / 10);
                renderer.AddText(control.Text, center, EHorizontalAlignment.Center, EVerticalAlignment.Center, color.ToColorValue());
            }

            //border
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(170, 170, 170); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(130, 130, 130) : new ColorByte(95, 168, 226); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(150, 150, 150) : new ColorByte(0, 120, 215); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(150, 150, 150) : new ColorByte(0, 120, 215); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(60, 60, 60) : new ColorByte(180, 180, 180); break;
                }

                renderer.AddRectangle(rect, color.ToColorValue());
            }
        }