예제 #1
0
파일: GLForm.cs 프로젝트: rainrcn/GLGUI
        public GLForm(GLGui gui) : base(gui)
        {
            Render     += OnRender;
            MouseDown  += OnMouseDown;
            MouseUp    += OnMouseUp;
            MouseMove  += OnMouseMove;
            MouseLeave += OnMouseLeave;
            //MouseDoubleClick += OnMouseDoubleClick;
            Focus     += (s, e) => Invalidate();
            FocusLost += (s, e) => Invalidate();

            skinActive   = Gui.Skin.FormActive;
            skinInactive = Gui.Skin.FormInactive;

            outer   = new Rectangle(0, 0, 100, 100);
            sizeMin = new Size(64, 32);
            sizeMax = new Size(int.MaxValue, int.MaxValue);
        }
예제 #2
0
파일: GLForm.cs 프로젝트: rainrcn/GLGUI
        protected override void UpdateLayout()
        {
            skin = HasFocus ? skinActive : skinInactive;

            if (AutoSize)
            {
                if (Controls.Count() > 0)
                {
                    outer.Width  = Controls.Max(c => c.Outer.Right) + skin.Border.Horizontal;
                    outer.Height = Controls.Max(c => c.Outer.Bottom) + skin.Border.Vertical + (int)titleSize.Height + skin.Border.Top;
                }
                else
                {
                    outer.Width  = 0;
                    outer.Height = 0;
                }
            }

            outer.Width = Math.Min(Math.Max(outer.Width, sizeMin.Width), sizeMax.Width);

            int innerWidth = outer.Width - skin.Border.Horizontal;

            titleSize = skin.Font.ProcessText(titleProcessed, title, GLFontAlignment.Left);
            minHeight = Math.Max(sizeMin.Height, (int)titleSize.Height + skin.Border.Vertical + skin.Border.Top);

            outer.Height = Math.Min(Math.Max(outer.Height, minHeight), sizeMax.Height);
            if (Parent != null)
            {
                outer.X      = Math.Max(Math.Min(outer.X, Parent.Inner.Width - outer.Width), 0);
                outer.Y      = Math.Max(Math.Min(outer.Y, Parent.Inner.Height - outer.Height), 0);
                outer.Width  = Math.Min(outer.Right, Parent.Inner.Width) - outer.X;
                outer.Height = Math.Min(outer.Bottom, Parent.Inner.Height) - outer.Y;
            }

            Inner = new Rectangle(
                skin.Border.Left, skin.Border.Top + (int)titleSize.Height + skin.Border.Top,
                innerWidth, outer.Height - skin.Border.Vertical - (int)titleSize.Height - skin.Border.Top);
            moveClickRegion = new Rectangle(skin.Border.Left, skin.Border.Top, Inner.Width, (int)titleSize.Height);
        }