From bcc89455a725a5963cc170bc43dadc039ac72d4e Mon Sep 17 00:00:00 2001 From: Sinai Date: Sat, 17 Apr 2021 04:11:45 +1000 Subject: [PATCH] rename "InfiniteScrollRect" to "ScrollPool" --- src/UI/UIFactory.cs | 4 ++-- src/UI/Widgets/{InfiniteScroll => ScrollPool}/ICell.cs | 0 .../IPoolDataSource.cs} | 2 +- .../InfiniteScrollRect.cs => ScrollPool/ScrollPool.cs} | 10 +++++----- .../{InfiniteScroll => ScrollPool}/UIExtensions.cs | 2 ++ src/UI/Widgets/SimpleList/SimpleListSource.cs | 6 +++--- src/UI/Widgets/TransformTree/TransformTree.cs | 6 +++--- 7 files changed, 16 insertions(+), 14 deletions(-) rename src/UI/Widgets/{InfiniteScroll => ScrollPool}/ICell.cs (100%) rename src/UI/Widgets/{InfiniteScroll/IListDataSource.cs => ScrollPool/IPoolDataSource.cs} (88%) rename src/UI/Widgets/{InfiniteScroll/InfiniteScrollRect.cs => ScrollPool/ScrollPool.cs} (98%) rename src/UI/Widgets/{InfiniteScroll => ScrollPool}/UIExtensions.cs (94%) diff --git a/src/UI/UIFactory.cs b/src/UI/UIFactory.cs index 662464f..35484c1 100644 --- a/src/UI/UIFactory.cs +++ b/src/UI/UIFactory.cs @@ -692,7 +692,7 @@ namespace UnityExplorer.UI return dropdownObj; } - public static InfiniteScrollRect CreateInfiniteScroll(GameObject parent, string name, out GameObject uiRoot, + public static ScrollPool CreateInfiniteScroll(GameObject parent, string name, out GameObject uiRoot, out GameObject content, Color? bgColor = null, bool autoResizeSliderHandle = true) { var mainObj = CreateUIObject(name, parent, new Vector2(1, 1)); @@ -752,7 +752,7 @@ namespace UnityExplorer.UI uiRoot = mainObj; - var infiniteScroll = new InfiniteScrollRect(scrollRect); + var infiniteScroll = new ScrollPool(scrollRect); infiniteScroll.AutoResizeHandleRect = autoResizeSliderHandle; return infiniteScroll; diff --git a/src/UI/Widgets/InfiniteScroll/ICell.cs b/src/UI/Widgets/ScrollPool/ICell.cs similarity index 100% rename from src/UI/Widgets/InfiniteScroll/ICell.cs rename to src/UI/Widgets/ScrollPool/ICell.cs diff --git a/src/UI/Widgets/InfiniteScroll/IListDataSource.cs b/src/UI/Widgets/ScrollPool/IPoolDataSource.cs similarity index 88% rename from src/UI/Widgets/InfiniteScroll/IListDataSource.cs rename to src/UI/Widgets/ScrollPool/IPoolDataSource.cs index 33d2995..af41106 100644 --- a/src/UI/Widgets/InfiniteScroll/IListDataSource.cs +++ b/src/UI/Widgets/ScrollPool/IPoolDataSource.cs @@ -6,7 +6,7 @@ using UnityEngine; namespace UnityExplorer.UI.Widgets { - public interface IListDataSource + public interface IPoolDataSource { int ItemCount { get; } diff --git a/src/UI/Widgets/InfiniteScroll/InfiniteScrollRect.cs b/src/UI/Widgets/ScrollPool/ScrollPool.cs similarity index 98% rename from src/UI/Widgets/InfiniteScroll/InfiniteScrollRect.cs rename to src/UI/Widgets/ScrollPool/ScrollPool.cs index e071bba..cf0f2f7 100644 --- a/src/UI/Widgets/InfiniteScroll/InfiniteScrollRect.cs +++ b/src/UI/Widgets/ScrollPool/ScrollPool.cs @@ -9,15 +9,15 @@ using UnityExplorer.UI.Models; namespace UnityExplorer.UI.Widgets { - public class InfiniteScrollRect : UIBehaviourModel + public class ScrollPool : UIBehaviourModel { - public InfiniteScrollRect(ScrollRect scrollRect) + public ScrollPool(ScrollRect scrollRect) { this.scrollRect = scrollRect; Init(); } - public IListDataSource DataSource; + public IPoolDataSource DataSource; public int PoolCount => _cachedCells.Count; @@ -186,7 +186,7 @@ namespace UnityExplorer.UI.Widgets /// Initialize with the provided DataSource /// /// - public void Initialize(IListDataSource dataSource) + public void Initialize(IPoolDataSource dataSource) { DataSource = dataSource; @@ -207,7 +207,7 @@ namespace UnityExplorer.UI.Widgets ReloadData(DataSource); } - public void ReloadData(IListDataSource dataSource) + public void ReloadData(IPoolDataSource dataSource) { if (scrollRect.onValueChanged == null) return; diff --git a/src/UI/Widgets/InfiniteScroll/UIExtensions.cs b/src/UI/Widgets/ScrollPool/UIExtensions.cs similarity index 94% rename from src/UI/Widgets/InfiniteScroll/UIExtensions.cs rename to src/UI/Widgets/ScrollPool/UIExtensions.cs index d26b917..4b97962 100644 --- a/src/UI/Widgets/InfiniteScroll/UIExtensions.cs +++ b/src/UI/Widgets/ScrollPool/UIExtensions.cs @@ -18,6 +18,8 @@ namespace UnityExplorer.UI.Widgets corners[3] = bottomLeft + new Vector3(rect.rect.width, 0, 0); } + // again, using position and rect instead of + public static float MaxY(this RectTransform rect) => rect.position.y - rect.rect.height; public static float MinY(this RectTransform rect) => rect.position.y; diff --git a/src/UI/Widgets/SimpleList/SimpleListSource.cs b/src/UI/Widgets/SimpleList/SimpleListSource.cs index 212783c..9b3b811 100644 --- a/src/UI/Widgets/SimpleList/SimpleListSource.cs +++ b/src/UI/Widgets/SimpleList/SimpleListSource.cs @@ -8,9 +8,9 @@ using UnityExplorer.UI.Widgets; namespace UnityExplorer.UI.Widgets { - public class SimpleListSource : IListDataSource + public class SimpleListSource : IPoolDataSource { - internal InfiniteScrollRect Scroller; + internal ScrollPool Scroller; public Func> GetEntries; public List currentEntries; @@ -29,7 +29,7 @@ namespace UnityExplorer.UI.Widgets } private string currentFilter; - public SimpleListSource(InfiniteScrollRect infiniteScroller, Func> getEntriesMethod, + public SimpleListSource(ScrollPool infiniteScroller, Func> getEntriesMethod, Func> createCellMethod, Action, int> setICellMethod, Func shouldFilterMethod) { diff --git a/src/UI/Widgets/TransformTree/TransformTree.cs b/src/UI/Widgets/TransformTree/TransformTree.cs index e8242ba..9703058 100644 --- a/src/UI/Widgets/TransformTree/TransformTree.cs +++ b/src/UI/Widgets/TransformTree/TransformTree.cs @@ -9,7 +9,7 @@ using UnityExplorer.UI.Widgets; namespace UnityExplorer.UI.Widgets { - public class TransformTree : IListDataSource + public class TransformTree : IPoolDataSource { public Func> GetRootEntriesMethod; @@ -33,7 +33,7 @@ namespace UnityExplorer.UI.Widgets } private string currentFilter; - internal InfiniteScrollRect Scroller; + internal ScrollPool Scroller; internal readonly List displayedObjects = new List(); @@ -44,7 +44,7 @@ namespace UnityExplorer.UI.Widgets public int ItemCount => displayedObjects.Count; - public TransformTree(InfiniteScrollRect infiniteScroller) + public TransformTree(ScrollPool infiniteScroller) { Scroller = infiniteScroller; }