shoes4
shoes4 copied to clipboard
Element click regions not right (need custom in_bounds? implementation)
Noticed in the course of testing out #768 that some of the drawing elements don't have an appropriate click region--i.e. they allow you to click outside of the actual drawn part of the screen. They all seem to just treat the enclosing rectangle as the click region.
- [ ] Arc
- [x] Line
- [x] Oval
- [ ] Star
- [ ] Advanced General fix to make this work right with
rotate
,displace
, andtranslate
(none of thein_bounds?
checks behave quite right there.
They just use the standard in_bounds?
implementation of the standard Dimensions object. Adjusted the title bit better to reflect that :)
Added newcomer friendly as I think this is well cut out with 3 distinct method implementations with not much overlap but at the same time some learning about these elements. Happy to help as well :-)
Add Rect to it :( It doesn't want to behave properly when there's a "rotate" applied. Here's an app I tested on:
Shoes.app do
fill "#333"
rotate 45
rect(30, 30, 40, 40).click { }
end
The misbehavior is noticeable when I hover the pointer over rect corners.
Seems like we would have to apply the transforms we use when painting rects also when bounds-checking.
Yeah, we need to consider the transform. Looks like transformations are entrusted on backend and they make core-level 'in_bounds?' useless. Shall registering click regions be in the backend layer? I don't like that idea, it apears to me that backend should only be drawing things and getting input.
Ugh, those options aren't going to be nice. Either we rely on the backend for the transformations (which can be fairly clean, but potentially loads up the work for later backends), or re-implement transformations in core (which could diverge from the backend's actual drawing algorithms, and is just plain a bunch of work).
I think it's actually reasonable to split that work into a separate item from this one, and just leave this as the basic in_bounds?
for the elements in question. Hopefully whichever way we do, we can apply the transform -> bounds thing systematically across all the elements rather than one-by-one.
Thanks for noticing this @seethemhigh ! :)
I'm also pro on a separate issue... I really don't want to implement transform/rotate on the front end. Which makes bounds checking even harder... I don't know if we should do it all in the backend, if there is a rotate set or take rotate into account (which might be hard).
I guess that overall rotate
might cause headaches also elsewhere... probably absolute_right/absolute_bottom etc. will also return incorrect values. Which would then speak for implementing it on the frontend.. but.. no/I dunno :-/
Unless someone else has started these, I will take a look at oval
I haven't been looking at these, so go for it!
@jasonrclark so I have been fighting with arc for a while now, and I have it mostly working. While I am refactoring and sorting out the remaining edge cases, I wanted to see code architecture-wise if you think all that code should stay in arc.rb or if I have helper methods to break them out into shared bits if another could use it?
@estensland That's awesome!
Sharing depends a lot on the type of code. We do share things via modules like you'll find in https://github.com/shoes/shoes4/tree/master/shoes-core/lib/shoes/common. Most of those have a very firm definition of the "theme" of what we're sharing (clickability, hovering, etc.) If you see bits that might be shareable and we can give a good name to, I'd say call it out in comments on where the code lives in arc right now and we can chat about pulling it out.
@jasonrclark thanks!
@jasonrclark Just quick update that I didn't fall off face of the earth...still attacking this.
I realized after the holidays that my approach didn't work with multiple cases...so I am revamping it to use a better formula, I really wish that I remembered more from math classes haha
Thanks for the update @estensland! Glad to hear that you're still making progress, and looking forward to seeing what you come up with.
I've honestly avoided a gradient bug we had for months because I just couldn't face the math in my evening coding time after work 😆
@jasonrclark didn't realize all my commits got reported here!
But I am wrapping up specs now on the most basic implementation of arc...in other words these shapes:
But since even the "simple_arc" sample uses nofill, and this arc business is all fresh in my mind, I am going to try to get #in_bounds? to work for that as well.
Then I will surely need some help on where all this code should live, if just on arc.rb or somewhere else.