Beispiel #1
0
		protected override void OnHandleCreated(EventArgs e)
		{
			base.OnHandleCreated(e);
			_parentForm = FindForm();

			// set the current state
			if (_controlToHide != null)
				_currentState = _controlToHide.Visible ? SplitterState.Expanded : SplitterState.Collapsed;
		}
        private void animationTimerTick(object sender, System.EventArgs e)
        {
            switch (currentState)
            {
                case SplitterState.Collapsing:

                    if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
                    {
                        // vertical splitter
                        if (controlToHide.Width > animationStep)
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Width -= animationStep;
                            }
                            controlToHide.Width -= animationStep;
                        }
                        else
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Width = parentFormWidth;
                            }
                            controlToHide.Visible = false;
                            animationTimer.Enabled = false;
                            controlToHide.Width = controlWidth;
                            currentState = SplitterState.Collapsed;
                            this.Invalidate();
                        }
                    }
                    else
                    {
                        // horizontal splitter
                        if (controlToHide.Height > animationStep)
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Height -= animationStep;
                            }
                            controlToHide.Height -= animationStep;
                        }
                        else
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Height = parentFormHeight;
                            }
                            controlToHide.Visible = false;
                            animationTimer.Enabled = false;
                            controlToHide.Height = controlHeight;
                            currentState = SplitterState.Collapsed;
                            this.Invalidate();
                        }
                    }
                    break;

                case SplitterState.Expanding:

                    if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
                    {
                        // vertical splitter
                        if (controlToHide.Width < (controlWidth - animationStep))
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Width += animationStep;
                            }
                            controlToHide.Width += animationStep;
                        }
                        else
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Width = parentFormWidth;
                            }
                            controlToHide.Width = controlWidth;
                            controlToHide.Visible = true;
                            animationTimer.Enabled = false;
                            currentState = SplitterState.Expanded;
                            this.Invalidate();
                        }
                    }
                    else
                    {
                        // horizontal splitter
                        if (controlToHide.Height < (controlHeight - animationStep))
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Height += animationStep;
                            }
                            controlToHide.Height += animationStep;
                        }
                        else
                        {
                            if (expandParentForm && parentForm.WindowState != FormWindowState.Maximized
                                && parentForm != null)
                            {
                                parentForm.Height = parentFormHeight;
                            }
                            controlToHide.Height = controlHeight;
                            controlToHide.Visible = true;
                            animationTimer.Enabled = false;
                            currentState = SplitterState.Expanded;
                            this.Invalidate();
                        }

                    }
                    break;
            }
        }
        private void ToggleSplitter()
        {
            // if an animation is currently in progress for this control, drop out
            if (currentState == SplitterState.Collapsing || currentState == SplitterState.Expanding)
                return;

            controlWidth = controlToHide.Width;
            controlHeight = controlToHide.Height;

            if (controlToHide.Visible)
            {
                if (useAnimations)
                {
                    currentState = SplitterState.Collapsing;

                    if (parentForm != null)
                    {
                        if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
                        {
                            parentFormWidth = parentForm.Width - controlWidth;
                        }
                        else
                        {
                            parentFormHeight = parentForm.Height - controlHeight;
                        }
                    }

                    this.animationTimer.Enabled = true;
                }
                else
                {
                    // no animations, so just toggle the visible state
                    currentState = SplitterState.Collapsed;
                    controlToHide.Visible = false;
                    if (expandParentForm && parentForm != null)
                    {
                        if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
                        {
                            parentForm.Width -= controlToHide.Width;
                        }
                        else
                        {
                            parentForm.Height -= controlToHide.Height;
                        }
                    }
                }
            }
            else
            {
                // control to hide is collapsed
                if (useAnimations)
                {
                    currentState = SplitterState.Expanding;

                    if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
                    {
                        if (parentForm != null)
                        {
                            parentFormWidth = parentForm.Width + controlWidth;
                        }
                        controlToHide.Width = 0;

                    }
                    else
                    {
                        if (parentForm != null)
                        {
                            parentFormHeight = parentForm.Height + controlHeight;
                        }
                        controlToHide.Height = 0;
                    }
                    controlToHide.Visible = true;
                    this.animationTimer.Enabled = true;
                }
                else
                {
                    // no animations, so just toggle the visible state
                    currentState = SplitterState.Expanded;
                    controlToHide.Visible = true;
                    if (expandParentForm && parentForm != null)
                    {
                        if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
                        {
                            parentForm.Width += controlToHide.Width;
                        }
                        else
                        {
                            parentForm.Height += controlToHide.Height;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private void ToggleSplitter()
        {
            _savedControlWidth = _targetControl.Width;
            _savedControlHeight = _targetControl.Height;

            if (_targetControl.Visible) {
                // no animations, so just toggle the visible state
                _state = SplitterState.Collapsed;
                _targetControl.Visible = false;
            }
            else {
                _state = SplitterState.Expanded;
                _targetControl.Visible = true;
            }
        }
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);
            this.parentForm = this.FindForm();

            // set the current state
            if (this.controlToHide != null)
            {
                if (this.controlToHide.Visible)
                {
                    this.currentState = SplitterState.Expanded;
                }
                else
                {
                    this.currentState = SplitterState.Collapsed;
                }
            }
        }
Beispiel #6
0
        private void ToggleSplitter()
        {
            // if an animation is currently in progress for this control, drop out
            if (_currentState == SplitterState.Collapsing || _currentState == SplitterState.Expanding)
            {
                return;
            }

            _controlWidth  = _controlToHide.Width;
            _controlHeight = _controlToHide.Height;

            if (_controlToHide.Visible)
            {
                if (_useAnimations)
                {
                    _currentState = SplitterState.Collapsing;

                    if (_parentForm != null)
                    {
                        if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                        {
                            _parentFormWidth = _parentForm.Width - _controlWidth;
                        }
                        else
                        {
                            _parentFormHeight = _parentForm.Height - _controlHeight;
                        }
                    }

                    _animationTimer.Enabled = true;
                }
                else
                {
                    // no animations, so just toggle the visible state
                    _currentState          = SplitterState.Collapsed;
                    _controlToHide.Visible = false;
                    if (_expandParentForm && _parentForm != null)
                    {
                        if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                        {
                            _parentForm.Width -= _controlToHide.Width;
                        }
                        else
                        {
                            _parentForm.Height -= _controlToHide.Height;
                        }
                    }
                }
            }
            else
            // control to hide is collapsed
            if (_useAnimations)
            {
                _currentState = SplitterState.Expanding;

                if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                {
                    if (_parentForm != null)
                    {
                        _parentFormWidth = _parentForm.Width + _controlWidth;
                    }
                    _controlToHide.Width = 0;
                }
                else
                {
                    if (_parentForm != null)
                    {
                        _parentFormHeight = _parentForm.Height + _controlHeight;
                    }
                    _controlToHide.Height = 0;
                }
                _controlToHide.Visible  = true;
                _animationTimer.Enabled = true;
            }
            else
            {
                // no animations, so just toggle the visible state
                _currentState          = SplitterState.Expanded;
                _controlToHide.Visible = true;
                if (_expandParentForm && _parentForm != null)
                {
                    if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                    {
                        _parentForm.Width += _controlToHide.Width;
                    }
                    else
                    {
                        _parentForm.Height += _controlToHide.Height;
                    }
                }
            }
        }
Beispiel #7
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);
            if (_targetControl == null)
                throw new Exception("_targetControl must be set");
            if (this.Dock == DockStyle.Fill || this.Dock == DockStyle.None)
                throw new Exception("invalid DockStyle");

            // set the current state
            _state = _targetControl.Visible ? SplitterState.Expanded : SplitterState.Collapsed;
        }
        void InitIfNeeded()
        {
            if (m_Initialized)
            {
                return;
            }

            var cpuDetailColumns = new[]
            {
                HierarchyFrameDataView.columnObjectName,
                HierarchyFrameDataView.columnTotalPercent,
                HierarchyFrameDataView.columnGcMemory,
                HierarchyFrameDataView.columnTotalTime
            };
            var gpuDetailColumns = new[]
            {
                HierarchyFrameDataView.columnObjectName,
                HierarchyFrameDataView.columnTotalGpuPercent,
                HierarchyFrameDataView.columnDrawCalls,
                HierarchyFrameDataView.columnTotalGpuTime
            };
            var profilerColumns   = gpuView ? gpuDetailColumns : cpuDetailColumns;
            var defaultSortColumn = gpuView ? HierarchyFrameDataView.columnTotalGpuTime : HierarchyFrameDataView.columnTotalTime;

            var columns     = ProfilerFrameDataHierarchyView.CreateColumns(profilerColumns);
            var headerState = ProfilerFrameDataHierarchyView.CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);

            headerState.columns[0].minWidth              = 60;
            headerState.columns[0].autoResize            = true;
            headerState.columns[0].allowToggleVisibility = false;
            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            }

            var firstInit = m_MultiColumnHeaderState == null;

            m_MultiColumnHeaderState = headerState;

            m_MultiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns)
            {
                height = 25
            };
            if (firstInit)
            {
                m_MultiColumnHeader.ResizeToFit();
            }

            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }
            m_TreeView = new ObjectsTreeView(m_TreeViewState, m_MultiColumnHeader);
            m_TreeView.frameItemEvent += frameItemEvent;

            if (m_VertSplit == null || m_VertSplit.relativeSizes == null || m_VertSplit.relativeSizes.Length == 0)
            {
                m_VertSplit = new SplitterState(new[] { 60f, 40f }, new[] { 50, 50 }, null);
            }

            m_Initialized = true;
        }
Beispiel #9
0
        void InitIfNeeded()
        {
            if (m_Initialized)
            {
                return;
            }

            if (m_CachedCallstack == null)
            {
                m_CachedCallstack = new List <ulong>();
            }

            var cpuDetailColumns = new[]
            {
                HierarchyFrameDataView.columnObjectName,
                HierarchyFrameDataView.columnTotalPercent,
                HierarchyFrameDataView.columnGcMemory,
                HierarchyFrameDataView.columnTotalTime
            };
            var gpuDetailColumns = new[]
            {
                HierarchyFrameDataView.columnObjectName,
                HierarchyFrameDataView.columnTotalGpuPercent,
                HierarchyFrameDataView.columnDrawCalls,
                HierarchyFrameDataView.columnTotalGpuTime
            };
            var profilerColumns   = gpuView ? gpuDetailColumns : cpuDetailColumns;
            var defaultSortColumn = gpuView ? HierarchyFrameDataView.columnTotalGpuTime : HierarchyFrameDataView.columnTotalTime;

            var columns     = ProfilerFrameDataHierarchyView.CreateColumns(profilerColumns);
            var headerState = ProfilerFrameDataHierarchyView.CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);

            headerState.columns[0].minWidth              = 60;
            headerState.columns[0].autoResize            = true;
            headerState.columns[0].allowToggleVisibility = false;

            var multiColumnHeaderStateData = SessionState.GetString(multiColumnHeaderStatePrefKey, "");

            if (!string.IsNullOrEmpty(multiColumnHeaderStateData))
            {
                try
                {
                    var restoredHeaderState = JsonUtility.FromJson <MultiColumnHeaderState>(multiColumnHeaderStateData);
                    if (restoredHeaderState != null)
                    {
                        m_MultiColumnHeaderState = restoredHeaderState;
                    }
                }
                catch {} // Nevermind, we'll just fall back to the default
            }

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            }

            var firstInit = m_MultiColumnHeaderState == null;

            m_MultiColumnHeaderState = headerState;

            m_MultiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns)
            {
                height = 25
            };
            if (firstInit)
            {
                m_MultiColumnHeader.ResizeToFit();
            }

            m_MultiColumnHeader.visibleColumnsChanged += OnMultiColumnHeaderChanged;
            m_MultiColumnHeader.sortingChanged        += OnMultiColumnHeaderChanged;

            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }
            m_TreeView = new ObjectsTreeView(m_TreeViewState, m_MultiColumnHeader);
            m_TreeView.frameItemEvent += frameItemEvent;

            if (m_VertSplit == null || !m_VertSplit.IsValid())
            {
                m_VertSplit = SplitterState.FromRelative(new[] { SessionState.GetFloat(splitter0StatePrefKey, 60f), SessionState.GetFloat(splitter1StatePrefKey, 40f) }, new[] { 50f, 50f }, null);
            }

            m_Initialized = true;
        }
Beispiel #10
0
        private void animationTimerTick(object sender, System.EventArgs e)
        {
            switch (currentState)
            {
            case SplitterState.Collapsing:

                if (this.Dock == System.Windows.Forms.DockStyle.Left || this.Dock == System.Windows.Forms.DockStyle.Right)
                {
                    // vertical splitter
                    if (controlToHide.Width > animationStep)
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Width -= animationStep;
                        }
                        controlToHide.Width -= animationStep;
                    }
                    else
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Width = parentFormWidth;
                        }
                        controlToHide.Visible  = false;
                        animationTimer.Enabled = false;
                        controlToHide.Width    = controlWidth;
                        currentState           = SplitterState.Collapsed;
                        this.Invalidate();
                    }
                }
                else
                {
                    // horizontal splitter
                    if (controlToHide.Height > animationStep)
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Height -= animationStep;
                        }
                        controlToHide.Height -= animationStep;
                    }
                    else
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Height = parentFormHeight;
                        }
                        controlToHide.Visible  = false;
                        animationTimer.Enabled = false;
                        controlToHide.Height   = controlHeight;
                        currentState           = SplitterState.Collapsed;
                        this.Invalidate();
                    }
                }
                break;

            case SplitterState.Expanding:

                if (this.Dock == System.Windows.Forms.DockStyle.Left || this.Dock == System.Windows.Forms.DockStyle.Right)
                {
                    // vertical splitter
                    if (controlToHide.Width < (controlWidth - animationStep))
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Width += animationStep;
                        }
                        controlToHide.Width += animationStep;
                    }
                    else
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Width = parentFormWidth;
                        }
                        controlToHide.Width    = controlWidth;
                        controlToHide.Visible  = true;
                        animationTimer.Enabled = false;
                        currentState           = SplitterState.Expanded;
                        this.Invalidate();
                    }
                }
                else
                {
                    // horizontal splitter
                    if (controlToHide.Height < (controlHeight - animationStep))
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Height += animationStep;
                        }
                        controlToHide.Height += animationStep;
                    }
                    else
                    {
                        if (expandParentForm && parentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized &&
                            parentForm != null)
                        {
                            parentForm.Height = parentFormHeight;
                        }
                        controlToHide.Height   = controlHeight;
                        controlToHide.Visible  = true;
                        animationTimer.Enabled = false;
                        currentState           = SplitterState.Expanded;
                        this.Invalidate();
                    }
                }
                break;
            }
        }
Beispiel #11
0
        void InitIfNeeded()
        {
            if (m_Initialized)
            {
                return;
            }

            var cpuHierarchyColumns = new[]
            {
                ProfilerColumn.FunctionName, ProfilerColumn.TotalPercent, ProfilerColumn.SelfPercent, ProfilerColumn.Calls,
                ProfilerColumn.GCMemory, ProfilerColumn.TotalTime, ProfilerColumn.SelfTime, ProfilerColumn.WarningCount
            };
            var gpuHierarchyColumns = new[]
            {
                ProfilerColumn.FunctionName, ProfilerColumn.TotalGPUPercent, ProfilerColumn.DrawCalls, ProfilerColumn.TotalGPUTime
            };
            var profilerColumns   = gpuView ? gpuHierarchyColumns : cpuHierarchyColumns;
            var defaultSortColumn = gpuView ? ProfilerColumn.TotalGPUTime : ProfilerColumn.TotalTime;

            var columns     = CreateColumns(profilerColumns);
            var headerState = CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            }

            var firstInit = m_MultiColumnHeaderState == null;

            m_MultiColumnHeaderState = headerState;

            var multiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns)
            {
                height = 25
            };

            if (firstInit)
            {
                multiColumnHeader.ResizeToFit();
            }

            // Check if it already exists (deserialized from window layout file or scriptable object)
            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }
            m_TreeView = new ProfilerFrameDataTreeView(m_TreeViewState, multiColumnHeader);
            m_TreeView.selectionChanged += OnMainTreeViewSelectionChanged;
            m_TreeView.searchChanged    += OnMainTreeViewSearchChanged;
            m_TreeView.Reload();

            m_SearchField = new SearchField();
            m_SearchField.downOrUpArrowKeyPressed += m_TreeView.SetFocusAndEnsureSelectedItem;

            if (m_DetailedObjectsView == null)
            {
                m_DetailedObjectsView = new ProfilerDetailedObjectsView();
            }
            m_DetailedObjectsView.gpuView         = gpuView;
            m_DetailedObjectsView.frameItemEvent += FrameItem;
            if (m_DetailedCallsView == null)
            {
                m_DetailedCallsView = new ProfilerDetailedCallsView();
            }
            m_DetailedCallsView.frameItemEvent += FrameItem;
            if (m_DetailedViewSpliterState == null || m_DetailedViewSpliterState.relativeSizes == null || m_DetailedViewSpliterState.relativeSizes.Length == 0)
            {
                m_DetailedViewSpliterState = new SplitterState(new[] { 70f, 30f }, new[] { 450, 50 }, null);
            }

            m_Initialized = true;
        }
Beispiel #12
0
        private void ToggleSplitter()
        {
            // if an animation is currently in progress for this control, drop out
            if (currentState == SplitterState.Collapsing || currentState == SplitterState.Expanding)
            {
                return;
            }

            controlWidth  = controlToHide.Width;
            controlHeight = controlToHide.Height;

            if (controlToHide.Visible)
            {
                if (useAnimations)
                {
                    currentState = SplitterState.Collapsing;

                    if (parentForm != null)
                    {
                        if (this.Dock == System.Windows.Forms.DockStyle.Left || this.Dock == System.Windows.Forms.DockStyle.Right)
                        {
                            parentFormWidth = parentForm.Width - controlWidth;
                        }
                        else
                        {
                            parentFormHeight = parentForm.Height - controlHeight;
                        }
                    }

                    this.animationTimer.Enabled = true;
                }
                else
                {
                    // no animations, so just toggle the visible state
                    currentState          = SplitterState.Collapsed;
                    controlToHide.Visible = false;
                    if (expandParentForm && parentForm != null)
                    {
                        if (this.Dock == System.Windows.Forms.DockStyle.Left || this.Dock == System.Windows.Forms.DockStyle.Right)
                        {
                            parentForm.Width -= controlToHide.Width;
                        }
                        else
                        {
                            parentForm.Height -= controlToHide.Height;
                        }
                    }
                }
            }
            else
            {
                // control to hide is collapsed
                if (useAnimations)
                {
                    currentState = SplitterState.Expanding;

                    if (this.Dock == System.Windows.Forms.DockStyle.Left || this.Dock == System.Windows.Forms.DockStyle.Right)
                    {
                        if (parentForm != null)
                        {
                            parentFormWidth = parentForm.Width + controlWidth;
                        }
                        controlToHide.Width = 0;
                    }
                    else
                    {
                        if (parentForm != null)
                        {
                            parentFormHeight = parentForm.Height + controlHeight;
                        }
                        controlToHide.Height = 0;
                    }
                    controlToHide.Visible       = true;
                    this.animationTimer.Enabled = true;
                }
                else
                {
                    // no animations, so just toggle the visible state
                    currentState          = SplitterState.Expanded;
                    controlToHide.Visible = true;
                    if (expandParentForm && parentForm != null)
                    {
                        if (this.Dock == System.Windows.Forms.DockStyle.Left || this.Dock == System.Windows.Forms.DockStyle.Right)
                        {
                            parentForm.Width += controlToHide.Width;
                        }
                        else
                        {
                            parentForm.Height += controlToHide.Height;
                        }
                    }
                }
            }
        }
Beispiel #13
0
        void InitIfNeeded()
        {
            if (m_Initialized)
            {
                return;
            }

            var cpuHierarchyColumns = new[]
            {
                HierarchyFrameDataView.columnName,
                HierarchyFrameDataView.columnTotalPercent,
                HierarchyFrameDataView.columnSelfPercent,
                HierarchyFrameDataView.columnCalls,
                HierarchyFrameDataView.columnGcMemory,
                HierarchyFrameDataView.columnTotalTime,
                HierarchyFrameDataView.columnSelfTime,
                HierarchyFrameDataView.columnWarningCount
            };
            var gpuHierarchyColumns = new[]
            {
                HierarchyFrameDataView.columnName,
                HierarchyFrameDataView.columnTotalGpuPercent,
                HierarchyFrameDataView.columnDrawCalls,
                HierarchyFrameDataView.columnTotalGpuTime
            };
            var profilerColumns   = gpuView ? gpuHierarchyColumns : cpuHierarchyColumns;
            var defaultSortColumn = gpuView ? HierarchyFrameDataView.columnTotalGpuTime : HierarchyFrameDataView.columnTotalTime;

            var columns = CreateColumns(profilerColumns);

            var multiColumnHeaderStateData = SessionState.GetString(multiColumnHeaderStatePrefKey, "");

            if (!string.IsNullOrEmpty(multiColumnHeaderStateData))
            {
                try
                {
                    var restoredHeaderState = JsonUtility.FromJson <MultiColumnHeaderState>(multiColumnHeaderStateData);
                    if (restoredHeaderState != null)
                    {
                        m_MultiColumnHeaderState = restoredHeaderState;
                    }
                }
                catch {} // Nevermind, we'll just fall back to the default
            }
            var headerState = CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            }

            var firstInit = m_MultiColumnHeaderState == null;

            m_MultiColumnHeaderState = headerState;

            var multiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns)
            {
                height = 25
            };

            if (firstInit)
            {
                multiColumnHeader.ResizeToFit();
            }

            multiColumnHeader.visibleColumnsChanged += OnMultiColumnHeaderChanged;
            multiColumnHeader.sortingChanged        += OnMultiColumnHeaderChanged;

            // Check if it already exists (deserialized from window layout file or scriptable object)
            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }
            m_TreeView = new ProfilerFrameDataTreeView(m_TreeViewState, multiColumnHeader, cpuModule);
            m_TreeView.selectionChanged += OnMainTreeViewSelectionChanged;
            m_TreeView.searchChanged    += OnMainTreeViewSearchChanged;
            m_TreeView.Reload();

            m_SearchField = new SearchField();
            m_SearchField.downOrUpArrowKeyPressed += m_TreeView.SetFocusAndEnsureSelectedItem;

            if (m_DetailedObjectsView == null)
            {
                m_DetailedObjectsView = new ProfilerDetailedObjectsView(detailedObjectsViewPrefKeyPrefix);
            }
            m_DetailedObjectsView.gpuView         = gpuView;
            m_DetailedObjectsView.frameItemEvent += FrameItem;
            if (m_DetailedCallsView == null)
            {
                m_DetailedCallsView = new ProfilerDetailedCallsView(detailedCallsViewPrefKeyPrefix);
                m_DetailedCallsView.profilerSampleNameProvider = cpuModule;
            }
            m_DetailedCallsView.frameItemEvent += FrameItem;
            if (m_DetailedViewSpliterState == null || m_DetailedViewSpliterState.relativeSizes == null || m_DetailedViewSpliterState.relativeSizes.Length == 0)
            {
                m_DetailedViewSpliterState = new SplitterState(new[] { SessionState.GetFloat(splitter0StatePrefKey, 70f), SessionState.GetFloat(splitter1StatePrefKey, 30f) }, new[] { 450, 50 }, null);
            }
            if (!m_Serialized)
            {
                m_DetailedViewType = (DetailedViewType)SessionState.GetInt(detailedViewTypeStatePrefKey, (int)DetailedViewType.None);
            }

            m_Serialized  = true;
            m_Initialized = true;
        }
Beispiel #14
0
        private void AnimationTimerTick(object sender, EventArgs e)
        {
            switch (_currentState)
            {
            case SplitterState.Collapsing:

                if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                {
                    // vertical splitter
                    if (_controlToHide.Width > _animationStep)
                    {
                        if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                            _parentForm != null)
                        {
                            _parentForm.Width -= _animationStep;
                        }
                        _controlToHide.Width -= _animationStep;
                    }
                    else
                    {
                        if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                            _parentForm != null)
                        {
                            _parentForm.Width = _parentFormWidth;
                        }
                        _controlToHide.Visible  = false;
                        _animationTimer.Enabled = false;
                        _controlToHide.Width    = _controlWidth;
                        _currentState           = SplitterState.Collapsed;
                        Invalidate();
                    }
                }
                else
                // horizontal splitter
                if (_controlToHide.Height > _animationStep)
                {
                    if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                        _parentForm != null)
                    {
                        _parentForm.Height -= _animationStep;
                    }
                    _controlToHide.Height -= _animationStep;
                }
                else
                {
                    if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                        _parentForm != null)
                    {
                        _parentForm.Height = _parentFormHeight;
                    }
                    _controlToHide.Visible  = false;
                    _animationTimer.Enabled = false;
                    _controlToHide.Height   = _controlHeight;
                    _currentState           = SplitterState.Collapsed;
                    Invalidate();
                }
                break;

            case SplitterState.Expanding:

                if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                {
                    // vertical splitter
                    if (_controlToHide.Width < (_controlWidth - _animationStep))
                    {
                        if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                            _parentForm != null)
                        {
                            _parentForm.Width += _animationStep;
                        }
                        _controlToHide.Width += _animationStep;
                    }
                    else
                    {
                        if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                            _parentForm != null)
                        {
                            _parentForm.Width = _parentFormWidth;
                        }
                        _controlToHide.Width    = _controlWidth;
                        _controlToHide.Visible  = true;
                        _animationTimer.Enabled = false;
                        _currentState           = SplitterState.Expanded;
                        Invalidate();
                    }
                }
                else
                // horizontal splitter
                if (_controlToHide.Height < (_controlHeight - _animationStep))
                {
                    if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                        _parentForm != null)
                    {
                        _parentForm.Height += _animationStep;
                    }
                    _controlToHide.Height += _animationStep;
                }
                else
                {
                    if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized &&
                        _parentForm != null)
                    {
                        _parentForm.Height = _parentFormHeight;
                    }
                    _controlToHide.Height   = _controlHeight;
                    _controlToHide.Visible  = true;
                    _animationTimer.Enabled = false;
                    _currentState           = SplitterState.Expanded;
                    Invalidate();
                }
                break;
            }
        }
Beispiel #15
0
		private void ToggleSplitter()
		{
			// if an animation is currently in progress for this control, drop out
			if (_currentState == SplitterState.Collapsing || _currentState == SplitterState.Expanding)
				return;

			_controlWidth = _controlToHide.Width;
			_controlHeight = _controlToHide.Height;

			if (_controlToHide.Visible)
				if (_useAnimations)
				{
					_currentState = SplitterState.Collapsing;

					if (_parentForm != null)
						if (Dock == DockStyle.Left || Dock == DockStyle.Right)
							_parentFormWidth = _parentForm.Width - _controlWidth;
						else
							_parentFormHeight = _parentForm.Height - _controlHeight;

					_animationTimer.Enabled = true;
				}
				else
				{
					// no animations, so just toggle the visible state
					_currentState = SplitterState.Collapsed;
					_controlToHide.Visible = false;
					if (_expandParentForm && _parentForm != null)
						if (Dock == DockStyle.Left || Dock == DockStyle.Right)
							_parentForm.Width -= _controlToHide.Width;
						else
							_parentForm.Height -= _controlToHide.Height;
				}
			else
				// control to hide is collapsed
				if (_useAnimations)
				{
					_currentState = SplitterState.Expanding;

					if (Dock == DockStyle.Left || Dock == DockStyle.Right)
					{
						if (_parentForm != null)
							_parentFormWidth = _parentForm.Width + _controlWidth;
						_controlToHide.Width = 0;
					}
					else
					{
						if (_parentForm != null)
							_parentFormHeight = _parentForm.Height + _controlHeight;
						_controlToHide.Height = 0;
					}
					_controlToHide.Visible = true;
					_animationTimer.Enabled = true;
				}
				else
				{
					// no animations, so just toggle the visible state
					_currentState = SplitterState.Expanded;
					_controlToHide.Visible = true;
					if (_expandParentForm && _parentForm != null)
						if (Dock == DockStyle.Left || Dock == DockStyle.Right)
							_parentForm.Width += _controlToHide.Width;
						else
							_parentForm.Height += _controlToHide.Height;
				}
		}
        void UpdateState(SplitterState state)
        {
            if(!_isInitialized)
            {
                return;
            }

            switch(state)
            {
                case SplitterState.Collapsed:
                    if(!_isDragStart)
                    {
                        _previousWidth = _collapsibleColumn.ActualWidth > SplitterCollapsedSize ? _collapsibleColumn.ActualWidth : SplitterExpandedSize;
                        _collapsibleColumn.Width = new GridLength(SplitterCollapsedSize, GridUnitType.Pixel);
                    }
                    _contentLeftFadeOut.Begin(_layoutRoot);
                    break;

                case SplitterState.Expanded:
                    if(!_isDragStart)
                    {
                        _collapsibleColumn.Width = new GridLength(_previousWidth, GridUnitType.Pixel);
                    }
                    _contentLeftFadeIn.Begin(_layoutRoot);
                    break;
            }
        }
Beispiel #17
0
		private void AnimationTimerTick(object sender, EventArgs e)
		{
			switch (_currentState)
			{
				case SplitterState.Collapsing:

					if (Dock == DockStyle.Left || Dock == DockStyle.Right)
						// vertical splitter
						if (_controlToHide.Width > _animationStep)
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Width -= _animationStep;
							_controlToHide.Width -= _animationStep;
						}
						else
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Width = _parentFormWidth;
							_controlToHide.Visible = false;
							_animationTimer.Enabled = false;
							_controlToHide.Width = _controlWidth;
							_currentState = SplitterState.Collapsed;
							Invalidate();
						}
					else
						// horizontal splitter
						if (_controlToHide.Height > _animationStep)
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Height -= _animationStep;
							_controlToHide.Height -= _animationStep;
						}
						else
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Height = _parentFormHeight;
							_controlToHide.Visible = false;
							_animationTimer.Enabled = false;
							_controlToHide.Height = _controlHeight;
							_currentState = SplitterState.Collapsed;
							Invalidate();
						}
					break;

				case SplitterState.Expanding:

					if (Dock == DockStyle.Left || Dock == DockStyle.Right)
						// vertical splitter
						if (_controlToHide.Width < (_controlWidth - _animationStep))
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Width += _animationStep;
							_controlToHide.Width += _animationStep;
						}
						else
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Width = _parentFormWidth;
							_controlToHide.Width = _controlWidth;
							_controlToHide.Visible = true;
							_animationTimer.Enabled = false;
							_currentState = SplitterState.Expanded;
							Invalidate();
						}
					else
						// horizontal splitter
						if (_controlToHide.Height < (_controlHeight - _animationStep))
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Height += _animationStep;
							_controlToHide.Height += _animationStep;
						}
						else
						{
							if (_expandParentForm && _parentForm.WindowState != FormWindowState.Maximized
								&& _parentForm != null)
								_parentForm.Height = _parentFormHeight;
							_controlToHide.Height = _controlHeight;
							_controlToHide.Visible = true;
							_animationTimer.Enabled = false;
							_currentState = SplitterState.Expanded;
							Invalidate();
						}
					break;
			}
		}
Beispiel #18
0
 private void InitIfNeeded()
 {
     if (!this.m_Initialized)
     {
         ProfilerColumn[] array = new ProfilerColumn[]
         {
             ProfilerColumn.FunctionName,
             ProfilerColumn.TotalPercent,
             ProfilerColumn.SelfPercent,
             ProfilerColumn.Calls,
             ProfilerColumn.GCMemory,
             ProfilerColumn.TotalTime,
             ProfilerColumn.SelfTime,
             ProfilerColumn.WarningCount
         };
         ProfilerColumn[] array2 = new ProfilerColumn[]
         {
             ProfilerColumn.FunctionName,
             ProfilerColumn.TotalGPUPercent,
             ProfilerColumn.DrawCalls,
             ProfilerColumn.TotalGPUTime
         };
         ProfilerColumn[] profilerColumns   = (!base.gpuView) ? array : array2;
         ProfilerColumn   defaultSortColumn = (!base.gpuView) ? ProfilerColumn.TotalTime : ProfilerColumn.TotalGPUTime;
         ProfilerFrameDataMultiColumnHeader.Column[] columns = ProfilerFrameDataHierarchyView.CreateColumns(profilerColumns);
         MultiColumnHeaderState multiColumnHeaderState       = ProfilerFrameDataHierarchyView.CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);
         if (MultiColumnHeaderState.CanOverwriteSerializedFields(this.m_MultiColumnHeaderState, multiColumnHeaderState))
         {
             MultiColumnHeaderState.OverwriteSerializedFields(this.m_MultiColumnHeaderState, multiColumnHeaderState);
         }
         bool flag = this.m_MultiColumnHeaderState == null;
         this.m_MultiColumnHeaderState = multiColumnHeaderState;
         ProfilerFrameDataMultiColumnHeader profilerFrameDataMultiColumnHeader = new ProfilerFrameDataMultiColumnHeader(this.m_MultiColumnHeaderState, columns)
         {
             height = 25f
         };
         if (flag)
         {
             profilerFrameDataMultiColumnHeader.ResizeToFit();
         }
         if (this.m_TreeViewState == null)
         {
             this.m_TreeViewState = new TreeViewState();
         }
         this.m_TreeView = new ProfilerFrameDataTreeView(this.m_TreeViewState, profilerFrameDataMultiColumnHeader);
         this.m_TreeView.selectionChanged += new ProfilerFrameDataTreeView.SelectionChangedCallback(this.OnMainTreeViewSelectionChanged);
         this.m_TreeView.searchChanged    += new ProfilerFrameDataTreeView.SearchChangedCallback(this.OnMainTreeViewSearchChanged);
         this.m_SearchField = new SearchField();
         this.m_SearchField.downOrUpArrowKeyPressed += new SearchField.SearchFieldCallback(this.m_TreeView.SetFocusAndEnsureSelectedItem);
         if (this.m_DetailedObjectsView == null)
         {
             this.m_DetailedObjectsView = new ProfilerDetailedObjectsView();
         }
         this.m_DetailedObjectsView.gpuView         = base.gpuView;
         this.m_DetailedObjectsView.frameItemEvent += new ProfilerDetailedObjectsView.FrameItemCallback(this.FrameItem);
         if (this.m_DetailedCallsView == null)
         {
             this.m_DetailedCallsView = new ProfilerDetailedCallsView();
         }
         this.m_DetailedCallsView.frameItemEvent += new ProfilerDetailedCallsView.FrameItemCallback(this.FrameItem);
         if (this.m_DetailedViewSpliterState == null || this.m_DetailedViewSpliterState.relativeSizes == null || this.m_DetailedViewSpliterState.relativeSizes.Length == 0)
         {
             this.m_DetailedViewSpliterState = new SplitterState(new float[]
             {
                 70f,
                 30f
             }, new int[]
             {
                 450,
                 50
             }, null);
         }
         this.m_Initialized = true;
     }
 }