Beispiel #1
0
        public GuiButton AddButton(string label)
        {
            var button = new GuiButton(Gui, this)
            {
                Label = label
            };

            AddControl(button);

            return(button);
        }
Beispiel #2
0
        public override void DrawButton(Canvas canvas, GuiButton button)
        {
            var x = button.GlobalX;
            var y = button.GlobalY;
            var w = button.W;
            var h = button.H;

            var textSize = new Size(

                button.Label.Length * 8,
                8
                );

            var labelPosX = x + (w / 2 - textSize.W / 2);
            var labelPosY = y + (h / 2 - textSize.H / 2);

            if (!button.Active)
            {
                DrawFrame(
                    canvas,
                    x, y,
                    w, h,
                    button.Hovered ? ControlOverBorder : ControlBorder,
                    button.Hovered ? ControlOverFill : ControlFill);

                canvas.DrawText(font, labelPosX, labelPosY, button.Label, Color.White, 0.25f);
            }
            else
            {
                DrawFrame(
                    canvas,
                    x, y + 1,
                    w, h,
                    button.Hovered ? ControlOverBorder : ControlBorder,
                    button.Hovered ? ControlOverFill : ControlFill);


                canvas.DrawText(font, labelPosX, labelPosY + 1, button.Label, Color.White, 0.25f);
            }
        }
Beispiel #3
0
 public abstract void DrawButton(Canvas canvas, GuiButton button);