Better mechanism to fade out the side bar when not on EmuScreen

This commit is contained in:
Henrik Rydgård committed 2023-07-16 08:55:48 +02:00
1 parent 393531317e
commit 6bb97b3d46
6 files changed
+31 -10

No files matched your search

+12
View File
@@ -3,6 +3,7 @@
#include "Common/System/OSD.h"
#include "Common/TimeUtil.h"
#include "Common/Log.h"
#include "Common/Math/math_util.h"
OnScreenDisplay g_OSD;
@@ -50,6 +51,17 @@ std::vector<OnScreenDisplay::ProgressBar> OnScreenDisplay::ProgressBars() {
return bars_; // makes a copy.
}
void OnScreenDisplay::NudgeSidebar() {
sideBarShowTime_ = time_now_d();
}
float OnScreenDisplay::SidebarAlpha() const {
double timeSinceNudge = time_now_d() - sideBarShowTime_;
// Fade out in 1/4 second, 0.1s after the last nudge.
return saturatef(1.0f - ((float)timeSinceNudge - 0.1f) * 4.0f);
}
void OnScreenDisplay::Show(OSDType type, const std::string &text, const std::string &text2, const std::string &icon, float duration_s, const char *id) {
// Automatic duration based on type.
if (duration_s <= 0.0f) {