Example #1
0
        public Button(string message, int padding, IFont buttonLabelFont, Color idle, Color hover, Color clicked, Color fontColor)
        {
            LabelFont = buttonLabelFont ?? Gia.Theme.DefaultFont;
            Message   = message;
            Padding   = padding;

            ClickAction        = new UserInterface.TransactionalBinding <bool>();
            ConsumesMouseInput = true;

            // Colors
            IdleColor   = idle;
            HoverColor  = hover;
            ActiveColor = clicked;
            FontColor   = fontColor;

            // Meta
            DrawMethod = DefaultDraw;
            CalculateBounds();

            // Defaults
            realColor = IdleColor;
            target    = IdleColor;

            // Interactivity
            SetInteractive();
            Interactivity.OnHover += (node) => target = HoverColor;
            Interactivity.OnClick += (node) =>
            {
                realColor = ActiveColor;
                Manager.SetFocus(this);
                ClickAction?.PushFromControl(true);
            };
            Interactivity.OnEndClicking += (node) =>
            {
                ClickAction?.PushFromControl(false);
            };
            Interactivity.OnUnhover += (node) => target = IdleColor;
        }
Example #2
0
 public void Take(UserInterface.TransactionalBinding <bool> transaction)
 {
     ClickAction = transaction;
     ClickAction.PushFromControl(false); // Buttons start out not clicked.
 }