New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New property TRegion for TCastleImagePersistent allows selecting a cropped region from a UI image set #442
Conversation
Make it possiable to load a large image, and select the source image region to use.
Zoom in on the pixel at the fixed mouse location.
@Freedomax Fantastic! Thank you! This is a feature I absolutely want, I know many people will be happy using this for UI atlas like https://opengameart.org/content/sci-fi-user-interface-elements , https://opengameart.org/content/rpg-user-interface . The editor for region looks great, I see it snaps to image pixels, super! I will review in detail later. In particular I'll think about |
Use |
If we use |
As for basing it on
|
Hi, @michaliskambi ,I am not sure how you will implement the |
Makes sense, I'll try to do it today evening. I'll borrow some ideas from TCastleVector4Persistent. And yes, I think I'll make it used just like TVector4 and TCastleVector4Persistent are. That is:
Note that This means that from Pascal API, you should mostly just deal with |
… implementation without specifically listing all "XxxPersistent" properties
Despite the comment -- it works perfectly, there's no problem setting it in editor, it seems.
Also small code style adjustments to castleinternalregiondialog.pas
…understand it now :)
…plicates the code more, and doesn't seem very necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Sorry it took me ages to review + apply.
Done, I committed a few changes, merging!
Some more important changes:
-
I added to this PR a change related to
TCastleComponent.ValueIsStreamed
, so thatCastleInternalRttiUtils
doesn't need to have hardcoded all those checks for specialXxxPersistent
classes.I planned this already, and noticed that your changes to
CastleInternalRttiUtils
related to addingTFloatRectanglePersistent
would benefit from it. So diff toCastleInternalRttiUtils
is simpler, albeit I needed to change more existing code. -
I removed
RegionEnabled
. Testing everywhere just is region rectangle.IsEmpty
is simpler, and I didn't observe any drawbacks. And it's also simpler for user to use, editingRegion
"just works".
A minor UI thing I noticed is that using mouse wheel in the region dialog sometimes shifts the image -- when the mouse cursor is outside of the image, it seems. It's a big surprising when the image is small. It's not a big deal and it doesn't prevent using the dialog for main purpose, so I'll leave this TODO for later.
TRegion.1.mp4
Also added a property editor for easy use.
TRegion
is actually aTBorder
, without re-adding a type (that would also need a separateEnable
variable), as TBorder is actually a rectangle, and its default value is easy to keep compatibility with. The newly added property editor (to choose a region from an image) can also be used forTBorder
and other purposes, but currently it is only used forTRegion
.