bevy/examples/ecs
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
..
component_change_detection.rs Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
custom_query_param.rs Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
ecs_guide.rs Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
event.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
fixed_timestep.rs Split time functionality into bevy_time (#4187) 2022-05-26 00:27:18 +00:00
generic_system.rs Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
hierarchy.rs Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
iter_combinations.rs Use Affine3A for GlobalTransform to allow any affine transformation (#4379) 2022-07-16 00:51:12 +00:00
parallel_query.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
removal_detection.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
startup_system.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
state.rs Improve ergonomics and reduce boilerplate around creating text elements. (#5343) 2022-07-20 14:14:29 +00:00
system_chaining.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
system_closure.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
system_param.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
system_sets.rs Implement From<bool> for ShouldRun. (#5306) 2022-07-14 17:26:40 +00:00
timers.rs Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00