Beispiel #1
0
        public WidgetButton AddItem(string title, Action <WidgetButton> action)
        {
            WidgetButton item = new WidgetButton(m_itemStyle, title);

            item.Position = m_padding.TopLeft + m_itemSize * new Vector2(0, Children.Count);
            if (action != null)
            {
                item.OnPress += delegate { Hide(item); action(item); }
            }
            ;
            else
            {
                item.OnPress += Hide;
            }

            item.Enabled = !string.IsNullOrEmpty(title);

            AddChild(item);

            item.Relayout();
            m_itemSize = new Vector2(Math.Max(m_itemSize.X, item.Size.X), Math.Max(m_itemSize.Y, item.Size.Y));

            for (int i = 0; i < Children.Count; i++)
            {
                ((WidgetButton)Children[i]).Size     = m_itemSize;
                ((WidgetButton)Children[i]).Position = m_padding.TopLeft + m_itemSize * new Vector2(0, i);
            }

            Size = new Vector2(m_padding.Width + m_itemSize.X, m_padding.Height + m_itemSize.Y * Children.Count);

            return(item);
        }
Beispiel #2
0
        private void Hide(WidgetButton caller)
        {
            if (!Visible)
            {
                return;
            }

            Visible = false;

            if (m_autohide)
            {
                WidgetManager.RemoveExclusive(this);
            }


//                WidgetManager.WindowController.OnTouch -= UnHoverTouch;
        }