Ejemplo n.º 1
0
        /// <summary>
        /// Update item size.
        /// </summary>
        /// <param name="item">Item.</param>
        protected static void UpdateItemSize(AccordionItem item)
        {
            LayoutUtilites.UpdateLayoutsRecursive(item.ContentObjectRect.transform);

            item.ContentObjectWidth = LayoutUtilites.IsWidthControlled(item.ContentObjectRect)
                                ? LayoutUtility.GetPreferredWidth(item.ContentObjectRect)
                                : item.ContentObjectRect.rect.width;

            item.ContentObjectHeight = LayoutUtilites.IsHeightControlled(item.ContentObjectRect)
                                ? LayoutUtility.GetPreferredHeight(item.ContentObjectRect)
                                : item.ContentObjectRect.rect.height;
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Calculates the size of the component for the specified item.
            /// </summary>
            /// <returns>The component size.</returns>
            /// <param name="item">Item.</param>
            protected virtual Vector2 CalculateComponentSize(TItem item)
            {
                if (Owner.DefaultItemLayout == null)
                {
                    return(Owner.ItemSize);
                }

                Owner.SetData(Owner.DefaultItemCopy, item);

                LayoutUtilites.UpdateLayoutsRecursive(Owner.Container);

                return(Owner.DefaultItemCopyRect.rect.size);
            }
        /// <summary>
        /// Update the DisplayedIndices.
        /// </summary>
        /// <param name="newIndices">New indices.</param>
        /// <param name="action">Action.</param>
        public void DisplayedIndicesUpdate(List <int> newIndices, Action <TComponent> action)
        {
            if (IndicesEqual(newIndices))
            {
                return;
            }

            FindIndicesDiff(newIndices);

            if (IndicesRemoved.Count > 0)
            {
                for (int i = Components.Count - 1; i >= 0; i--)
                {
                    var component = Components[i];
                    if (IndicesRemoved.Contains(component.Index))
                    {
                        DeactivateComponent(component);
                        Components.RemoveAt(i);
                        ComponentsCache.Add(component);
                    }
                }
            }

            for (int i = 0; i < IndicesAdded.Count; i++)
            {
                var component = CreateComponent();
                Components.Add(component);
            }

            Owner.Items = Components.Convert(x => x as ListViewItem);

            var start = Components.Count - IndicesAdded.Count;

            for (int i = 0; i < IndicesAdded.Count; i++)
            {
                var component = Components[start + i];
                component.Index = IndicesAdded[i];
                action(component);
            }

            DisplayedIndices.Clear();
            DisplayedIndices.AddRange(newIndices);

            Components.Sort(ComponentsComparer);
            Components.ForEach(SetComponentAsLastSibling);

            LayoutUtilites.UpdateLayoutsRecursive(Owner.Container);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Set the DisplayedIndices.
        /// </summary>
        /// <param name="newIndices">New indices.</param>
        /// <param name="action">Action.</param>
        public void DisplayedIndicesSet(List <int> newIndices, Action <TComponent> action)
        {
            SetCount(newIndices.Count);

            Components.ForEach((x, i) =>
            {
                x.Index = newIndices[i];
                action(x);
                LayoutUtilites.UpdateLayoutsRecursive(x);
            });

            DisplayedIndices.Clear();
            DisplayedIndices.AddRange(newIndices);

            Components.Sort(ComponentsComparer);
            Components.ForEach(SetComponentAsLastSibling);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get component size.
        /// </summary>
        /// <param name="defaultItemComponent">Default item component.</param>
        /// <returns>Component size.</returns>
        protected virtual Vector2 GetComponentSize(TComponent defaultItemComponent)
        {
            LayoutUtilites.UpdateLayoutsRecursive(defaultItemComponent);

            return((defaultItemComponent.transform as RectTransform).rect.size);
        }