void OnMainTreeViewSelectionChanged(ProfilerTimeSampleSelection selection)
 {
     if (selectionChanged != null)
     {
         selectionChanged.Invoke(selection);
     }
 }
 public void SetSelection(ProfilerTimeSampleSelection selection, bool expandSelection)
 {
     m_Selected = selection;
     m_LocalSelectedItemMarkerIdPath.Clear();
     m_LocalSelectedItemMarkerIdPath.AddRange(selection.markerIdPath);
     m_ExpandDuringNextSelectionMigration = expandSelection;
     m_SelectionNeedsMigration            = true;
     proxySelectionInfo = default;
 }
 // setClearedSelection = false is only supposed to be used when a selection change was reported by the Tree View via SelectionChanged
 // if SetSelection(new List<int>()) would be triggered during SelectionChanged, the TreeViews selection state would get corrupted before it is even fully set.
 void ClearSelection(bool setClearedSelection)
 {
     m_Selected = null;
     m_LocalSelectedItemMarkerIdPath.Clear();
     m_ExpandDuringNextSelectionMigration = false;
     m_SelectionNeedsMigration            = false;
     proxySelectionInfo = default;
     if (setClearedSelection)
     {
         SetSelection(new List <int>());
     }
 }
        protected override void SelectionChanged(IList <int> selectedIds)
        {
            ProfilerTimeSampleSelection selection;

            // When we navigate through frames and there is no path exists,
            // we still want to be able to frame and select proper sample once it is present again.
            // Thus we invalidate selection only if user selected new item.
            // Same applies to expanded state.
            if (selectedIds.Count > 0)
            {
                ClearSelection(setClearedSelection: false);
            }

            if (selectedIds.Count > 0 && m_FrameDataView.valid)
            {
                List <int> rawIds = new List <int>();
                if (selectedIds.Count > 1)
                {
                    List <int> ids = new List <int>();
                    for (int i = 0; i < selectedIds.Count; i++)
                    {
                        m_FrameDataView.GetItemRawFrameDataViewIndices(selectedIds[i], ids);
                    }
                }
                else
                {
                    m_FrameDataView.GetItemRawFrameDataViewIndices(selectedIds[0], rawIds);
                }
                selection = new ProfilerTimeSampleSelection(m_FrameDataView.frameIndex, m_FrameDataView.threadGroupName, m_FrameDataView.threadName, m_FrameDataView.threadId, rawIds, m_ProfilerSampleNameProvider.GetItemName(m_FrameDataView, selectedIds[0]));
                var selectedId       = selectedIds[0];
                var rawSampleIndices = new List <int>(m_FrameDataView.GetItemMergedSamplesCount(selectedId));
                m_FrameDataView.GetItemRawFrameDataViewIndices(selectedId, rawSampleIndices);
                var markerIDs = new List <int>(m_FrameDataView.GetItemDepth(selectedId));
                using (var iterator = new RawFrameDataView(m_FrameDataView.frameIndex, m_FrameDataView.threadIndex))
                {
                    string name = null;
                    ProfilerTimelineGUI.GetItemMarkerIdPath(iterator, m_ProfilerSampleNameProvider, rawSampleIndices[0], ref name, ref markerIDs);
                }
                selection.GenerateMarkerNamePath(m_FrameDataView, markerIDs);
            }
            else
            {
                selection = null;
            }

            var id = selectedIds.Count > 0 ? selectedIds[0] : RawFrameDataView.invalidSampleIndex;

            if (selectionChanged != null)
            {
                selectionChanged.Invoke(selection);
            }
        }
 public void SetSelection(ProfilerTimeSampleSelection selection, bool expandSelection)
 {
     if (selection.markerIdPath == null)
     {
         throw new ArgumentNullException(nameof(selection.markerIdPath));
     }
     if (selection.markerNamePath == null)
     {
         throw new ArgumentNullException(nameof(selection.markerNamePath));
     }
     if (selection.markerIdPath.Count != selection.markerPathDepth)
     {
         throw new ArgumentException($"ProfilerFrameDataHierarchyView.SetSelectionFromMarkerIDPath needs to be called with {nameof(selection)} having {nameof(selection.markerIdPath)} and {nameof(selection.markerNamePath)} with the same amount of elements.");
     }
     InitIfNeeded();
     m_TreeView.SetSelection(selection, expandSelection);
 }
Esempio n. 6
0
 private void OnSelectionChangedInCpuProfilerModule(IProfilerFrameTimeViewSampleSelectionController controller, ProfilerTimeSampleSelection selection)
 {
     if (controller == m_CpuProfilerModule && !m_SendingSelectionEventToProfilerWindowInProgress)
     {
         if (selection != null && selection.markerNamePath != null && selection.markerNamePath.Count > 0)
         {
             selectedMarkerChanged(selection.markerNamePath[selection.markerNamePath.Count - 1], selection.threadGroupName, selection.threadName);
         }
     }
 }