rename "InfiniteScrollRect" to "ScrollPool"

This commit is contained in:
Sinai 2021-04-17 04:11:45 +10:00
parent 2e5fb72716
commit bcc89455a7
7 changed files with 16 additions and 14 deletions

View File

@ -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;

View File

@ -6,7 +6,7 @@ using UnityEngine;
namespace UnityExplorer.UI.Widgets
{
public interface IListDataSource
public interface IPoolDataSource
{
int ItemCount { get; }

View File

@ -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
/// </summary>
/// <param name="dataSource"></param>
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;

View File

@ -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;

View File

@ -8,9 +8,9 @@ using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.Widgets
{
public class SimpleListSource<T> : IListDataSource
public class SimpleListSource<T> : IPoolDataSource
{
internal InfiniteScrollRect Scroller;
internal ScrollPool Scroller;
public Func<List<T>> GetEntries;
public List<T> currentEntries;
@ -29,7 +29,7 @@ namespace UnityExplorer.UI.Widgets
}
private string currentFilter;
public SimpleListSource(InfiniteScrollRect infiniteScroller, Func<List<T>> getEntriesMethod,
public SimpleListSource(ScrollPool infiniteScroller, Func<List<T>> getEntriesMethod,
Func<RectTransform, SimpleCell<T>> createCellMethod, Action<SimpleCell<T>, int> setICellMethod,
Func<T, string, bool> shouldFilterMethod)
{

View File

@ -9,7 +9,7 @@ using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.Widgets
{
public class TransformTree : IListDataSource
public class TransformTree : IPoolDataSource
{
public Func<IEnumerable<GameObject>> GetRootEntriesMethod;
@ -33,7 +33,7 @@ namespace UnityExplorer.UI.Widgets
}
private string currentFilter;
internal InfiniteScrollRect Scroller;
internal ScrollPool Scroller;
internal readonly List<CachedTransform> displayedObjects = new List<CachedTransform>();
@ -44,7 +44,7 @@ namespace UnityExplorer.UI.Widgets
public int ItemCount => displayedObjects.Count;
public TransformTree(InfiniteScrollRect infiniteScroller)
public TransformTree(ScrollPool infiniteScroller)
{
Scroller = infiniteScroller;
}