bevy/examples/ui
Lena Milizé 73605f43b6 Replace the bool argument of Timer with TimerMode (#6247)
As mentioned in #2926, it's better to have an explicit type that clearly communicates the intent of the timer mode rather than an opaque boolean, which can be only understood when knowing the signature or having to look up the documentation.

This also opens up a way to merge different timers, such as `Stopwatch`, and possibly future ones, such as `DiscreteStopwatch` and `DiscreteTimer` from #2683, into one struct.

Signed-off-by: Lena Milizé <me@lvmn.org>

# Objective

Fixes #2926.

## Solution

Introduce `TimerMode` which replaces the `bool` argument of `Timer` constructors. A `Default` value for `TimerMode` is `Once`.

---

## Changelog

### Added

- `TimerMode` enum, along with variants `TimerMode::Once` and `TimerMode::Repeating`

### Changed

- Replace `bool` argument of `Timer::new` and `Timer::from_seconds` with `TimerMode`
- Change `repeating: bool` field of `Timer` with `mode: TimerMode`

## Migration Guide

- Replace `Timer::new(duration, false)` with `Timer::new(duration, TimerMode::Once)`.
- Replace `Timer::new(duration, true)` with `Timer::new(duration, TimerMode::Repeating)`.
- Replace `Timer::from_seconds(seconds, false)` with `Timer::from_seconds(seconds, TimerMode::Once)`.
- Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`.
- Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`.
2022-10-17 13:47:01 +00:00
..
button.rs Rename UiColor to BackgroundColor (#6087) 2022-09-25 00:39:17 +00:00
font_atlas_debug.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
scaling.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
text.rs Change UI coordinate system to have origin at top left corner (#6000) 2022-10-11 12:51:44 +00:00
text_debug.rs Change UI coordinate system to have origin at top left corner (#6000) 2022-10-11 12:51:44 +00:00
transparency_ui.rs Rename UiColor to BackgroundColor (#6087) 2022-09-25 00:39:17 +00:00
ui.rs Clarify bevy::ui::Node field and documentation (#5995) 2022-10-17 13:27:24 +00:00