Ejemplo n.º 1
0
 void OnDirectoryFoldOutClicked(IHierarchyNodeViewsHolder vh)
 {
     if (!ToggleDirectoryFoldoutInternal(vh.ItemIndex, vh))
     {
         return;
     }
 }
Ejemplo n.º 2
0
        void SetHeaderInset(IHierarchyNodeViewsHolder header, float inset)
        {
            var layoutInfo = _HierarchyOSA.GetLayoutInfoReadonly();

            // Positioning a views holder. Taken from OSA.AddViewsHolderAndMakeVisible() method in OSAInternal.cs (15-Feb-19, 16:33)
            var asAbstractVH = (header as AbstractViewsHolder);

            asAbstractVH.root.SetInsetAndSizeFromParentEdgeWithCurrentAnchors(layoutInfo.startEdge, inset, _HierarchyOSA.BaseParameters.DefaultItemSize);

            if (layoutInfo.transversalPaddingContentStart == -1d)
            {
                throw new OSAException("transversalPaddingContentStart is not allowed to be -1 when using " + typeof(OSAHierarchyStickyHeader).Name);
            }

            asAbstractVH.root.SetInsetAndSizeFromParentEdgeWithCurrentAnchors(layoutInfo.transvStartEdge, (float)layoutInfo.transversalPaddingContentStart, (float)layoutInfo.itemsConstantTransversalSize);
        }
Ejemplo n.º 3
0
        void UpdateHeaderViews(IHierarchyNodeViewsHolder header, IHierarchyNodeModel model)
        {
            int prevDepth = model.Depth;

            if (_HeaderFixedPadding)
            {
                model.Depth = 1;
            }

            header.UpdateViews(model);

            if (_HeaderFixedPadding)
            {
                model.Depth = prevDepth;
            }
        }
Ejemplo n.º 4
0
        void OnHeaderFoldOutClicked(IHierarchyNodeViewsHolder headerVH)
        {
            if (_CurrentHeaderDirModel == null)
            {
                throw new OSAException("Model null");
            }

            var list  = _Params.FlattenedVisibleHierarchy;
            int index = list.IndexOf(_CurrentHeaderDirModel);

            if (index == -1)
            {
                throw new OSAException("Model not found: " + _CurrentHeaderDirModel.Depth + ", " + (_CurrentHeaderDirModel.Children == null ? "null children" : _CurrentHeaderDirModel.Children.Length + " children"));
            }

            _HierarchyOSA.ToggleDirectoryFoldout(index);
            UpdateHeaderViews(headerVH, _CurrentHeaderDirModel);
        }
Ejemplo n.º 5
0
        void ManageHeader(IHierarchyNodeViewsHolder header, IHierarchyNodeViewsHolder firstVH, IHierarchyNodeViewsHolder secondVH)
        {
            var firstAsAbstractVH           = firstVH as AbstractViewsHolder;
            int itemIndex                   = firstVH.ItemIndex;
            var firstVisibleItemModel       = _Params.FlattenedVisibleHierarchy[itemIndex];
            var parentDirOfFirstVisibleItem = firstVisibleItemModel.Parent;

            if (firstVisibleItemModel.IsDirectory() && firstVisibleItemModel.Expanded)
            {
                if (_CurrentHeaderDirModel == null || _CurrentHeaderDirModel != firstVisibleItemModel)
                {
                    _CurrentHeaderDirModel = firstVisibleItemModel;
                    UpdateHeaderViews(header, _CurrentHeaderDirModel);
                }

                float amountBeforeViewport = -_HierarchyOSA.GetItemRealInsetFromParentStart(firstAsAbstractVH.root);
                //Debug.Log(amountBeforeViewport);
                bool beforeViewport = amountBeforeViewport > 0;
                if (beforeViewport)
                {
                    ActivateVH(header);
                    UpdateHeaderViews(header, _CurrentHeaderDirModel);
                    SetHeaderInset(header, 0f);
                }
                else
                {
                    DeactivateVH(header);
                }
            }
            else
            {
                //Debug.Log(firstVisibleItemModel.title + ", " + firstVisibleItemModel.IsDirectory + ", " + firstVisibleItemModel.depth + ", parent= " + (parentDirOfFirstVisibleItem == null ? "null" : parentDirOfFirstVisibleItem.title + ", d " + parentDirOfFirstVisibleItem.depth));
                if (parentDirOfFirstVisibleItem == null || parentDirOfFirstVisibleItem.Depth == 0)
                {
                    DeactivateVH(header);
                    return;
                }

                ActivateVH(header);

                if (_CurrentHeaderDirModel != parentDirOfFirstVisibleItem)
                {
                    _CurrentHeaderDirModel = parentDirOfFirstVisibleItem;
                    UpdateHeaderViews(header, parentDirOfFirstVisibleItem);
                }

                SetHeaderInset(header, 0f);
            }

            var secondAsAbstractVH     = secondVH as AbstractViewsHolder;
            int secondItemIndex        = secondVH.ItemIndex;
            var secondVisibleItemModel = _Params.FlattenedVisibleHierarchy[secondItemIndex];

            if (secondVisibleItemModel.IsDirectory())
            {
                bool secondIsSameDepth = secondVisibleItemModel.Depth == _CurrentHeaderDirModel.Depth;

                if (!secondIsSameDepth)
                {
                    if (!secondVisibleItemModel.Expanded)
                    {
                        return;
                    }

                    if (secondVisibleItemModel.Parent != _CurrentHeaderDirModel)
                    {
                        bool secondIsSmallerDepth = secondVisibleItemModel.Depth < _CurrentHeaderDirModel.Depth;
                        if (!secondIsSmallerDepth)
                        {
                            return;
                        }
                    }
                }

                float secondItemInset = _HierarchyOSA.GetItemRealInsetFromParentStart(secondAsAbstractVH.root);
                if (secondItemInset < 0)                 // wait for positions to be fixed
                {
                    return;
                }

                var layoutInfo         = _HierarchyOSA.GetLayoutInfoReadonly();
                var headerAsAbstractVH = header as AbstractViewsHolder;
                var size      = headerAsAbstractVH.root.rect.size[layoutInfo.hor0_vert1];
                var insetMax0 = Mathf.Min(0f, (float)(secondItemInset /*- layoutInfo.spacing*/ - size));
                SetHeaderInset(header, insetMax0);
            }
        }
Ejemplo n.º 6
0
 void DeactivateVH(IHierarchyNodeViewsHolder header)
 {
     (header as AbstractViewsHolder).root.gameObject.SetActive(false);
 }
Ejemplo n.º 7
0
 void ActivateVH(IHierarchyNodeViewsHolder header)
 {
     (header as AbstractViewsHolder).root.gameObject.SetActive(true);
     _AtLeastOneActivated = true;
 }
Ejemplo n.º 8
0
        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);
        }