-
Using TouchArea with Image { image-fit: contain; } inconvenient. Am I missing something? Probably there is a workaround for this case \ or prob it should be made for first time? In simple words - TouchArea sticks outside Image. example: TouchArea placed inside
will occupy full size of the Image, so it's tricky to map a mouse event to the same pixel on the image, if any gaps surrounds image (and they will - because of "image-fit: contain;")
PS: sorry for my level of English, if something is not clear. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 11 replies
-
PPSS: I know that I can map mouse events, because I know size of the window & aspect ratio of the image, |
Beta Was this translation helpful? Give feedback.
-
You just need to set the height or width of Image. Note: Just change one of them, the other will automatically be proportional. Otherwise, the height and width will be changed to what you set, even if it doesn't fit the proportions. |
Beta Was this translation helpful? Give feedback.
-
Hi, @W9pi3cZ1, thank you for response! |
Beta Was this translation helpful? Give feedback.
-
I think the To avoid a binding loop, you could probably have single expression determine the scale the image should have, based on its parent width and height, and then set the image's width and height based on the scale. You need to make sure though, that the parent size does not also depend on the image size. |
Beta Was this translation helpful? Give feedback.
-
Hello, @W9pi3cZ1. I'm really grateful for the time you have spent, but I've just tried your approach and it doesn't work for me as I've expected - the image doesn't stay fitted to the window size and can overflow (watch the attached video). I want to make, as clear as possible, what I want to get. So here is video of expected behavior (in terms of resizing) - Actual problem - I want to fit TouchArea into a RENDERED image without loosing this fancy resizing, but I don't have any access to real rendered(!) image size \ position :
So there is no clear way to get this information. Here is a simplified example of my code:
Here is a code used for video of "your" code:
Code directly from dreams:
PS: I can just calculate rendered size of the image from window size, image source size, aspect ratio of the image, but It's definitely NOT a convenient way. |
Beta Was this translation helpful? Give feedback.
@ogoffart final solution - forget about image and just scale size of TouchArea same way, as u suggested before for image. In my case its whole overlay, not just TouchArea, but idea is the same.
Thoughts about why u had not any issues with that, and I had - probably u have a lot more powerful device, so in your case performance is degrading too, but fps still higher than 60 and my 10 years old pc with weak CPU just dies from this load. So that's why.
Writing here just to provide info for next generations (for me, when i will forget this solution 0)0))