Beispiel #1
0
        public override void DrawSlider(Canvas canvas, GuiSlider slider)
        {
            int x = slider.GlobalX;
            int y = slider.GlobalY;
            int w = slider.W;
            int h = slider.H;



            float valueFactor = (float)slider.Value / (slider.MaxValue - slider.MinValue);

            if (slider.Orientation == Orientation.Horizontal)
            {
                DrawFrame(
                    canvas,
                    x, y,
                    w, h,
                    ControlBorder,
                    ControlFill);


                int indicatorSize = (int)(valueFactor * w);

                indicatorSize = Calc.Clamp(indicatorSize, 0, w - 4);

                canvas.FillRect(x + 2, y + 2, indicatorSize, h - 4, AccentColor);

                var label_x = x + w / 2 - 4;
                var label_y = y + h / 2 - 4;

                canvas.DrawText(font, label_x, label_y, slider.Value.ToString(), Color.White, 0.25f);
            }
            else
            {
                DrawFrame(
                    canvas,
                    x, y,
                    w, h,
                    ControlBorder,
                    ControlFill);

                int indicatorSize = (int)((float)slider.Value / (slider.MaxValue - slider.MinValue) * h);

                indicatorSize = Calc.Clamp(indicatorSize, 0, h - 4);

                canvas.FillRect(x + 2, y + 2, w - 3, indicatorSize, AccentColor);

                var label_x = x + w / 2 - 4;
                var label_y = y + h / 2 - 4;

                canvas.DrawText(font, label_x, label_y, slider.Value.ToString(), Color.White, 0.25f);
            }
        }
Beispiel #2
0
        public GuiSlider AddSlider(int minValue, int maxValue, int step, Orientation orientation = Orientation.Horizontal)
        {
            var slider = new GuiSlider(
                Gui,
                this,
                value: minValue,
                minValue: minValue,
                maxValue: maxValue,
                step: step, orientation:
                orientation);

            AddWidget(slider);

            return(slider);
        }
Beispiel #3
0
 public abstract void DrawSlider(Canvas canvas, GuiSlider slider);