void UpdateHeaderViews(IHierarchyNodeViewsHolder header, IHierarchyNodeModel model) { int prevDepth = model.Depth; if (_HeaderFixedPadding) { model.Depth = 1; } header.UpdateViews(model); if (_HeaderFixedPadding) { model.Depth = prevDepth; } }
bool ToggleDirectoryFoldoutInternal(int itemIndex, IHierarchyNodeViewsHolder vhIfVisible) { if (_BusyWithAnimation) { return(false); } var model = _Params.FlattenedVisibleHierarchy[itemIndex]; if (!model.IsDirectory()) { return(false); } int nextIndex = itemIndex + 1; bool wasExpanded = model.Expanded; model.Expanded = !wasExpanded; if (wasExpanded) { // Remove all following models with bigger depth, until a model with a less than- or equal depth is found int i = itemIndex + 1; int count = _Params.FlattenedVisibleHierarchy.Count; for (; i < count;) { var m = _Params.FlattenedVisibleHierarchy[i]; if (m.Depth > model.Depth) { m.Expanded = false; ++i; continue; } break; // found with depth less than- or equal to the collapsed item } int countToRemove = i - nextIndex; if (countToRemove > 0) { if (_Params.animatedFoldOut) { GradualRemove(nextIndex, countToRemove); } else { _Params.FlattenedVisibleHierarchy.RemoveRange(nextIndex, countToRemove); RemoveItems(nextIndex, countToRemove); } } } else { if (model.Children.Length > 0) { if (_Params.animatedFoldOut) { GradualAdd(nextIndex, model.Children); } else { _Params.FlattenedVisibleHierarchy.InsertRange(nextIndex, model.Children); InsertItems(nextIndex, model.Children.Length); } } } // Starting with v4.0, only the newly visible items are updated to keep performance at max, // so we need to update the directory viewsholder manually (most notably, its arrow will change) //Debug.Log(model.expanded + ", " + vhIfVisible); if (vhIfVisible != null) { vhIfVisible.UpdateViews(model); } return(true); }