示例#1
0
        private void DrawLine(int pos, object obj, float width, bool rebuild)
        {
            bool     selectionHappens = EditorTool.MouseClickInRect(new Rect(0, pos * _appearance.LineHeight, width, _appearance.LineHeight)) || (rebuild && pos == 0);
            GUIStyle style            = new GUIStyle((pos % 2 != 0) ? _appearance.StyleLine : _appearance.StyleLineAlt);

            // click event
            if (selectionHappens)
            {
                _selected = obj;
            }

            // note that the 'selected-style' assignment below should be isolated from the if-conditional statement above
            // since the above if is a one-time event, on the contrary, the 'selected-style' assignment below should be done every time in the drawing process
            if (_selected == obj)
            {
                style = _appearance.StyleSelected;
            }
            else
            {
                Color specialColor;
                if (_specialTextColors != null && _specialTextColors.TryGetValue(obj, out specialColor))
                {
                    style.normal.textColor = specialColor;
                }
            }

            // draw line column
            for (int i = 0; i < _descArray.Count; i++)
            {
                DrawLineCol(pos, i, width, obj, style, selectionHappens);
            }
        }
示例#2
0
        private void DrawTitle(float width)
        {
            for (int i = 0; i < _descArray.Count; i++)
            {
                // title label
                GUI.Label(LabelRect(width, i, 0), _descArray[i].TitleText + (_sortSlot == i ? _appearance.GetSortMark(_descending) : ""), _appearance.GetTitleStyle(_sortSlot == i));

                // click event
                if (EditorTool.MouseClickInRect(LabelRect(width, i, 0)))
                {
                    if (_sortSlot == i)
                    {
                        _descending = !_descending;
                    }
                    else
                    {
                        _sortSlot = i;
                    }
                    SortData();
                    _hostWindow.Repaint();
                }
            }
        }