shoes4 icon indicating copy to clipboard operation
shoes4 copied to clipboard

Element click regions not right (need custom in_bounds? implementation)

Open jasonrclark opened this issue 10 years ago • 15 comments

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, and translate (none of the in_bounds? checks behave quite right there.

jasonrclark avatar Jul 03 '14 05:07 jasonrclark

They just use the standard in_bounds? implementation of the standard Dimensions object. Adjusted the title bit better to reflect that :)

PragTob avatar Jul 03 '14 12:07 PragTob

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 :-)

PragTob avatar Oct 16 '14 21:10 PragTob

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.

tryzniak avatar Feb 18 '15 14:02 tryzniak

Seems like we would have to apply the transforms we use when painting rects also when bounds-checking.

wasnotrice avatar Feb 18 '15 14:02 wasnotrice

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.

tryzniak avatar Feb 18 '15 16:02 tryzniak

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.

jasonrclark avatar Feb 18 '15 17:02 jasonrclark

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 :-/

PragTob avatar Feb 18 '15 17:02 PragTob

Unless someone else has started these, I will take a look at oval

estensland avatar Oct 18 '17 12:10 estensland

I haven't been looking at these, so go for it!

jasonrclark avatar Oct 18 '17 16:10 jasonrclark

@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 avatar Dec 06 '17 16:12 estensland

@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 avatar Dec 07 '17 04:12 jasonrclark

@jasonrclark thanks!

estensland avatar Dec 07 '17 11:12 estensland

@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

estensland avatar Jan 31 '18 01:01 estensland

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 avatar Jan 31 '18 05:01 jasonrclark

@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: screen shot 2018-02-10 at 8 51 48 am

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.

estensland avatar Feb 28 '18 13:02 estensland