static void CategoryTreeViewItemGUI( Rect rowRect, float rowHeight, ChangeCategoryTreeViewItem item, bool isSelected, bool isFocused) { Texture icon = GetCategoryIcon(item.Category); string label = item.Category.GetHeaderText(); bool wasChecked = item.Category.IsChecked(); bool hadCheckedChildren = item.Category.GetCheckedChangesCount() > 0; bool isChecked = DrawTreeViewItem.ForCheckableCategoryItem( rowRect, rowHeight, item.depth, icon, label, isSelected, isFocused, wasChecked, hadCheckedChildren); if (!wasChecked && isChecked) { item.Category.UpdateCheckedState(true); return; } if (wasChecked && !isChecked) { item.Category.UpdateCheckedState(false); return; } }
static void RegenerateRows( UnityPendingChangesTree pendingChangesTree, TreeViewItemIds <PendingChangeCategory, PendingChangeInfo> treeViewItemIds, PendingChangesTreeView treeView, TreeViewItem rootItem, List <TreeViewItem> rows, bool expandCategories) { ClearRows(rootItem, rows); List <PendingChangeCategory> categories = pendingChangesTree.GetNodes(); if (categories == null) { return; } foreach (PendingChangeCategory category in categories) { int categoryId; if (!treeViewItemIds.TryGetCategoryItemId(category, out categoryId)) { categoryId = treeViewItemIds.AddCategoryItem(category); } ChangeCategoryTreeViewItem categoryTreeViewItem = new ChangeCategoryTreeViewItem(categoryId, category); rootItem.AddChild(categoryTreeViewItem); rows.Add(categoryTreeViewItem); if (!expandCategories && !treeView.IsExpanded(categoryTreeViewItem.id)) { continue; } foreach (PendingChangeInfo change in category.GetCurrentChanges()) { int changeId; if (!treeViewItemIds.TryGetInfoItemId(change, out changeId)) { changeId = treeViewItemIds.AddInfoItem(change); } TreeViewItem changeTreeViewItem = new ChangeTreeViewItem(changeId, change); categoryTreeViewItem.AddChild(changeTreeViewItem); rows.Add(changeTreeViewItem); } } if (!expandCategories) { return; } treeView.state.expandedIDs = treeViewItemIds.GetCategoryIds(); }
static void CategoryTreeViewItemGUI( PendingChangesTreeView treeView, Rect rowRect, float rowHeight, ChangeCategoryTreeViewItem item, bool isSelected, bool isFocused) { Texture icon = GetCategoryIcon(item.Category); string label = item.Category.CategoryName; string secondaryLabel = item.Category.GetCheckedChangesText(); bool wasChecked = item.Category.IsChecked(); bool hadCheckedChildren = item.Category.GetCheckedChangesCount() > 0; bool isChecked = DrawTreeViewItem.ForCheckableCategoryItem( rowRect, rowHeight, item.depth, icon, label, secondaryLabel, isSelected, isFocused, wasChecked, hadCheckedChildren); if (wasChecked != isChecked) { item.Category.UpdateCheckedState(isChecked); treeView.SelectionChanged(); } }