From d970cf74f29b7d337b23fbed4b6758831d29dc5a Mon Sep 17 00:00:00 2001 From: Eray Cepni Date: Wed, 14 Oct 2026 14:20:33 +0300 Subject: [PATCH] UI: Fade chat button with touch controls Apply touch-control opacity to the chat button so it fades after inactivity and reappears on touch. Keep it visible when touch controls are disabled. --- UI/EmuScreen.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 73ba801d2f..d41f4c3177 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -107,6 +107,18 @@ static AVIDump avi; extern bool g_TakeScreenshot; +class FadingChatButton : public UI::ChoiceWithValueDisplay { +public: + using UI::ChoiceWithValueDisplay::ChoiceWithValueDisplay; + + void Draw(UIContext &dc) override { + float opacity = g_Config.bShowTouchControls ? GamepadGetOpacity() : 1.0f; + dc.Draw()->PushAlpha(opacity); + UI::ChoiceWithValueDisplay::Draw(dc); + dc.Draw()->PopAlpha(); + } +}; + // Handles control rotation due to internal screen rotation. void EmuScreen::UpdatePSPButtons(uint32_t bitsToSet, uint32_t bitsToClear) { if (!IsOnTop()) { @@ -1284,7 +1296,7 @@ void EmuScreen::CreateViews() { if (g_Config.iChatButtonPosition != 8) { auto n = GetI18NCategory(I18NCat::NETWORKING); AnchorLayoutParams *layoutParams = AnchorInCorner(bounds, g_Config.iChatButtonPosition, 80.0f, 50.0f); - chatButton_ = root_->Add(new ChoiceWithValueDisplay(&newChatMessages_, n->T("Chat"), layoutParams)); + chatButton_ = root_->Add(new FadingChatButton(&newChatMessages_, n->T("Chat"), layoutParams)); chatButton_->OnClick.Add([this](UI::EventParams &e) { // Really, the check here should be "has a hard keyboard". bool focus = System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_DESKTOP;