bevy/crates/bevy_render/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
..
camera update wgpu to 0.13 (#5168) 2022-07-14 21:17:16 +00:00
color Very minor doc formatting changes (#5287) 2022-07-12 13:06:16 +00:00
mesh Improve ergonomics and reduce boilerplate around creating text elements. (#5343) 2022-07-20 14:14:29 +00:00
primitives Very minor doc formatting changes (#5287) 2022-07-12 13:06:16 +00:00
render_graph Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
render_phase Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
render_resource update wgpu to 0.13 (#5168) 2022-07-14 21:17:16 +00:00
renderer update wgpu to 0.13 (#5168) 2022-07-14 21:17:16 +00:00
texture update wgpu to 0.13 (#5168) 2022-07-14 21:17:16 +00:00
view Recalculate entity aabbs when meshes change (#4944) 2022-07-20 07:05:29 +00:00
extract_component.rs Visibilty Inheritance, universal ComputedVisibility and RenderLayers support (#5310) 2022-07-15 23:24:42 +00:00
extract_param.rs Make RenderStage::Extract run on the render world (#4402) 2022-07-08 23:56:33 +00:00
extract_resource.rs remove an unused import in release (#5320) 2022-07-14 23:43:57 +00:00
lib.rs add a SpatialBundle with visibility and transform components (#5344) 2022-07-18 23:27:30 +00:00
rangefinder.rs Very minor doc formatting changes (#5287) 2022-07-12 13:06:16 +00:00
render_asset.rs Make RenderStage::Extract run on the render world (#4402) 2022-07-08 23:56:33 +00:00
settings.rs Add some docs about lowspec rendering (#5091) 2022-06-25 16:22:28 +00:00
spatial_bundle.rs add a SpatialBundle with visibility and transform components (#5344) 2022-07-18 23:27:30 +00:00