Conversation
…ipping of a UI node's content such as images and text. `bevy_ui::ui_node` * Added `UiContentOrientation` enum component. * Implemented `From<UiContentOrientation>` for `Mat4` `bevy_ui::layout` * If a node has a `ContentSize` and its `UiContentOrientation` is set to rotate the node sideways, the width and height of the MeasureFunc's inputs and outputs are flipped. `bevy_ui::widget::text::text_system` * The height and width of the text bounds is switched for text nodes orientated sideways. `bevy_ui::node_bundle` * Added field `content_orientation: UiContentOrientation` to all UI node bundles. examples: * Changed PBR example to use `UiContentOrientation` instead of manipulation of the transform. * Added the example `ui_image_symmetries`.
…ent, instead of `UiSurface::update_measure`. Fixed bugs in extraction transform calculations causing incorrect positioning and sizing. Added `text_transformed` example. Clean up formatting and applied CI suggested fixes.
alice-i-cecile
left a comment
There was a problem hiding this comment.
I prefer this to the linked PR.
|
I wish we could call this |
|
What about
Maybe |
|
This seems like a good direction. @ickshonpe A few questions:
|
No that changes are only applied to single nodes. I'm not keen on allowing transformations of sub-trees. I'd prefer to simulate it by spawning a second layout tree with a transformation that is applied globally to all nodes in the tree.
The layout is unaffected, only the content within the node is transformed respecting the node's boundaries.
The regular The regular |
|
I saw that this PR is said to fix #8998 which is about vertical text support like CSS's However, all the examples shown in the PR description is about rotating the whole text piece, which can't really be called vertical text support. If the only thing this PR does is to support such rotation, I would suggest either it should not mark that issue as fixed, or that issue should be updated to a narrower scope. But maybe I'm missing something? |
Yeah I should I have been clearer maybe, the vertical text support I'm talking about here is for tasks like labelling the vertical axis of a graph. This PR is mainly about changing the orientation of content and negotiating with Taffy to find the ideal size to fit the reorientated content into the UI node layout. It's meant to be content agnostic as far as possible. The layout of glyphs into rows for languages that can be written vertically like Japanese is something separate and would be handled by |
|
triage: still up for adoption with some nasty merge conflicts |

Objective
Allow limited rotation and flipping of a UI node's content without modifying its
Transformcomponent or breaking the UI layout and clipping.Fixes #8998
Solution
Generalization of #6688.
UI nodes have a
UiContentTransformcomponent, withidentity,flip_x,flip_y,rotate_leftandrotate_rightmethods which you can compose to get whatever orientation you want.Notes:
The API is a bit mathy and might be quite counterintuitive for some users, particularly when working with text.
I really hate the naming scheme using cardinal directions for the variants of
UiContentTransform. There is a long discussion about this at UI Image Rotation #6688. All the other ideas were terrible too.Probably still got a few bugs but it all seems to work mostly. Needs some refactoring and more doc comments.
In the original design widgets didn't need to be aware of the content transform and layout handled everything. But I realised it wasn't going to work without changes to Taffy (probably coming in Taffy 0.4).
You can still use the regular
Transformcomponent to rotate and scale UI elements as before.This is a relatively large PR but it doesn't make too many changes, most of the code is examples and helper methods.
Changelog
flip_xandflip_yfrom theUiImageandUiTextureAtlasImagecomponents.UiContentTransformenum component.ui_image_symmetriesandtext_transformedexamples.From<UiContentOrientation>forMat4content_transform: UiContentTransformfield to all UI node bundles.Migration Guide
The
flip_xandflip_yfields have been removed from theUiImageandUiTextureAtlasImagecomponents. Theflip_x()andflip_y()methods of theUiContentTransformcomponent now control image flipping.