Esempio n. 1
0
        void UpdateStates(States s)
        {
            var color = win.titleColor; // MUISkin.config.titlebarColor;

            if ((s & States.HoverInTitlebar) == States.HoverInTitlebar)
            {
                color = MUIUtil.BrightenColor(color, 0.2f, color[3]);
                titleTextture.SetPixel(0, 0, color);
                titleStyle.normal.textColor = MUISkin.config.titleTextHoverColor;
            }
            else
            {
                titleTextture.SetPixel(0, 0, color);
                titleStyle.normal.textColor = MUISkin.config.titleTextColor;
            }

            color = win.backgroundColor;
            if (color == Color.clear)
            {
                color    = Color.gray;
                color[3] = 0.5f; // alpha
            }


            if ((s & States.HoverInResize) == States.HoverInResize)
            {
                color = MUIUtil.BrightenColor(color, 0.8f, 1.0f);
            }
            else
            {
                color = MUIUtil.BrightenColor(color, 0.5f, color[3]);
            }

            if (MUISkin.isStyleExists("button_resize"))
            {
                resizeTextture = MUISkin.skin.FindStyle("button_resize").normal.background;
            }
            else
            {
                resizeTextture.SetPixel(0, 0, color);
            }

            color = new Color(0.8f, 0.0f, 0.0f, MUISkin.config.titlebarColor[3]);
            if ((s & States.HoverInCloseButton) == States.HoverInCloseButton)
            {
                closeTextture.SetPixel(0, 0, MUIUtil.BrightenColor(color, 0.65f, 1.0f));
                if (MUISkin.isStyleExists("button_close"))
                {
                    closeTextture = MUISkin.skin.FindStyle("button_close").hover.background;
                }
            }
            else
            {
                closeTextture.SetPixel(0, 0, color);
                if (MUISkin.isStyleExists("button_close"))
                {
                    closeTextture = MUISkin.skin.FindStyle("button_close").normal.background;
                }
            }
            _states = s;
            titleTextture.Apply();
            closeTextture.Apply();
            resizeTextture.Apply();
        }
Esempio n. 2
0
        void DoDrawWindow()
        {
            var h = win.titleHeight;

            if ((win.options & MUIWindow.Options.TitleBar) == MUIWindow.Options.TitleBar)
            {
                titleRect = new Rect(win.titleOffset.x, win.titleOffset.y, rect.width - win.titleOffset.x * 3, h);
            }
            else
            {
                titleRect = new Rect(0, 0, 0, 0);
            }

            if ((win.options & MUIWindow.Options.CloseButton) == MUIWindow.Options.CloseButton)
            {
                float size = win.closeButtonSize;
                if (size == 0)
                {
                    size = 16.0f;
                }
                var offset = win.closeButtonOffset;


                closeRect = new Rect(rect.width - size + offset.x - 0.0f, offset.y, size, titleRect.y + (size / 2) + 2.0f);
                if (MUISkin.isStyleExists("button_close"))
                {
                    size = win.closeButtonSize;
                    if (size == 0)
                    {
                        size = h;
                    }
                    if (MUISkin.UIView.ratio > 1.0)
                    {
                        size /= MUISkin.UIView.ratio;
                    }
                    closeRect = new Rect(rect.width - size + offset.x, (h - size) / 2 + offset.y, size, size);
                }
            }
            else
            {
                closeRect = new Rect(0, 0, 0, 0);
            }

            if (!titleRect.IsEmpty())
            {
                GUI.DrawTexture(titleRect, titleTextture, ScaleMode.StretchToFill);
                GUI.DrawTexture(closeRect, closeTextture, ScaleMode.ScaleAndCrop);
                titleStyle.alignment = win.titleAlignment;
                GUI.Label(new Rect(titleRect.x + 3.0f, titleRect.y, rect.width - 3.0f, titleRect.height), win.Title, titleStyle);
            }

            if (!resizeRect.IsEmpty())
            {
                if (MUISkin.isStyleExists("button_resize"))
                {
                    resizeRect = new Rect(rect.width - resizeButton_size + win.resizeButtonOffset.x - 2.0f,
                                          rect.height - resizeButton_size + win.resizeButtonOffset.y - 2.0f,
                                          resizeButton_size, resizeButton_size);
                }
                GUI.DrawTexture(resizeRect, resizeTextture, ScaleMode.StretchToFill);
            }
        }