-
Notifications
You must be signed in to change notification settings - Fork 240
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
FromFront and FromBack should equal if the position of the layer is logically same if we count from back or from the front of the stack #725
Comments
As you can see from the definition, It's very similar to how in python the number Similarly, If you expect equality checks to work, you need a canonical representation, not just an abstract index. You could for example only use I suppose to help that, there could be helper methods Note that |
I don't think I've expressed myself clearly. In stackview containing two items, where the "looked for" item is the item that is visible, should this piece of code compare equal:
that is, is_at_front_0 should equal true, as well as is_at_back_1 should equal true. Are you agreeing with me on that? |
No: It also does not know about the length of the If you want to compare two positions, you could write this function: fn point_to_same_object(pos_a: LayerPosition, pos_b: LayerPosition, container_size: usize) -> bool {
match (pos_a, pos_b) {
(LayerPosition::FromFront(a), LayerPosition::FromFront(b)) | (LayerPosition::FromBack(a), LayerPosition::FromBack(b)) => a == b,
(LayerPosition::FromFront(a), LayerPosition::FromBack(b)) | (LayerPosition::FromBack(a), LayerPosition::FromFront(b)) => a + b + 1 == container_size
}
} Then you could check |
"No: pos here is of type LayerPosition. This type is either FromFront or FromBack: you can check the type definition, it's just a regular enum." |
They do point to the same item, but that was not your question. |
Yes it was. Again, perhaps I didn't somehow make it clear, but I just wonder how clearer can I say it: |
If I have a stack that contains two items and one of the items is named "STACKED_SEARCH_BAR" which is at the top of the stack that is, it is visible and not covered by any layer, then the above should give identical answer to the comparison, i.e, FromFront(0) should be equal to FromBack(1);
But it doesn't. Tbh, I did mention this somewhere, but the introduction of very unconventional way of referring to the position of the object in a container is something else... How many times do I had to check (and still am) what Front means in that case, and ironically it means the exact opposite to what programmers are used to...
The text was updated successfully, but these errors were encountered: