protected void SortingButton(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
        {
            // Button logic
            if (EditorGUI.Button(headerRect, GUIContent.none, GUIStyle.none))
            {
                ColumnHeaderClicked(column, columnIndex);
            }

            // Draw sorting arrow
            if (columnIndex == state.sortedColumnIndex && Event.current.type == EventType.Repaint)
            {
                var arrowRect = GetArrowRect(column, headerRect);

                Matrix4x4 normalMatrix = GUI.matrix;
                if (column.sortedAscending)
                {
                    GUIUtility.RotateAroundPivot(180, arrowRect.center - new Vector2(0, 1));
                }

                GUI.Label(arrowRect, "\u25BE", DefaultStyles.arrowStyle);

                if (column.sortedAscending)
                {
                    GUI.matrix = normalMatrix;
                }
            }
        }
        internal virtual Rect GetArrowRect(MultiColumnHeaderState.Column column, Rect headerRect)
        {
            float sortingArrowWidth = DefaultStyles.arrowStyle.fixedWidth;
            float arrowYPos         = headerRect.y;
            float arrowXPos         = 0f;

            switch (column.sortingArrowAlignment)
            {
            case TextAlignment.Left:
                arrowXPos = headerRect.x + DefaultStyles.columnHeader.padding.left;
                break;

            case TextAlignment.Center:
                arrowXPos = headerRect.x + headerRect.width * 0.5f - sortingArrowWidth * 0.5f;
                break;

            case TextAlignment.Right:
                arrowXPos = headerRect.xMax - DefaultStyles.columnHeader.padding.right - sortingArrowWidth;
                break;

            default:
                Debug.LogError("Unhandled enum");
                break;
            }

            Rect arrowRect = new Rect(Mathf.Round(arrowXPos), arrowYPos, sortingArrowWidth, 16f);

            return(arrowRect);
        }
Esempio n. 3
0
 internal virtual void DrawColumnResizing(Rect headerRect, MultiColumnHeaderState.Column column)
 {
     headerRect.y      += 1f;
     headerRect.width  -= 1f;
     headerRect.height -= 2f;
     EditorGUI.DrawRect(headerRect, new Color(0.5f, 0.5f, 0.5f, 0.1f));
 }
Esempio n. 4
0
        public virtual void OnGUI(Rect rect, float xScroll)
        {
            Event current = Event.current;

            if (this.m_GUIView == null)
            {
                this.m_GUIView = GUIView.current;
            }
            this.DetectSizeChanges(rect);
            GUIClip.Push(rect, new Vector2(-xScroll, 0f), Vector2.zero, false);
            Rect  totalHeaderRect          = new Rect(0f, 0f, rect.width, rect.height);
            float widthOfAllVisibleColumns = this.state.widthOfAllVisibleColumns;
            float width    = ((totalHeaderRect.width <= widthOfAllVisibleColumns) ? widthOfAllVisibleColumns : totalHeaderRect.width) + GUI.skin.verticalScrollbar.fixedWidth;
            Rect  position = new Rect(0f, 0f, width, totalHeaderRect.height);

            GUI.Label(position, GUIContent.none, MultiColumnHeader.DefaultStyles.background);
            if (current.type == EventType.ContextClick && position.Contains(current.mousePosition))
            {
                current.Use();
                this.DoContextMenu();
            }
            this.UpdateColumnHeaderRects(totalHeaderRect);
            for (int i = 0; i < this.state.visibleColumns.Length; i++)
            {
                int num = this.state.visibleColumns[i];
                MultiColumnHeaderState.Column column = this.state.columns[num];
                Rect headerRect  = this.m_ColumnRects[i];
                Rect dividerRect = new Rect(headerRect.xMax - 1f, headerRect.y + 4f, 1f, headerRect.height - 8f);
                this.DrawDivider(dividerRect);
                Rect position2 = new Rect(dividerRect.x - this.m_DividerWidth * 0.5f, totalHeaderRect.y, this.m_DividerWidth, totalHeaderRect.height);
                column.width = EditorGUI.WidthResizer(position2, column.width, column.minWidth, column.maxWidth);
                this.ColumnHeaderGUI(column, headerRect, num);
            }
            GUIClip.Pop();
        }
Esempio n. 5
0
        internal virtual Rect GetArrowRect(MultiColumnHeaderState.Column column, Rect headerRect)
        {
            float fixedWidth = MultiColumnHeader.DefaultStyles.arrowStyle.fixedWidth;
            float y          = headerRect.y;
            float f          = 0f;

            switch (column.sortingArrowAlignment)
            {
            case TextAlignment.Left:
                f = headerRect.x + (float)MultiColumnHeader.DefaultStyles.columnHeader.padding.left;
                break;

            case TextAlignment.Center:
                f = headerRect.x + headerRect.width * 0.5f - fixedWidth * 0.5f;
                break;

            case TextAlignment.Right:
                f = headerRect.xMax - (float)MultiColumnHeader.DefaultStyles.columnHeader.padding.right - fixedWidth;
                break;

            default:
                Debug.LogError("Unhandled enum");
                break;
            }
            Rect result = new Rect(Mathf.Round(f), y, fixedWidth, 16f);

            return(result);
        }
        internal virtual void DrawColumnResizing(Rect headerRect, MultiColumnHeaderState.Column column)
        {
            const float margin = 1;

            headerRect.y      += margin;
            headerRect.width  -= margin;
            headerRect.height -= 2 * margin;
            EditorGUI.DrawRect(headerRect, new Color(0.5f, 0.5f, 0.5f, 0.1f));
        }
Esempio n. 7
0
 public void SetSortDirection(int columnIndex, bool sortAscending)
 {
     MultiColumnHeaderState.Column column = this.GetColumn(columnIndex);
     if (column.sortedAscending != sortAscending)
     {
         column.sortedAscending = sortAscending;
         this.OnSortingChanged();
     }
 }
Esempio n. 8
0
        protected virtual void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
        {
            if (this.canSort)
            {
                this.SortingButton(column, headerRect, columnIndex);
            }
            GUIStyle columnHeader = MultiColumnHeader.DefaultStyles.columnHeader;

            columnHeader.alignment = this.ConvertHeaderAlignmentToTextAnchor(column.headerTextAlignment);
            GUI.Label(headerRect, column.headerText, columnHeader);
        }
Esempio n. 9
0
        protected virtual void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
        {
            if (this.canSort && column.canSort)
            {
                this.SortingButton(column, headerRect, columnIndex);
            }
            GUIStyle style            = this.GetStyle(column.headerTextAlignment);
            float    singleLineHeight = EditorGUIUtility.singleLineHeight;
            Rect     position         = new Rect(headerRect.x, headerRect.yMax - singleLineHeight - MultiColumnHeader.DefaultGUI.labelSpaceFromBottom, headerRect.width, singleLineHeight);

            GUI.Label(position, column.headerContent, style);
        }
Esempio n. 10
0
 protected virtual void ColumnHeaderClicked(MultiColumnHeaderState.Column column, int columnIndex)
 {
     if (this.state.sortedColumnIndex == columnIndex)
     {
         column.sortedAscending = !column.sortedAscending;
     }
     else
     {
         this.state.sortedColumnIndex = columnIndex;
     }
     this.OnSortingChanged();
 }
Esempio n. 11
0
        protected virtual void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
        {
            var evt = Event.current;

            SortingButton(column, headerRect, columnIndex);

            GUIStyle style = GetStyle(column.headerTextAlignment);

            float labelHeight = EditorGUI.kWindowToolbarHeight;
            Rect  labelRect   = new Rect(headerRect.x, headerRect.yMax - labelHeight, headerRect.width, labelHeight);

            GUI.Label(labelRect, column.headerContent, style);
        }
Esempio n. 12
0
        public void SetSortingColumns(int[] columnIndices, bool[] sortAscending)
        {
            if (columnIndices == null)
            {
                throw new ArgumentNullException("columnIndices");
            }
            if (sortAscending == null)
            {
                throw new ArgumentNullException("sortAscending");
            }
            if (columnIndices.Length != sortAscending.Length)
            {
                throw new ArgumentException("Input arrays should have same length");
            }
            if (columnIndices.Length > this.state.maximumNumberOfSortedColumns)
            {
                throw new ArgumentException(string.Concat(new object[]
                {
                    "The maximum number of sorted columns is ",
                    this.state.maximumNumberOfSortedColumns,
                    ". Trying to set ",
                    columnIndices.Length,
                    " columns."
                }));
            }
            if (columnIndices.Length != columnIndices.Distinct <int>().Count <int>())
            {
                throw new ArgumentException("Duplicate column indices are not allowed", "columnIndices");
            }
            bool flag = false;

            if (!columnIndices.SequenceEqual(this.state.sortedColumns))
            {
                this.state.sortedColumns = columnIndices;
                flag = true;
            }
            for (int i = 0; i < columnIndices.Length; i++)
            {
                MultiColumnHeaderState.Column column = this.GetColumn(columnIndices[i]);
                if (column.sortedAscending != sortAscending[i])
                {
                    column.sortedAscending = sortAscending[i];
                    flag = true;
                }
            }
            if (flag)
            {
                this.OnSortingChanged();
            }
        }
Esempio n. 13
0
 protected virtual void AddColumnVisibilityItems(GenericMenu menu)
 {
     for (int i = 0; i < this.state.columns.Length; i++)
     {
         MultiColumnHeaderState.Column column = this.state.columns[i];
         if (column.allowToggleVisibility)
         {
             menu.AddItem(new GUIContent(column.headerText), this.state.visibleColumns.Contains(i), new GenericMenu.MenuFunction2(this.ToggleVisibility), i);
         }
         else
         {
             menu.AddDisabledItem(new GUIContent(column.headerText));
         }
     }
 }
        void ResizeColumnsWidthsProportionally(float deltaWidth)
        {
            // Find auto resizing columns
            List <MultiColumnHeaderState.Column> autoResizeColumns = null;

            foreach (int i in state.visibleColumns)
            {
                MultiColumnHeaderState.Column column = state.columns[i];
                if (column.autoResize)
                {
                    // Ignore the columns that cannot expand anymore
                    if (deltaWidth > 0f && column.width >= column.maxWidth)
                    {
                        continue;
                    }
                    // Ignore the columns that cannot shrink anymore
                    if (deltaWidth < 0f && column.width <= column.minWidth)
                    {
                        continue;
                    }

                    if (autoResizeColumns == null)
                    {
                        autoResizeColumns = new List <MultiColumnHeaderState.Column>();
                    }

                    autoResizeColumns.Add(column);
                }
            }

            // Any auto resizing columns?
            if (autoResizeColumns == null)
            {
                return;
            }

            // Sum
            float totalAutoResizeWidth = autoResizeColumns.Sum(x => x.width);

            // Distribute
            foreach (var column in autoResizeColumns)
            {
                column.width += deltaWidth * (column.width / totalAutoResizeWidth);
                column.width  = Mathf.Clamp(column.width, column.minWidth, column.maxWidth);
            }
        }
Esempio n. 15
0
 protected virtual void AddColumnHeaderContextMenuItems(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("Resize to Fit"), false, new GenericMenu.MenuFunction(this.ResizeToFit));
     menu.AddSeparator("");
     for (int i = 0; i < this.state.columns.Length; i++)
     {
         MultiColumnHeaderState.Column column = this.state.columns[i];
         string text = string.IsNullOrEmpty(column.contextMenuText) ? column.headerContent.text : column.contextMenuText;
         if (column.allowToggleVisibility)
         {
             menu.AddItem(new GUIContent(text), this.state.visibleColumns.Contains(i), new GenericMenu.MenuFunction2(this.ToggleVisibility), i);
         }
         else
         {
             menu.AddDisabledItem(new GUIContent(text));
         }
     }
 }
Esempio n. 16
0
 protected override void OnContentGUI(Rect rect, int row, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging)
 {
     if (!isPinging)
     {
         if (this.m_Owner.m_OverriddenMethods.hasItemGUI)
         {
             TreeView.ItemGUIEventArgs args = new TreeView.ItemGUIEventArgs
             {
                 rowRect      = rect,
                 row          = row,
                 item         = item,
                 selected     = selected,
                 focused      = focused,
                 isRenaming   = this.IsRenaming(item.id),
                 isDropTarget = this.IsDropTarget(item)
             };
             if (this.m_Owner.multiColumnHeader != null)
             {
                 int[] visibleColumns = this.m_Owner.multiColumnHeader.state.visibleColumns;
                 MultiColumnHeaderState.Column[] columns = this.m_Owner.multiColumnHeader.state.columns;
                 Rect rowRect = args.rowRect;
                 for (int i = 0; i < visibleColumns.Length; i++)
                 {
                     int num = visibleColumns[i];
                     MultiColumnHeaderState.Column column = columns[num];
                     rowRect.width = column.width;
                     args.cellRect = rowRect;
                     args.column   = num;
                     this.m_Owner.OnItemGUI(args);
                     rowRect.x += column.width;
                 }
             }
             else
             {
                 this.m_Owner.OnItemGUI(args);
             }
         }
         else
         {
             base.OnContentGUI(rect, row, item, label, selected, focused, useBoldFont, false);
         }
     }
 }
Esempio n. 17
0
        protected void SortingButton(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
        {
            if (EditorGUI.Button(headerRect, GUIContent.none, GUIStyle.none))
            {
                this.ColumnHeaderClicked(column, columnIndex);
            }
            if (columnIndex == this.state.sortedColumnIndex && Event.current.type == EventType.Repaint)
            {
                float fixedWidth = MultiColumnHeader.DefaultStyles.arrowStyle.fixedWidth;
                float y          = headerRect.y;
                float f          = 0f;
                switch (column.sortingArrowAlignment)
                {
                case TextAlignment.Left:
                    f = headerRect.x + (float)MultiColumnHeader.DefaultStyles.columnHeader.padding.left;
                    break;

                case TextAlignment.Center:
                    f = headerRect.x + headerRect.width * 0.5f - fixedWidth * 0.5f;
                    break;

                case TextAlignment.Right:
                    f = headerRect.xMax - (float)MultiColumnHeader.DefaultStyles.columnHeader.padding.right - fixedWidth;
                    break;

                default:
                    Debug.LogError("Unhandled enum");
                    break;
                }
                Rect      position = new Rect(Mathf.Round(f), y, fixedWidth, 12f);
                Matrix4x4 matrix   = GUI.matrix;
                if (column.sortedAscending)
                {
                    GUIUtility.RotateAroundPivot(180f, position.center);
                }
                GUI.Label(position, "▾", MultiColumnHeader.DefaultStyles.arrowStyle);
                if (column.sortedAscending)
                {
                    GUI.matrix = matrix;
                }
            }
        }
Esempio n. 18
0
        private void UpdateColumnHeaderRects(Rect totalHeaderRect)
        {
            if (this.m_ColumnRects == null || this.m_ColumnRects.Length != this.state.visibleColumns.Length)
            {
                this.m_ColumnRects = new Rect[this.state.visibleColumns.Length];
            }
            Rect rect = totalHeaderRect;

            for (int i = 0; i < this.state.visibleColumns.Length; i++)
            {
                int num = this.state.visibleColumns[i];
                MultiColumnHeaderState.Column column = this.state.columns[num];
                if (i > 0)
                {
                    rect.x += rect.width;
                }
                rect.width            = column.width;
                this.m_ColumnRects[i] = rect;
            }
        }
Esempio n. 19
0
        public void SetSorting(int columnIndex, bool sortAscending)
        {
            bool flag = false;

            if (this.state.sortedColumnIndex != columnIndex)
            {
                this.state.sortedColumnIndex = columnIndex;
                flag = true;
            }
            MultiColumnHeaderState.Column column = this.GetColumn(columnIndex);
            if (column.sortedAscending != sortAscending)
            {
                column.sortedAscending = sortAscending;
                flag = true;
            }
            if (flag)
            {
                this.OnSortingChanged();
            }
        }
        private void ResizeColumnsWidthsProportionally(float deltaWidth)
        {
            List <MultiColumnHeaderState.Column> list = null;

            foreach (int num in this.state.visibleColumns)
            {
                MultiColumnHeaderState.Column item = this.state.columns[num];
                if ((item.autoResize && ((deltaWidth <= 0f) || (item.width < item.maxWidth))) && ((deltaWidth >= 0f) || (item.width > item.minWidth)))
                {
                    if (list == null)
                    {
                        list = new List <MultiColumnHeaderState.Column>();
                    }
                    list.Add(item);
                }
            }
            if (list != null)
            {
                if (< > f__am$cache0 == null)
                {
Esempio n. 21
0
 protected void SortingButton(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
 {
     if (EditorGUI.Button(headerRect, GUIContent.none, GUIStyle.none))
     {
         this.ColumnHeaderClicked(column, columnIndex);
     }
     if (columnIndex == this.state.sortedColumnIndex && Event.current.type == EventType.Repaint)
     {
         Rect      arrowRect = this.GetArrowRect(column, headerRect);
         Matrix4x4 matrix    = GUI.matrix;
         if (column.sortedAscending)
         {
             GUIUtility.RotateAroundPivot(180f, arrowRect.center - new Vector2(0f, 1f));
         }
         GUI.Label(arrowRect, "▾", MultiColumnHeader.DefaultStyles.arrowStyle);
         if (column.sortedAscending)
         {
             GUI.matrix = matrix;
         }
     }
 }
Esempio n. 22
0
        private void ResizeColumnsWidthsProportionally(float deltaWidth)
        {
            List <MultiColumnHeaderState.Column> list = null;

            int[] visibleColumns = this.state.visibleColumns;
            int   i = 0;

            while (i < visibleColumns.Length)
            {
                int num = visibleColumns[i];
                MultiColumnHeaderState.Column column = this.state.columns[num];
                if (column.autoResize)
                {
                    if (deltaWidth <= 0f || column.width < column.maxWidth)
                    {
                        if (deltaWidth >= 0f || column.width > column.minWidth)
                        {
                            if (list == null)
                            {
                                list = new List <MultiColumnHeaderState.Column>();
                            }
                            list.Add(column);
                        }
                    }
                }
IL_94:
                i++;
                continue;
                goto IL_94;
            }
            if (list != null)
            {
                float num2 = list.Sum((MultiColumnHeaderState.Column x) => x.width);
                foreach (MultiColumnHeaderState.Column current in list)
                {
                    current.width += deltaWidth * (current.width / num2);
                    current.width  = Mathf.Clamp(current.width, current.minWidth, current.maxWidth);
                }
            }
        }
        void UpdateColumnHeaderRects(Rect totalHeaderRect)
        {
            if (m_ColumnRects == null || m_ColumnRects.Length != state.visibleColumns.Length)
            {
                m_ColumnRects = new Rect[state.visibleColumns.Length];
            }

            Rect curRect = totalHeaderRect;

            for (int v = 0; v < state.visibleColumns.Length; v++)
            {
                int columnIndex = state.visibleColumns[v];
                MultiColumnHeaderState.Column column = state.columns[columnIndex];

                if (v > 0)
                {
                    curRect.x += curRect.width;
                }
                curRect.width = column.width;

                m_ColumnRects[v] = curRect;
            }
        }
Esempio n. 24
0
 protected void SortingButton(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
 {
     DoSortingButtonAndColumnHeaderDragging(column, headerRect, columnIndex);
 }
Esempio n. 25
0
        private void DoSortingButtonAndColumnHeaderDragging(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
        {
            var evt = Event.current;

            switch (evt.GetTypeForControl(m_HeaderButtonsControlID))
            {
            case EventType.MouseDown:
            {
                bool canBeInteractedWith = allowDraggingColumnsToReorder || (canSort && column.canSort);
                if (canBeInteractedWith && evt.button == 0 && GUIUtility.hotControl == 0)
                {
                    var interactionRect = Inflate(headerRect, -10, -1, -10, -1);
                    if (interactionRect.Contains(evt.mousePosition))
                    {
                        GUIUtility.hotControl = m_HeaderButtonsControlID;
                        m_SelectedColumnIndex = columnIndex;
                        evt.Use();
                    }
                }
            }
            break;

            case EventType.MouseDrag:
                if (allowDraggingColumnsToReorder && GUIUtility.hotControl == m_HeaderButtonsControlID)
                {
                    if (m_DraggedColumnIndex == -1)
                    {
                        m_DraggedColumnIndex = m_SelectedColumnIndex;
                        Repaint();
                    }

                    if (columnIndex == m_DraggedColumnIndex)
                    {
                        return;
                    }

                    var   columnCenter = headerRect.center;
                    float min, max;
                    if (columnIndex < m_DraggedColumnIndex)
                    {
                        min = headerRect.x;
                        max = columnCenter.x;
                    }
                    else
                    {
                        min = columnCenter.x;
                        max = headerRect.xMax;
                    }

                    int visibleColumnIndex = GetVisibleColumnIndex(columnIndex);
                    if (visibleColumnIndex == 0)
                    {
                        min = float.MinValue;
                    }
                    if (visibleColumnIndex == state.visibleColumns.Length - 1)
                    {
                        max = float.MaxValue;
                    }

                    var mousePosX             = evt.mousePosition.x;
                    var foundDragTargetColumn = mousePosX > min && mousePosX < max;

                    if (foundDragTargetColumn)
                    {
                        MoveColumn(m_DraggedColumnIndex, columnIndex);
                        m_DraggedColumnIndex = m_SelectedColumnIndex = columnIndex;
                        Repaint();
                        evt.Use();
                    }
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == m_HeaderButtonsControlID && m_SelectedColumnIndex == columnIndex)
                {
                    var selectedColumnIndex = m_SelectedColumnIndex;
                    var dragging            = m_DraggedColumnIndex >= 0;
                    m_DraggedColumnIndex  = -1;
                    m_SelectedColumnIndex = -1;
                    GUIUtility.hotControl = 0;
                    evt.Use();

                    if (canSort && column.canSort && !dragging)
                    {
                        if (selectedColumnIndex == columnIndex && headerRect.Contains(evt.mousePosition))
                        {
                            ColumnHeaderClicked(column, columnIndex);
                        }
                    }
                }
                break;

            case EventType.Repaint:
                if (m_SelectedColumnIndex == columnIndex)
                {
                    EditorGUI.DrawRect(headerRect, new Color(0.5f, 0.5f, 0.5f, 0.1f));
                }
                if (m_DraggedColumnIndex == columnIndex)
                {
                    EditorGUIUtility.AddCursorRect(new Rect(-100000, -100000, 200000, 200000), MouseCursor.SlideArrow, m_HeaderButtonsControlID);
                }

                // Draw sorting arrow
                if (canSort && column.canSort && columnIndex == state.sortedColumnIndex)
                {
                    var arrowRect = GetArrowRect(column, headerRect);

                    Matrix4x4 normalMatrix = GUI.matrix;
                    if (column.sortedAscending)
                    {
                        GUIUtility.RotateAroundPivot(180, arrowRect.center - new Vector2(0, 1));
                    }

                    GUI.Label(arrowRect, "\u25BE", DefaultStyles.arrowStyle);

                    if (column.sortedAscending)
                    {
                        GUI.matrix = normalMatrix;
                    }
                }

                break;
            }
        }
        // Virtual so clients can override header behavior and rendering entirely
        public virtual void OnGUI(Rect rect, float xScroll)
        {
            Event evt = Event.current;

            if (m_GUIView == null)
            {
                m_GUIView = GUIView.current;
            }

            DetectSizeChanges(rect);

            if (m_ResizeToFit && evt.type == EventType.Repaint)
            {
                m_ResizeToFit = false;
                ResizeColumnsWidthsProportionally(rect.width - GUI.skin.verticalScrollbar.fixedWidth - state.widthOfAllVisibleColumns);
            }

            // We create a guiclip to let the header be able to scroll horizontally according to the tree view's horizontal scroll
            GUIClip.Push(rect, new Vector2(-xScroll, 0f), Vector2.zero, false);
            {
                Rect localRect = new Rect(0, 0, rect.width, rect.height);

                // Background ( We always add the width of the vertical scrollbar to accomodate if this is being shown below e.g by a tree view)
                float widthOfAllColumns = state.widthOfAllVisibleColumns;
                float backgroundWidth   = (localRect.width > widthOfAllColumns ? localRect.width : widthOfAllColumns) + GUI.skin.verticalScrollbar.fixedWidth;
                Rect  backgroundRect    = new Rect(0, 0, backgroundWidth, localRect.height);
                GUI.Label(backgroundRect, GUIContent.none, DefaultStyles.background);

                // Context menu
                if (evt.type == EventType.ContextClick && backgroundRect.Contains(evt.mousePosition))
                {
                    evt.Use();
                    DoContextMenu();
                }

                // Update column rects (cached for clients to have fast access to column rects by using GetCellRect)
                UpdateColumnHeaderRects(localRect);

                // Columns
                for (int v = 0; v < state.visibleColumns.Length; v++)
                {
                    int columnIndex = state.visibleColumns[v];
                    MultiColumnHeaderState.Column column = state.columns[columnIndex];

                    Rect        headerRect           = m_ColumnRects[v];
                    const float limitHeightOfDivider = 4f;
                    Rect        dividerRect          = new Rect(headerRect.xMax - 1, headerRect.y + limitHeightOfDivider, 1f, headerRect.height - 2 * limitHeightOfDivider);

                    // Resize columns logic
                    Rect dragRect = new Rect(dividerRect.x - m_DividerWidth * 0.5f, localRect.y, m_DividerWidth, localRect.height);
                    bool hasControl;
                    column.width = EditorGUI.WidthResizer(dragRect, column.width, column.minWidth, column.maxWidth, out hasControl);
                    if (hasControl && evt.type == EventType.Repaint)
                    {
                        DrawColumnResizing(headerRect, column);
                    }

                    // Draw divider (can be overridden)
                    DrawDivider(dividerRect, column);

                    // Draw header (can be overridden)
                    ColumnHeaderGUI(column, headerRect, columnIndex);
                }
            }
            GUIClip.Pop();
        }
Esempio n. 27
0
 internal virtual void DrawDivider(Rect dividerRect, MultiColumnHeaderState.Column column)
 {
     EditorGUI.DrawRect(dividerRect, new Color(0.5f, 0.5f, 0.5f, 0.5f));
 }