-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add UiImage offset property #5629
Conversation
Ping @ManevilleF for review here :) |
|
||
fn main() { | ||
App::new() | ||
// Change image filter to a pixel-art friendly |
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.
// Change image filter to a pixel-art friendly | |
// Change image filter to a pixel-art friendly mode |
} | ||
|
||
// Image rect in pixels, inside the base image. | ||
// Values are using to built a rect with begin (X, Y) and end (X, Y) format |
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.
Users would really benefit from some more advice on how these values were determined.
align_items: AlignItems::Center, | ||
..default() | ||
}, | ||
// Default image has no offset, but that's OK since it'll be update it on button_system |
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.
// Default image has no offset, but that's OK since it'll be update it on button_system | |
// Default image has no offset, but that's OK since it'll be updated in button_system |
Code quality and docs seem fine, minus a few nits. I'm not fully sold on the grand vision here, so I'll defer to @mockersf and @ManevilleF who've thought about this space more. |
The new property But to customize |
I can't do a complete review anytime soon, but anything that impact rendered size should impact layout, and I didn't see layout files being modified in this PR |
Closing in favor of #5103; let's collect our efforts there. |
Objective
Currently
UiImage
component is just a unit struct forHandle<Image>
. At it's core, it draws the image and that's it. If someone needs to have a more complex use case, like implementing a nine patch, one have to useTextureAtlas
which is good, but is a overkill for ui works.This PR is related to #5070, but it aims to make
TextureAtlas
to work withUiImage
which is a different use case IMO, since one should useTextureAtlas
andUiImage
together on same entity.Solution
Add an
offset
property toUiImage
and enable to render a portion of the image, much like aTexturaAtlas
but simplified, so users may create it's own image atlas and reuse on manyUiImage
components.Changelog
offset
property onUiImage
and changed to from unit struct to normal struct;Deref
andDerefMut
fromUiImage
since it's no longer a unit struct;extract_uinodes
to useUiImage::offset
when it's non-zero;image_button
example:Migration Guide
UiImage
is now a normal struct so it can't be directly dereferenced anymore and should use normal struct initialization.