Request: Header and Footer offsets for ListView #175
Replies: 1 comment 8 replies
-
Just so we understand correctly, is the header/footer being scrollable within the If it must be scrollable, one option to avoid baking header/footer elements into your actual E.g. /// <summary>
/// Wrapper around a List but with an additional element for a Header/Footer.
/// </summary>
/// <typeparam name="TData">The type of data in the List.</typeparam>
public class HeaderFooterList<TData> : IList<TData>
{
public TData Header;
public TData Footer;
public List<TData> Data;
/// <summary>
/// Wrapper around <see cref="Data"/>.
/// </summary>
/// <param name="index"></param>
/// <returns>
/// If <c><paramref name="index"/> == 0</c>, returns <see cref="Header"/>.
/// If <c><paramref name="index"/> == <see cref="Count"/> - 1</c>, returns <see cref="Footer"/>.
/// Otherwise returns <c><paramref name="index"/> - 1</c> into <see cref="Data"/>.
/// </returns>
public TData this[int index]
{
get
{
return index == 0 ? Header :
index == Count - 1 ? Footer :
Data[index - 1];
}
set
{
if (index == 0)
{
Header = value;
}
else if (index == Count - 1)
{
Footer = value;
}
else
{
Data[index - 1] = value;
}
}
}
/// <summary>
/// Returns size of <see cref="Data"/> + 2, for <see cref="Header"/> and <see cref="Footer"/>.
/// </summary>
public int Count => Data.Count + 2;
// implement rest of IList<TData> interface as desired
} And then you can bind that to the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi friends,
With the power and worldspace-ness of ListViews, one wants a semi-transparent header or footer floating over (above) a ListView. For this, one would need to specify header and footer offsets that specify blank space along the layout axis. Basically, the equivalent would be adding faux DataSource elements at 0 and N-1 that map to blank cell of a specified length along the layout axis.
This is currently possible by using faux list items but that makes life painful on our side because that has to get baked into the DataSource plus a custom prefab and bindings (makes for terrible code to maintain). Forgive me if I'm wrong, but I suspect it's a small and clean add that on the Nova side: a header and footer length added to the total virtual list length plus a single offset value with a "dirty propagation" pattern identical to changing any other UIBlock2D layout property.
I know y'all have a ton on your plate, but if you could squeeze this lil guy in that would be huge. Happy to talk bounty if that's available. This and a
OnRectTransformChanged()
analogue would encourage me up to put a repo live that contains the UIBlock-friendly blur as well as some other utils that I was planning to gift to Nova and the community. I was planning to do it either way, I'm just swamped myself and would love to feel like low hanging fruit is being picked where possible -- I know how tough and tricky the main features are to design and develop! Meanwhile, since we have to make URP utils for UIBlock over here, then why not share and let everyone make use of that.Beta Was this translation helpful? Give feedback.
All reactions