Exemplo n.º 1
0
        public void WindowTitleBar(SWindowTitleBar bar)
        {
            Rect bounds = new Rect(Vector2.zero, bar.Size);

            SGroup group = (SGroup)bar.Parent;
            string title = group.WindowTitle;

            Rect(bar, Vector2.zero, bar.Size, group.Background);

            if (!string.IsNullOrEmpty(title))
            {
                Text(bar, new Vector2(group.Border, 0f), bar.InnerSize, title);
            }

            // TODO Window header buttons.
        }
Exemplo n.º 2
0
 public SGroup()
 {
     WindowTitleBar = new SWindowTitleBar {
         Parent = this
     };
 }
Exemplo n.º 3
0
        public int HandleMouseEventInGroup(Event e, SGroup group)
        {
            int  handled;
            int  groupFirstComponent = GetFirstComponentID(group);
            bool containsMouse       = new Rect(
                group.AbsoluteOffset.x + group.Position.x,
                group.AbsoluteOffset.y + group.Position.y,
                group.Size.x + group.Border * 2f,
                group.Size.y + (group.IsWindow ? group.WindowTitleBar.Size.y : 0f) + group.Border * 2f
                ).Contains(e.mousePosition);

            if (group.IsWindow)
            {
                SWindowTitleBar bar = group.WindowTitleBar;

                Rect bounds = (_ClipScopeRects.Count == 0 || !IsOnGUIRepainting) ?
                              new Rect(group.AbsoluteOffset + group.Position, bar.Size) :
                              new Rect(Vector2.zero, bar.Size);
                if (e.type == EventType.MouseDown && bounds.Contains(e.mousePosition))
                {
                    bar.Dragging    = true;
                    _WindowDragging = group;
                    e.Use();
                    return(groupFirstComponent);
                }

                if (bar.Dragging)
                {
                    if (e.type == EventType.MouseDrag)
                    {
                        group.Position += e.delta;
                    }
                    else if (e.type == EventType.MouseUp)
                    {
                        bar.Dragging    = false;
                        _WindowDragging = null;
                    }
                    e.Use();
                    return(groupFirstComponent);
                }

                bar.Dragging = false;
            }

            if (!containsMouse)
            {
                return(-1);
            }

            IList <SElement> children = group.Children;

            for (int i = children.Count - 1; 0 <= i; i--)
            {
                if ((handled = HandleMouseEventIn(e, children[i])) != -1)
                {
                    return(handled);
                }
            }

            // Window background would be click-through otherwise.
            if (!new Rect(group.AbsoluteOffset + group.Position, group.InnerSize).Contains(e.mousePosition))
            {
                e.Use();
                return(groupFirstComponent);
            }
            return(-1);
        }