bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Flip UI image

Open ickshonpe opened this issue 3 years ago • 4 comments

Objective

Fixes #3225, Allow for flippable UI Images

Solution

Add flip_x and flip_y fields to UiImage, and swap the UV coordinates accordingly in ui_prepare_nodes.

Changelog

  • Changes UiImage to a struct with texture, flip_x, and flip_y fields.
  • Adds flip_x and flip_y fields to ExtractedUiNode.
  • Changes extract_uinodes to extract the flip_x and flip_y values from UiImage.
  • Changes prepare_uinodes to swap the UV coordinates as required.
  • Changes UiImage derefs to texture field accesses.

ickshonpe avatar Oct 18 '22 13:10 ickshonpe

I'd probably prefer a singular Flip component, which is reused across sprites and UI images, but I won't block on that.

Yes, I'm trying to keep things as close to sprites as possible (with the least breaking changes).

I chose FlipImage rather than Flip because a lot of people already find the UI confusing, so I wanted to be extra clear about what it's flipping. Most of the ambiguity is in the Style component though so maybe Flip is fine. Or it could be FlipTexture.

ickshonpe avatar Oct 19 '22 07:10 ickshonpe

I don't think it should be a separate component. What happens if I add the FlipImage component to a PbrBundle? Is the image file used for texture flipped?

I would prefer to have two fields flip_x and flip_y in an existing UI component, maybe UiImage

mockersf avatar Oct 19 '22 12:10 mockersf

I don't think it should be a separate component. What happens if I add the FlipImage component to a PbrBundle? Is the image file used for texture flipped?

I would prefer to have two fields flip_x and flip_y in an existing UI component, maybe UiImage

I agree that would be better, it's just that I was worried it'd break a lot of existing code that expects UiImage to be a newtype.

ImageMode is only used as a marker component for the image widget at the moment, the flip_x/y fields could be added to it as an alternative? Or would it be better to just have the changes to ExtractedUiNode and ui_prepare_nodes in this PR, and have another PR for the interface?

ickshonpe avatar Nov 01 '22 10:11 ickshonpe

I agree that would be better, it's just that I was worried it'd break a lot of existing code that expects UiImage to be a newtype.

Yep, no worries about breaking existing code here :) This sort of migration is very easy. Not immediately sure about your other question though.

alice-i-cecile avatar Nov 01 '22 11:11 alice-i-cecile

bors r+

cart avatar Nov 14 '22 21:11 cart

Build failed (retrying...):

bors[bot] avatar Nov 14 '22 21:11 bors[bot]