Пример #1
0
        //----

        private void drawWindow(int id)
        {
            TitleHeight   = PV.Line("C1");
            TitleFontSize = PV.Font("C2");

            LabelStyle.fontSize  = TitleFontSize;
            LabelStyle.alignment = TextAnchor.UpperLeft;
            GUI.Label(titleRect, TitleText, LabelStyle);

            GUI.BeginGroup(contentRect);
            {
                Rect cur = new Rect(0f, 0f, 0f, 0f);

                foreach (Element child in children)
                {
                    if (!child.Visible)
                    {
                        continue;
                    }

                    if (child.Left >= 0 || child.Top >= 0)
                    {
                        Rect tmp = new Rect((child.Left >= 0) ? child.Left : cur.x,
                                            (child.Top >= 0) ? child.Top : cur.y,
                                            (child.Width > 0) ? child.Width : autoSize.x,
                                            (child.Height > 0) ? child.Height : autoSize.y);

                        child.Draw(tmp);
                    }
                    else
                    {
                        cur.width  = (child.Width > 0) ? child.Width : autoSize.x;
                        cur.height = (child.Height > 0) ? child.Height : autoSize.y;
                        child.Draw(cur);
                        cur.y += cur.height;
                    }
                }
            }
            GUI.EndGroup();

            GUI.DragWindow();
        }
Пример #2
0
        public Window(string name, Rect ratio, string header, string title, List <Element> children) : base(name, PV.PropScreenMH(ratio))
        {
            this.sizeRatio   = ratio;
            this.HeaderText  = header;
            this.TitleText   = title;
            this.TitleHeight = PV.Line("C1");

            if (children != null && children.Count > 0)
            {
                this.children = new List <Element>(children);
                foreach (Element child in children)
                {
                    child.Parent        = this;
                    child.NotifyParent += this.onChildChenged;
                }
                Resize();
            }

            lastScreenSize = new Vector2(Screen.width, Screen.height);
        }