-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Hidden vectorio #6363
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
Hidden vectorio #6363
Conversation
Latest commit corrects an issue where vectorio shapes that were nested at least 2 layers deep inside of groups would not be properly hidden / shown if the outermost parent (or probably any parent except the one the shape was directly inside of) was the one set to hidden. |
With a point in the right direction by WarriorOfWire I think the code from here is how this can be done in the more generic way without having to check for each possible type: circuitpython/shared-module/displayio/Group.c Lines 147 to 152 in 5f4f667
I'll come back to this and attempt something similar for the changes in this PR to minimize the amount of new code needed. |
Some additional context for $future_reader: By doing it the explicit type check way you exploit knowledge of the actual Draw Protocol implementation for each of the types (which can be changed!). This duplicates knowledge of the Draw Protocol types’ implementations outside of the types themselves. 😬 As an example of where this would add pain, I’m planning to make a python binding so people can implement whatever bonkers shapes they can imagine in Python. That would potentially not use VectorShape for the Draw Protocol implementation. Then there’s a pending bug “hidden does not work on PythonShape”! Flexibility, forward compatibility and ease of maintenance is what Draw Protocol is for ❤️. Less code is icing on the cake, but the real value is in easier iteration on vectorio, where all the valuable ancillary features (like hidden!) “just work” with new additions. It’s like an interface in other languages - there’s a touch more ceremony in C but the micropython |
@WarriorOfWire First, thanks for the additional explanation this is all quite helpful. And the ability to define new shapes from python sounds awesome! Looking into changing this I'm thinking I will need to expose the set_dirty() function in the protocol impl here: circuitpython/shared-bindings/vectorio/__init__.h Lines 22 to 28 in 5f4f667
Does that seem right to you? I made a first attempt at it and wasn't successful but am going to get back into it and try some more. Wanted to make sure I was headed down the right path though before I go too far. |
@FoamyGuy yeah, that sounds right! Probably the right thing to do is to replace on_dirty with your new draw protocol method too. https://github.com/adafruit/circuitpython/blob/main/shared-module/vectorio/Polygon.c#L198 |
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 got this working, but unsure if I've gone about it in the correct way.
I didn't end up making a new function I don't think, I'm not sure how to set the on_dirty event
I think this is ready now. I've tested several more scenarios around it and everything has worked as expected so far. Am interested in getting clarification from @WarriorOfWire about what possible issues may still exist as well as feedback from anyone else. |
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.
This looks great to me. Thank you for sticking with this change!
@tannewt I have not followed this. Do you want to review before merging? |
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 just skimmed it and it looks good. Thanks to @WarriorOfWire for the main review.
resolves #6204
Here's a short recording showing the behavior with these changes running the reproducer code from the issue
hidden_vectorio_objs.mp4