| 32 | } |
| 33 | |
| 34 | void UiController::process() |
| 35 | { |
| 36 | if (_lastChangeTimePoint) { |
| 37 | auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( |
| 38 | std::chrono::steady_clock::now() - *_lastChangeTimePoint) |
| 39 | .count(); |
| 40 | if (_on) { |
| 41 | ImGui::GetStyle().Alpha = toFloat(std::min(duration, FadeInOutDuration)) / FadeInOutDuration; |
| 42 | if (ImGui::GetStyle().Alpha == 1) { |
| 43 | _lastChangeTimePoint = std::nullopt; |
| 44 | } |
| 45 | } |
| 46 | else { |
| 47 | ImGui::GetStyle().Alpha = |
| 48 | toFloat(std::max(FadeInOutDuration - duration, std::chrono::milliseconds::rep(0))) / FadeInOutDuration; |
| 49 | if (ImGui::GetStyle().Alpha == 0) { |
| 50 | _lastChangeTimePoint = std::nullopt; |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |