void OperationsRemoved(Progress.Item[] items) { using (new EditorPerformanceTracker("ProgressWindow.OperationsRemoved")) { foreach (var item in items) { RemoveTreeViewItem(item.id); } m_TreeView.Rebuild(); UpdateDismissAllButton(); } }
void OnEnable() { s_Window = this; titleContent = EditorGUIUtility.TrTextContent("Background Tasks"); rootVisualElement.AddStyleSheetPath(ussPath); if (EditorGUIUtility.isProSkin) { rootVisualElement.AddStyleSheetPath(ussPathDark); } else { rootVisualElement.AddStyleSheetPath(ussPathLight); } var toolbar = new UIElements.Toolbar(); m_DismissAllBtn = new ToolbarButton(ClearInactive) { name = "DismissAllBtn", text = L10n.Tr("Clear inactive"), }; toolbar.Add(m_DismissAllBtn); // This is our friend the spacer toolbar.Add(new VisualElement() { style = { flexGrow = 1 } }); rootVisualElement.Add(toolbar); s_VisualProgressItemTask = EditorGUIUtility.Load(k_UxmlProgressItemPath) as VisualTreeAsset; m_TreeView = new TreeView(); m_TreeView.makeItem = MakeTreeViewItem; m_TreeView.bindItem = BindTreeViewItem; m_TreeView.unbindItem = UnbindTreeViewItem; m_TreeView.destroyItem = DestroyTreeViewItem; m_TreeView.fixedItemHeight = 50; m_TreeView.SetRootItems(new TreeViewItemData <Progress.Item>[] {}); var scrollView = m_TreeView.Q <ScrollView>(); if (scrollView != null) { scrollView.horizontalScrollerVisibility = ScrollerVisibility.Hidden; } rootVisualElement.Add(m_TreeView); m_TreeView.Rebuild(); // Update the treeview with the existing items m_MissingParents = new Dictionary <int, List <int> >(); m_ContainedItems = new HashSet <int>(); m_ItemsNeedingExpansion = new HashSet <int>(); OperationsAdded(Progress.EnumerateItems().ToArray()); Progress.added += OperationsAdded; Progress.removed += OperationsRemoved; Progress.updated += OperationsUpdated; UpdateDismissAllButton(); }