SetAlpha() private method

private SetAlpha ( float alpha ) : void
alpha float
return void
示例#1
0
        protected override void OldOnGUI()
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            const float dragTabOffsetX = 2f;
            const float dragTabOffsetY = 2f;
            const float dragTabHeight  = 18f;

            float minWidth, expectedWidth;

            Styles.dragtab.CalcMinMaxWidth(m_Content, out minWidth, out expectedWidth);
            float tabWidth        = Mathf.Max(Mathf.Min(expectedWidth, Styles.tabMaxWidth), Styles.tabMinWidth) + Styles.tabWidthPadding;
            Rect  windowRect      = new Rect(0, 0, position.width, position.height);
            Rect  tabPositionRect = new Rect(dragTabOffsetX, dragTabOffsetY, tabWidth, dragTabHeight);
            float roundedPosX     = Mathf.Round(tabPositionRect.x);
            float roundedWidth    = Mathf.Round(tabPositionRect.x + tabPositionRect.width) - roundedPosX;
            Rect  tabContentRect  = new Rect(roundedPosX, tabPositionRect.y, roundedWidth, tabPositionRect.height);
            Rect  viewRect        = new Rect(dragTabOffsetX, tabContentRect.yMax - 2f,
                                             position.width - dragTabOffsetX * 2, position.height - tabContentRect.yMax - dragTabOffsetY + 2f);

            Styles.background.Draw(windowRect, GUIContent.none, false, false, true, true);
            Styles.dragtab.Draw(tabContentRect, false, true, false, false);
            Styles.view.Draw(viewRect, GUIContent.none, false, false, true, true);
            GUI.Label(tabPositionRect, m_Content, Styles.tabLabel);

            // We currently only support this on macOS
            m_Window.SetAlpha(m_TargetAlpha);
        }
        void Setup(string tooltip, Rect rect)
        {
            m_hoverRect    = rect;
            m_tooltip.text = tooltip;

            // Calculate size and position tooltip view
            m_Style = EditorStyles.tooltip;

            m_Style.wordWrap = false;
            m_optimalSize    = m_Style.CalcSize(m_tooltip);

            if (m_optimalSize.x > MAX_WIDTH)
            {
                m_Style.wordWrap = true;
                m_optimalSize.x  = MAX_WIDTH;
                m_optimalSize.y  = m_Style.CalcHeight(m_tooltip, MAX_WIDTH);
            }

            m_tooltipContainer.position = new Rect(
                Mathf.Floor(m_hoverRect.x + (m_hoverRect.width / 2) - (m_optimalSize.x / 2)),
                Mathf.Floor(m_hoverRect.y + (m_hoverRect.height) + 10.0f),
                m_optimalSize.x, m_optimalSize.y);

            position = new Rect(0, 0, m_optimalSize.x, m_optimalSize.y);

            m_tooltipContainer.ShowPopup();
            m_tooltipContainer.SetAlpha(1.0f);
            s_guiView.mouseRayInvisible = true;

            RepaintImmediately(); // Force repaint to fix that the tooltip text did sometimes not update (we did not get a new OnGUI if the rect had the same size)
        }
示例#3
0
        protected override void OldOnGUI()
        {
            if (!m_Window)
            {
                return;
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            Rect windowRect = new Rect(0, 0, position.width, position.height);

            if (Event.current.type == EventType.Repaint)
            {
                GUI.DrawTexture(windowRect, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill, false, 0f, Styles.backgroundColor, 0, 0);
            }
            if (m_Type == DropInfo.Type.Tab)
            {
                Styles.dragtab.Draw(windowRect, false, true, false, false);
                GUI.Label(windowRect, m_Content, Styles.tabLabel);
            }
            else
            {
                const float dragTabOffsetX = 2f;
                const float dragTabHeight  = DockArea.kTabHeight;

                float minWidth, expectedWidth;
                Styles.dragtab.CalcMinMaxWidth(m_Content, out minWidth, out expectedWidth);
                float tabWidth        = Mathf.Max(Mathf.Min(expectedWidth, Styles.tabMaxWidth), Styles.tabMinWidth) + Styles.tabWidthPadding;
                Rect  tabPositionRect = new Rect(1, 2f, tabWidth, dragTabHeight);
                float roundedPosX     = Mathf.Floor(tabPositionRect.x);
                float roundedWidth    = Mathf.Ceil(tabPositionRect.x + tabPositionRect.width) - roundedPosX;
                Rect  tabContentRect  = new Rect(roundedPosX, tabPositionRect.y, roundedWidth, tabPositionRect.height);
                Rect  viewRect        = new Rect(dragTabOffsetX, tabContentRect.yMax - 2f,
                                                 position.width - dragTabOffsetX * 2, position.height - tabContentRect.yMax);

                Styles.dragtab.Draw(tabContentRect, false, true, false, false);
                Styles.view.Draw(viewRect, GUIContent.none, false, false, true, true);
                GUI.Label(tabPositionRect, m_Content, Styles.tabLabel);
            }

            // We currently only support this on macOS
            m_Window.SetAlpha(m_TargetAlpha);
        }
示例#4
0
        protected override void OldOnGUI()
        {
            if (s_PaneStyle == null)
            {
                s_PaneStyle = "dragtabdropwindow";
                s_TabStyle  = "dragtab";
            }

            if (Event.current.type == EventType.Repaint)
            {
                Color oldGUIColor = GUI.color;
                GUI.color = Color.white;
                s_PaneStyle.Draw(new Rect(0, 0, position.width, position.height), m_TabVisible ? GUIContent.none : m_Content, false, false, true, true);
                if (m_TabVisible)
                {
                    s_TabStyle.Draw(new Rect(0, 0, position.width, position.height), m_Content, false, false, true, true);
                }
                GUI.color = oldGUIColor;

                m_Window.SetAlpha(m_TargetAlpha);  //We currently only support this on macOS
            }
        }