public GuiButton AddButton(string label) { var button = new GuiButton(Gui, this) { Label = label }; AddControl(button); return(button); }
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); } }
public abstract void DrawButton(Canvas canvas, GuiButton button);