bevy/crates/bevy_text/src
ira 9f906fdc8b Improve ergonomics and reduce boilerplate around creating text elements. (#5343)
# Objective

Creating UI elements is very boilerplate-y with lots of indentation.
This PR aims to reduce boilerplate around creating text elements.

## Changelog

* Renamed `Text::with_section` to `from_section`.
  It no longer takes a `TextAlignment` as argument, as the vast majority of cases left it `Default::default()`.
* Added `Text::from_sections` which creates a `Text` from a list of `TextSections`.
  Reduces line-count and reduces indentation by one level.
* Added `Text::with_alignment`.
  A builder style method for setting the `TextAlignment` of a `Text`.
* Added `TextSection::new`.
  Does not reduce line count, but reduces character count and made it easier to read. No more `.to_string()` calls!
* Added `TextSection::from_style` which creates an empty `TextSection` with a style.
  No more empty strings! Reduces indentation.
* Added `TextAlignment::CENTER` and friends.
* Added methods to `TextBundle`. `from_section`, `from_sections`, `with_text_alignment` and `with_style`.

## Note for reviewers.
Because of the nature of these changes I recommend setting diff view to 'split'.
~~Look for the book icon~~ cog in the top-left of the Files changed tab.

Have fun reviewing ❤️
<sup> >:D </sup>

## Migration Guide

`Text::with_section` was renamed to `from_section` and no longer takes a `TextAlignment` as argument.
Use `with_alignment` to set the alignment instead.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
2022-07-20 14:14:29 +00:00
..
error.rs Fix errors and panics to typical Rust conventions (#968) 2020-12-02 11:31:16 -08:00
font_atlas_set.rs Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
font_atlas.rs Replace old renderer with new renderer (#3312) 2021-12-14 03:58:23 +00:00
font_loader.rs Add support for OTF fonts (#1200) 2021-01-03 12:10:23 -08:00
font.rs small and mostly pointless refactoring (#2934) 2022-02-13 22:33:55 +00:00
glyph_brush.rs Move Size to bevy_ui (#4285) 2022-04-25 13:54:46 +00:00
lib.rs Update layout/style when scale factor changes too (#4689) 2022-05-09 14:18:02 +00:00
pipeline.rs Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
text2d.rs Use Affine3A for GlobalTransform to allow any affine transformation (#4379) 2022-07-16 00:51:12 +00:00
text.rs Improve ergonomics and reduce boilerplate around creating text elements. (#5343) 2022-07-20 14:14:29 +00:00