예제 #1
0
        public static bool Button(RectFloat rect, string text = null, bool active = true, Vector4?color = null)
        {
            bool hover    = rect.Contains(InputEngine.MousePosition, true);
            bool anyPress = InputEngine.GetMouseButton(0);

            var style = skin.buttonStyle;
            var tex   = active ? hover ? anyPress ? style.texActive : style.texHover : style.texNormal : style.texInactive;

            Draw(rect, tex, color, style);

            if (!string.IsNullOrEmpty(text))
            {
                var textRect = new RectFloat(
                    rect.x + style.border.left,
                    rect.y + style.border.top,
                    rect.width - style.border.left - style.border.right,
                    rect.height - style.border.top - style.border.bottom
                    );

                DrawString(font, style.fontSize, textRect, text, alignment: style.textAlignment);
            }

            return(active && hover && InputEngine.GetMouseButtonUp(0) && rect.Contains(InputEngine.MousePosition, true));
        }