예제 #1
0
        public Panel(ScriptableObject ownerObject, ContextType contextType, IDataWatchService dataWatch = null, IEventDispatcher dispatcher = null)
        {
            this.ownerObject               = ownerObject;
            this.contextType               = contextType;
            m_DataWatch                    = dataWatch;
            this.dispatcher                = dispatcher;
            stylePainter                   = new StylePainter();
            cursorManager                  = new CursorManager();
            contextualMenuManager          = null;
            m_RootContainer                = new VisualElement();
            m_RootContainer.name           = VisualElementUtils.GetUniqueName("PanelContainer");
            m_RootContainer.persistenceKey = "PanelContainer"; // Required!
            visualTree.SetPanel(this);
            focusController = new FocusController(new VisualElementFocusRing(visualTree));
            m_StyleContext  = new StyleSheets.StyleContext(m_RootContainer);

            allowPixelCaching = true;
        }
예제 #2
0
        private float DrawTab(Rect tabRegionRect, GUIStyle tabStyle, int tabIndex, float xPos)
        {
            float tabWidth        = GetTabWidth(tabStyle, tabIndex);
            Rect  tabPositionRect = new Rect(xPos, tabRegionRect.yMin, tabWidth, tabRegionRect.height);
            float roundedPosX     = Mathf.Round(tabPositionRect.x);
            float roundedWidth    = Mathf.Round(tabPositionRect.x + tabPositionRect.width) - roundedPosX;

            bool isActive       = m_Panes[tabIndex] == EditorWindow.focusedWindow;
            Rect tabContentRect = new Rect(roundedPosX, tabPositionRect.y, roundedWidth, tabPositionRect.height);

            StylePainter.DrawStyle(tabStyle, tabContentRect, null, new DrawStates(false, isActive, tabIndex == selected, false));
            GUI.Label(tabPositionRect, GetTruncatedTabContent(tabIndex), Styles.tabLabel);

            var unclippedContentRect = GUIClip.UnclipToWindow(tabContentRect);

            if (tabIndex == selected)
            {
                m_SelectedTabRect = unclippedContentRect;
            }

            MarkHotRegion(unclippedContentRect);

            return(tabWidth);
        }