-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial spec of IndexPath class #81
base: master
Are you sure you want to change the base?
Conversation
``` | ||
would select the item "Kitchen cabinet style", since it is in the second group of first nesting level, first group in the second level of nesting and is the fourth element in the last nesting level. | ||
|
||
![Sample tree selection](./sample-tree-selection.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might just be on my end, but the image isn't rendering for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the webview is not really aware of the relative paths here. Downloading them should work correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, it's there, but it doesn't show up. I can vouch that the picture's accurate :)
Are there for sure no situations in which you'd need to modify an IndexPath after it's been created? I feel like there might be some possible use cases for this. 🤔 |
I am not sure if there are scenarios where one would benefit from it. If the collection changes, e.g. an item suddenly becomes a collection I think it is better to create new IndexPath objects to adress the new items instead of modifying an existing one. SelectionModel just keeps overriding the path objects instead of modifying them. The big design question at hand I think is whether IndexPath should be mutable or immutable. Should one be able to change the index they are pointing to or should they return/create a new IndexPath if they want to point to something different? |
I think it was initially mutable and we changed it to immutable. Array sounds like a good idea to reduce the footprint. |
|
||
# Description | ||
|
||
The `IndexPath` class provides indexing of nested collections, for example in a TreeView. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a corresponding update to TreeView to accept an IndexPath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. TreeView does not use this yet. This is used by SelectionModel, which still needs an API spec. I would make this public along with SelectionModel. We internally use this for NavigationView.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a feature that cuts across multiple APIs, we likely want a single API spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we/I add the SelectionModel to this API spec since it is the main API this will interact with (and the only one so far)?
```c++ | ||
[WUXC_VERSION_MUXONLY] | ||
[webhosthidden] | ||
runtimeclass IndexPath : Windows.Foundation.IStringable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it need IStringable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not really need it, it's just better for debugging and representation. Should we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a debugging aid. Perhaps there is a different way to achieve the debug visualization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think debugging is fine. What does it return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the IndexPath IndexPath.CreateFrom(1,3)
it would return "R.1.3"
active/IndexPath/IndexPath.md
Outdated
[default_overload] [method_name("CreateFrom")] | ||
static IndexPath CreateFrom(Int32 index); | ||
[method_name("CreateFromGroupAndItemIndex")] | ||
static IndexPath CreateFrom(Int32 groupIndex, Int32 itemIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's obvious enough that two parameters means the grouping case, it would be more clear with a name like CreateForGroup, or some such with "group" in its name.
But how is the grouped case different from the indices case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference is that it's a bit faster and easier to use in the two index case. Updated the name to CreateFromGroupAndItemIndex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. These are convenience constructors. The most common are one and two indices(one level grouping) in which case from a usage perspective we don't have to require creating a list of one or list of two items.
``` | ||
would select the item "Kitchen cabinet style", since it is in the second group of first nesting level, first group in the second level of nesting and is the fourth element in the last nesting level. | ||
|
||
![Sample tree selection](./sample-tree-selection.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, it's there, but it doesn't show up. I can vouch that the picture's accurate :)
Should I create a tracking issue for that over at WinUI so we update it to array and adjust the API once API review has gone through? |
|
||
# Description | ||
|
||
The `IndexPath` class provides indexing of nested collections, for example in a TreeView. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a feature that cuts across multiple APIs, we likely want a single API spec.
```c++ | ||
[WUXC_VERSION_MUXONLY] | ||
[webhosthidden] | ||
runtimeclass IndexPath : Windows.Foundation.IStringable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think debugging is fine. What does it return?
Int32 GetSize(); | ||
Int32 GetAt(Int32 index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an IVectorView?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding IndexOf doesn't make much sense I think.
Are there any points that I need to follow up on or I should address here @anawishnoff @MikeHillberg @ranjeshj? |
Everything looks good here to me, but I'll leave it to @ranjeshj and @MikeHillberg for any final approval. Thanks Marcel! I believe we'll need to publish this alongside the SelectionModel spec, which will be in progress for a while until we decide between using a flexible container or attached behaviors to implement this in ItemsRepeater. So, lots of things linked together here :) I'll make sure to keep you updated and in the loop about progress on SelectionModel. |
This PR adds the initial API spec for the IndexPath class.
@anawishnoff @ranjeshj FYI
Background
To easily track selection in nested collections, we need an object that we can use to uniquely identify an item in nested collections.
This can be done with the IndexPath.
Description
The
IndexPath
class provides indexing of nested collections, for example in a TreeView.Examples
In the tree below, using the following IndexPath
would select the item "Kitchen cabinet style", since it is in the second group of first nesting level, first group in the second level of nesting and is the fourth element in the last nesting level.
Creating IndexPath objects
New IndexPaths objects can be created using the static
IndexPath.CreateFrom
andIndexPath.CreateFromIndices
methods:Comparing two IndexPaths
Comparing two
IndexPath
objects can be done using theCompareTo
function:API Notes
API Details
Appendix
Currently we use a
Vector<int>
to store those indices. Since we don't have any operations that would modify the size of an IndexPath, that is how many nesting levels it works with, shouldn't we switch to an array to increase performance?