scarpe-team / scarpe

Scarpe - shoes but running on webview
Other
162 stars 29 forks source link

Draw context inheritance #513

Closed noahgibbs closed 8 months ago

noahgibbs commented 8 months ago

This depends on #512, so I'm opening it as draft.

Description

Draw context -- fill, stroke, etc -- is set in Shoes according to the drawable tree. You get the draw context from your own slot, and it gets it from its parent, etc. I checked and it does not act like a global variable, where setting a "sibling" slot ahead of yours sets your draw context.

As a side effect, there's no longer any reason to check the draw_context in the display service, or to send it as a style. This takes care of that transparently.

This PR implements that. Also a bunch of tests, because it needs it. Some of the Niente/Lacci test infra needed to be built for this, so that's why it depends on #512.

Checklist

noahgibbs commented 8 months ago

Nah, never mind, right now this is pretty broken. So: another reason not to merge it yet!

noahgibbs commented 8 months ago

Huh. Looking at this, I'm going about it wrong. Instead of passing parent everywhere, I should check current_slot.

noahgibbs commented 8 months ago

Okay, better now.

noahgibbs commented 8 months ago

Hrm. While there's an error still, that's not what's bothering me. Using the current slot isn't quite right -- that's what happens if you create a new drawable from Shoes::App. But it's not what happens if you use @s.button (where @s would be a stack or similar.) That isn't necessarily the current slot. Hrm...

noahgibbs commented 8 months ago

This mostly works... But it causes some problems with things like oval fill. Basically, this runs into problems we already have, that we have attempts to fix (#507, #511). But the draw context improvements won't fix that without the Calzini fixes.

noahgibbs commented 8 months ago

Not a stupid question at all. So, with this change you would no longer see a difference between those. They would just show up with the stroke being red when the display-side drawable is created. The draw context style is still technically set here (not gone yet, but soon), but it won't do anything if Calzini is operating properly. We can get rid of any place we pass the draw context as a style, since the same values will be passed as individual styles. But even before we get rid of them, they won't do anything.