Step 176: smooth UI transitions

This commit is contained in:
Bill
2026-02-09 22:18:11 -07:00
parent 6f5005b326
commit 1693fd08d6
17 changed files with 480 additions and 39 deletions

View File

@@ -0,0 +1,26 @@
#pragma once
#include <string>
#include <algorithm>
struct UIAnimationState {
std::string activeTabPath;
double tabSwitchTime = 0.0;
void recordTabSwitch(const std::string& path, double nowSeconds) {
if (path == activeTabPath) return;
activeTabPath = path;
tabSwitchTime = nowSeconds;
}
float tabFadeAlpha(const std::string& path,
double nowSeconds,
bool reduceMotion,
float durationSeconds = 0.15f) const {
if (reduceMotion) return 1.0f;
if (path.empty() || path != activeTabPath) return 1.0f;
double elapsed = nowSeconds - tabSwitchTime;
float t = (durationSeconds <= 0.0f) ? 1.0f : (float)(elapsed / durationSeconds);
return std::max(0.0f, std::min(1.0f, t));
}
};