Exemplo n.º 1
0
        public override void OnRowGUI(Rect rowRect, TreeViewItem item, int row, bool selected, bool focused)
        {
            rowRect.height -= 1f;
            Rect rect  = rowRect;
            Rect rect2 = rowRect;

            rect.width  = this.m_Column1Width;
            rect.xMin  += this.GetFoldoutIndent(item);
            rect2.xMin += this.m_Column1Width + 1f;
            float foldoutIndent = this.GetFoldoutIndent(item);
            Rect  position      = rowRect;
            int   itemControlID = TreeViewController.GetItemControlID(item);
            bool  flag          = false;

            if (this.m_TreeView.dragging != null)
            {
                flag = (this.m_TreeView.dragging.GetDropTargetControlID() == itemControlID && this.m_TreeView.data.CanBeParent(item));
            }
            bool  flag2  = this.m_TreeView.data.IsExpandable(item);
            Color color  = new Color(0f, 0.22f, 0.44f);
            Color color2 = new Color(0.1f, 0.1f, 0.1f);

            EditorGUI.DrawRect(rect, (!selected) ? color2 : color);
            EditorGUI.DrawRect(rect2, (!selected) ? color2 : color);
            if (flag)
            {
                EditorGUI.DrawRect(new Rect(rowRect.x, rowRect.y, 3f, rowRect.height), Color.yellow);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect position2 = rect;
                position2.xMin += this.m_FoldoutWidth;
                GUI.Label(position2, item.displayName, EditorStyles.largeLabel);
                if (rowRect.height > 20f)
                {
                    position2.y += 16f;
                    GUI.Label(position2, "Ut tincidunt tortor. Donec nonummy, enim in lacinia pulvinar", EditorStyles.miniLabel);
                }
                if (this.m_TreeView.dragging != null && this.m_TreeView.dragging.GetRowMarkerControlID() == itemControlID)
                {
                    this.m_DraggingInsertionMarkerRect = new Rect(rowRect.x + foldoutIndent, rowRect.y, rowRect.width - foldoutIndent, rowRect.height);
                }
            }
            if (flag2)
            {
                position.x     = foldoutIndent;
                position.width = this.m_FoldoutWidth;
                EditorGUI.BeginChangeCheck();
                bool expand = GUI.Toggle(position, this.m_TreeView.data.IsExpanded(item), GUIContent.none, TestGUICustomItemHeights.Styles.foldout);
                if (EditorGUI.EndChangeCheck())
                {
                    this.m_TreeView.UserInputChangedExpandedState(item, row, expand);
                }
            }
        }
Exemplo n.º 2
0
        public virtual void OnRowGUI(Rect rowRect, TreeViewItem item, int row, bool selected, bool focused)
        {
            using (new EditorGUI.DisabledScope(TimelineWindow.instance.currentMode.TrackState(TimelineWindow.instance.state) == TimelineModeGUIState.Disabled))
            {
                var sqvi = (TimelineTrackBaseGUI)item;
                sqvi.treeViewToWindowTransformation = m_TreeView.GetTotalRect().position - m_TreeView.state.scrollPos;

                // this may be called because an encompassing parent is visible
                if (!sqvi.visibleExpanded)
                {
                    return;
                }

                Rect headerRect  = rowRect;
                Rect contentRect = rowRect;

                headerRect.width  = m_State.sequencerHeaderWidth - 2.0f;
                contentRect.xMin += m_State.sequencerHeaderWidth;
                contentRect.width = rowRect.width - m_State.sequencerHeaderWidth - 1.0f;

                Rect foldoutRect = rowRect;

                var indent = GetFoldoutIndent(item);
                var headerRectWithIndent = headerRect;
                headerRectWithIndent.xMin = indent;
                var rowRectWithIndent = new Rect(rowRect.x + indent, rowRect.y, rowRect.width - indent, rowRect.height);
                sqvi.Draw(headerRectWithIndent, contentRect, m_State);
                sqvi.DrawInsertionMarkers(rowRectWithIndent);

                if (Event.current.type == EventType.Repaint)
                {
                    m_State.spacePartitioner.AddBounds(sqvi);

                    // Show marker below this Item
                    if (showInsertionMarker)
                    {
                        if (m_TreeView.dragging != null && m_TreeView.dragging.GetRowMarkerControlID() == TreeViewController.GetItemControlID(item))
                        {
                            m_DraggingInsertionMarkerRect = rowRectWithIndent;
                        }
                    }
                }

                // Draw foldout (after text content above to ensure drop down icon is rendered above selection highlight)
                DrawFoldout(item, foldoutRect, indent);

                sqvi.ClearDrawFlags();
            }
        }
        public override void OnRowGUI(Rect rowRect, TreeViewItem item, int row, bool selected, bool focused)
        {
            rowRect.height -= 1f;
            Rect column1Rect = rowRect;
            Rect column2Rect = rowRect;

            column1Rect.width = m_Column1Width;
            column1Rect.xMin += GetFoldoutIndent(item);
            column2Rect.xMin += m_Column1Width + 1;

            float indent  = GetFoldoutIndent(item);
            Rect  tmpRect = rowRect;

            int itemControlID = TreeViewController.GetItemControlID(item);

            bool isDropTarget = false;

            if (m_TreeView.dragging != null)
            {
                isDropTarget = m_TreeView.dragging.GetDropTargetControlID() == itemControlID && m_TreeView.data.CanBeParent(item);
            }
            bool showFoldout = m_TreeView.data.IsExpandable(item);


            Color selectedColor = new Color(0.0f, 0.22f, 0.44f);
            Color normalColor   = new Color(0.1f, 0.1f, 0.1f);

            EditorGUI.DrawRect(column1Rect, selected ? selectedColor : normalColor);
            EditorGUI.DrawRect(column2Rect, selected ? selectedColor : normalColor);

            if (isDropTarget)
            {
                EditorGUI.DrawRect(new Rect(rowRect.x, rowRect.y, 3, rowRect.height), Color.yellow);
            }

            if (Event.current.type == EventType.Repaint)
            {
                Rect labelRect = column1Rect;
                labelRect.xMin += m_FoldoutWidth;

                GUI.Label(labelRect, item.displayName, EditorStyles.largeLabel);
                if (rowRect.height > 20f)
                {
                    labelRect.y += 16f;
                    GUI.Label(labelRect, "Ut tincidunt tortor. Donec nonummy, enim in lacinia pulvinar", EditorStyles.miniLabel);
                }

                // Show marker below this Item
                if (m_TreeView.dragging != null && m_TreeView.dragging.GetRowMarkerControlID() == itemControlID)
                {
                    m_DraggingInsertionMarkerRect = new Rect(rowRect.x + indent, rowRect.y, rowRect.width - indent, rowRect.height);
                }
            }

            // Draw foldout (after text content above to ensure drop down icon is rendered above selection highlight)
            if (showFoldout)
            {
                tmpRect.x     = indent;
                tmpRect.width = m_FoldoutWidth;
                EditorGUI.BeginChangeCheck();
                bool newExpandedValue = GUI.Toggle(tmpRect, m_TreeView.data.IsExpanded(item), GUIContent.none, Styles.foldout);
                if (EditorGUI.EndChangeCheck())
                {
                    m_TreeView.UserInputChangedExpandedState(item, row, newExpandedValue);
                }
            }
        }
        public virtual void OnRowGUI(Rect rowRect, TreeViewItem item, int row, bool selected, bool focused)
        {
            Rect headerRect = rowRect;
            Rect trackRect  = rowRect;

            headerRect.set_width(this.m_State.sequencerHeaderWidth);
            trackRect.set_xMin(trackRect.get_xMin() + this.m_State.sequencerHeaderWidth);
            trackRect.set_width(rowRect.get_width() - this.m_State.sequencerHeaderWidth - 1f);
            float foldoutIndent = this.GetFoldoutIndent(item);
            Rect  rect          = rowRect;
            TimelineTrackBaseGUI timelineTrackBaseGUI = (TimelineTrackBaseGUI)item;

            timelineTrackBaseGUI.isExpanded = this.m_TreeView.get_data().IsExpanded(item);
            timelineTrackBaseGUI.Draw(headerRect, trackRect, this.m_State, foldoutIndent);
            if (trackRect.Contains(Event.get_current().get_mousePosition()) || Event.get_current().get_isKey())
            {
                timelineTrackBaseGUI.OnEvent(Event.get_current(), this.m_State, false);
            }
            if (Event.get_current().get_type() == 7)
            {
                if (this.showInsertionMarker)
                {
                    if (this.m_TreeView.get_dragging() != null && this.m_TreeView.get_dragging().GetRowMarkerControlID() == TreeViewController.GetItemControlID(item))
                    {
                        this.m_DraggingInsertionMarkerRect = new Rect(rowRect.get_x() + foldoutIndent, rowRect.get_y(), rowRect.get_width() - foldoutIndent, rowRect.get_height());
                    }
                }
            }
            bool flag = this.m_TreeView.get_data().IsExpandable(item);

            if (flag)
            {
                rect.set_x(foldoutIndent - TimelineTreeView.kFoldOutOffset);
                rect.set_width(this.m_FoldoutWidth);
                EditorGUI.BeginChangeCheck();
                float num = (float)DirectorStyles.Instance.foldout.get_normal().get_background().get_height();
                rect.set_y(rect.get_y() + num / 2f);
                rect.set_height(num);
                bool flag2 = GUI.Toggle(rect, this.m_TreeView.get_data().IsExpanded(item), GUIContent.none, TimelineTreeView.m_Styles.foldout);
                if (EditorGUI.EndChangeCheck())
                {
                    if (Event.get_current().get_alt())
                    {
                        this.m_TreeView.get_data().SetExpandedWithChildren(item, flag2);
                    }
                    else
                    {
                        this.m_TreeView.get_data().SetExpanded(item, flag2);
                    }
                }
            }
            if (headerRect.Contains(Event.get_current().get_mousePosition()) || Event.get_current().get_isKey())
            {
                timelineTrackBaseGUI.OnEvent(Event.get_current(), this.m_State, false);
            }
        }