Example #1
0
        /// <summary>
        /// Gets the height of the item.
        /// </summary>
        /// <returns>The item height.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemHeight(TItem item)
        {
            if (defaultItemlayoutGroup == null)
            {
                defaultItemlayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float height = 0f;

            if ((!IsCanCalculateHeight || ForceAutoHeightCalculation) && (defaultItemlayoutGroup != null))
            {
                DefaultItemCopy.gameObject.SetActive(true);

                SetData(DefaultItemCopy, item);

                defaultItemlayoutGroup.CalculateLayoutInputHorizontal();
                defaultItemlayoutGroup.SetLayoutHorizontal();
                defaultItemlayoutGroup.CalculateLayoutInputVertical();
                defaultItemlayoutGroup.SetLayoutVertical();

                height = LayoutUtility.GetPreferredHeight(DefaultItemCopyRect);

                DefaultItemCopy.gameObject.SetActive(false);
            }
            else
            {
                SetData(DefaultItemCopy, item);

                height = (DefaultItemCopy as IListViewItemHeight).Height;
            }

            return(height);
        }
Example #2
0
        /// <summary>
        /// Gets the height of the item.
        /// </summary>
        /// <returns>The item height.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemHeight(TItem item)
        {
            if (defaultItemLayoutGroup == null)
            {
                DefaultItemCopy.gameObject.SetActive(true);

                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float height = 0f;

            if (!IsCanCalculateHeight || ForceAutoHeightCalculation)
            {
                if (defaultItemLayoutGroup != null)
                {
                    SetData(DefaultItemCopy, item);

                    var lg = DefaultItemCopy.GetComponentsInChildren <LayoutGroup>();
                    Array.Reverse(lg);
                    lg.ForEach(LayoutUtilites.UpdateLayout);

                    LayoutUtilites.UpdateLayout(defaultItemLayoutGroup);

                    height = LayoutUtility.GetPreferredHeight(DefaultItemCopyRect);
                }
            }
            else
            {
                SetData(DefaultItemCopy, item);

                height = (DefaultItemCopy as IListViewItemHeight).Height;
            }

            return(height);
        }
        /// <summary>
        /// Gets the height of the item.
        /// </summary>
        /// <returns>The item height.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemHeight(TItem item)
        {
            if (defaultItemLayoutGroup == null)
            {
                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float height = 0f;

            if (!IsCanCalculateHeight || ForceAutoHeightCalculation)
            {
                if (defaultItemLayoutGroup != null)
                {
                    DefaultItemCopy.gameObject.SetActive(true);

                    SetData(DefaultItemCopy, item);

                    Utilites.UpdateLayout(defaultItemLayoutGroup);

                    height = LayoutUtility.GetPreferredHeight(DefaultItemCopyRect);

                    DefaultItemCopy.gameObject.SetActive(false);
                }
            }
            else
            {
                SetData(DefaultItemCopy, item);

                height = (DefaultItemCopy as IListViewItemHeight).Height;
            }

            return(height);
        }
Example #4
0
        /// <summary>
        /// Calculate and sets the height of the items.
        /// </summary>
        /// <param name="items">Items.</param>
        /// <param name="forceUpdate">If set to <c>true</c> force update.</param>
        void CalculateItemsSizes(ObservableList <TItem> items, bool forceUpdate = true)
        {
            // remove old items
            ItemSizes.Keys.Except(items).ToArray().ForEach(x => ItemSizes.Remove(x));

            if (defaultItemLayoutGroup == null)
            {
                DefaultItemCopy.gameObject.SetActive(true);

                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            if (forceUpdate)
            {
                DefaultItemCopy.gameObject.SetActive(true);

                items.ForEach(x => {
                    ItemSizes[x] = CalculateComponentSize(x);
                });

                DefaultItemCopy.gameObject.SetActive(false);
            }
            else
            {
                items.Except(ItemSizes.Keys).ForEach(x => {
                    ItemSizes[x] = CalculateComponentSize(x);
                });
            }
        }
Example #5
0
        /// <summary>
        /// Calculate and sets the height of the items.
        /// </summary>
        /// <param name="items">Items.</param>
        /// <param name="forceUpdate">If set to <c>true</c> force update.</param>
        void SetItemsHeight(ObservableList <TItem> items, bool forceUpdate = true)
        {
            if (defaultItemLayoutGroup == null)
            {
                DefaultItemCopy.gameObject.SetActive(true);

                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            DefaultItemCopy.gameObject.SetActive(true);

            items.ForEach(x => {
                if ((x.Height == 0) || forceUpdate)
                {
                    x.Height = CalculateItemHeight(x);
                }
            });

            DefaultItemCopy.gameObject.SetActive(false);
        }
Example #6
0
        /// <summary>
        /// Gets the height of the item.
        /// </summary>
        /// <returns>The item height.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemHeight(string item)
        {
            if (defaultItemLayoutGroup == null)
            {
                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float height = 0f;

            if (defaultItemLayoutGroup != null)
            {
                DefaultItemCopy.gameObject.SetActive(true);

                DefaultItemCopy.SetData(item);
                LayoutUtilites.UpdateLayout(defaultItemLayoutGroup);

                height = LayoutUtility.GetPreferredHeight(DefaultItemCopyRect);

                DefaultItemCopy.gameObject.SetActive(false);
            }

            return(height);
        }
Example #7
0
        /// <summary>
        /// Gets the width of the item.
        /// </summary>
        /// <returns>The item width.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemWidth(TItem item)
        {
            if (defaultItemLayoutGroup == null)
            {
                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float width = 0f;

            if (!IsCanCalculateWidth || ForceAutoWidthCalculation)
            {
                if (defaultItemLayoutGroup != null)
                {
                    DefaultItemCopy.gameObject.SetActive(true);

                    SetData(DefaultItemCopy, item);

                    var lg = DefaultItemCopy.GetComponentsInChildren <LayoutGroup>();
                    Array.Reverse(lg);
                    lg.ForEach(LayoutUtilites.UpdateLayout);

                    LayoutUtilites.UpdateLayout(defaultItemLayoutGroup);

                    width = LayoutUtility.GetPreferredWidth(DefaultItemCopyRect);

                    DefaultItemCopy.gameObject.SetActive(false);
                }
            }
            else
            {
                SetData(DefaultItemCopy, item);

                width = (DefaultItemCopy as IListViewItemWidth).Width;
            }

            return(width);
        }