Ellpeck / MLEM

Libraries for MonoGame and FNA that provide abstractions, quality of life improvements and additional features like a ui system and easy input handling.
https://mlem.ellpeck.de/
MIT License
84 stars 6 forks source link

DisplayArea has incorrect value in some case #14

Closed Gandifil closed 10 months ago

Gandifil commented 10 months ago

Hi!

You have written that coder can use DisplayArea for mouse input handle.

I don't set size vector for image exactly, and have got this: image

Red rectangle - DisplayArea Blue rectangle - what I mean real DisplayArea.

So, if i try to check mouse events I can't see real image area. If I will use scaleToImage, it makes image too big, because asset is hi-res.

Ellpeck commented 10 months ago

Hi! This is not an issue with the library, it's just about how the Image element works: The size of the element itself doesn't necessarily have to correspond to the size of the texture that it displays. This may be a bit confusing, but is the intended behavior!

If you want an easy way to deal with this issue for your situation, I recommend upgrading to the prerelease versions of MLEM (more info in the README!), where I recently introduced the SetWidthBasedOnAspect and SetHeightBasedOnAspect properties for images (https://github.com/Ellpeck/MLEM/commit/294af052ae313e1dabd3c9ac098b2ee32b155e66). These allow setting a fixed or percentual width (or height), and then having the height (or width) automatically adjust itself so that the image element's size matches the texture it displays exactly.

Let me know if that answered your question :))

Gandifil commented 10 months ago

Thanks you! SetWidthBasedOnAspect and SetHeightBasedOnAspect are literally what I meant and what I wanted.